@@ -174,9 +174,8 @@ abstract static class TestCase {
174174 abstract int expectedResponseCode ();
175175
176176 /**
177- * Expected response headers map, header name -> value.
178- * Value "*" asserts the header is present with any value.
179- * Value "-" asserts the header is not present.
177+ * Expected response headers map, header name -> value. Value "*" asserts the header is present
178+ * with any value. Value "-" asserts the header is not present.
180179 *
181180 * @return the expected response headers for this test case.
182181 */
@@ -268,8 +267,7 @@ public void helloWorld() throws Exception {
268267 fullTarget ("HelloWorld" ),
269268 ImmutableList .of (
270269 TestCase .builder ()
271- .setExpectedResponseHeaders (ImmutableMap .of (
272- "Content-Length" , "*" ))
270+ .setExpectedResponseHeaders (ImmutableMap .of ("Content-Length" , "*" ))
273271 .setExpectedResponseText ("hello\n " )
274272 .build (),
275273 FAVICON_TEST_CASE ,
@@ -315,23 +313,23 @@ public void bufferedWrites() throws Exception {
315313 TestCase .builder ()
316314 .setUrl ("/target?writes=2" )
317315 .setExpectedResponseText ("write 0\n write 1\n " )
318- .setExpectedResponseHeaders (ImmutableMap . of (
319- "x-write-0" , "true" ,
320- "x-write-1 " , "true" ,
321- "x-written " , "true" ,
322- "Content-Length " , "16"
323- ))
316+ .setExpectedResponseHeaders (
317+ ImmutableMap . of (
318+ "x-write-0 " , "true" ,
319+ "x-write-1 " , "true" ,
320+ "x-written " , "true" ,
321+ "Content-Length" , "16" ))
324322 .build (),
325323 TestCase .builder ()
326324 .setUrl ("/target?writes=2&flush=true" )
327325 .setExpectedResponseText ("write 0\n write 1\n " )
328- .setExpectedResponseHeaders (ImmutableMap . of (
329- "x-write-0" , "true" ,
330- "x-write-1 " , "true" ,
331- "x-written " , "- " ,
332- "Transfer-Encoding " , "chunked" ))
333- . build ( )
334- ));
326+ .setExpectedResponseHeaders (
327+ ImmutableMap . of (
328+ "x-write-0 " , "true" ,
329+ "x-write-1 " , "true " ,
330+ "x-written " , "-" ,
331+ "Transfer-Encoding" , "chunked" ) )
332+ . build () ));
335333 }
336334
337335 @ Test
@@ -683,10 +681,12 @@ public void packageless() throws Exception {
683681 public void multipart () throws Exception {
684682 MultiPartRequestContent multiPartRequestContent = new MultiPartRequestContent ();
685683 byte [] bytes = new byte [17 ];
686- multiPartRequestContent .addPart (new ContentSourcePart ("bytes" , null ,
687- HttpFields .EMPTY , new ByteBufferRequestContent (ByteBuffer .wrap (bytes ))));
688- multiPartRequestContent .addPart (new MultiPart .ContentSourcePart ("string" , null ,
689- HttpFields .EMPTY , new StringRequestContent ("1234567890" )));
684+ multiPartRequestContent .addPart (
685+ new ContentSourcePart (
686+ "bytes" , null , HttpFields .EMPTY , new ByteBufferRequestContent (ByteBuffer .wrap (bytes ))));
687+ multiPartRequestContent .addPart (
688+ new MultiPart .ContentSourcePart (
689+ "string" , null , HttpFields .EMPTY , new StringRequestContent ("1234567890" )));
690690 multiPartRequestContent .close ();
691691
692692 String expectedResponse =
@@ -842,27 +842,39 @@ private void testFunction(
842842 String uri = "http://localhost:" + serverPort + testCase .url ();
843843 Request request = httpClient .POST (uri );
844844
845- request .headers (headers -> {
846- testCase .httpContentType ().ifPresent (contentType -> headers .put (HttpHeader .CONTENT_TYPE , contentType ));
847- testCase .httpHeaders ().forEach (headers ::put );
848- });
845+ request .headers (
846+ headers -> {
847+ testCase
848+ .httpContentType ()
849+ .ifPresent (contentType -> headers .put (HttpHeader .CONTENT_TYPE , contentType ));
850+ testCase .httpHeaders ().forEach (headers ::put );
851+ });
849852 request .body (testCase .requestContent ());
850853 ContentResponse response = request .send ();
851854 expect
852855 .withMessage ("Response to %s is %s %s" , uri , response .getStatus (), response .getReason ())
853856 .that (response .getStatus ())
854857 .isEqualTo (testCase .expectedResponseCode ());
855- testCase .expectedResponseHeaders ().ifPresent (expectedResponseHeaders -> {
856- for (Map .Entry <String , String > entry : expectedResponseHeaders .entrySet ()) {
857- if ("*" .equals (entry .getValue ())) {
858- expect .that (response .getHeaders ().getFieldNamesCollection ()).contains (entry .getKey ());
859- } else if ("-" .equals (entry .getValue ())) {
860- expect .that (response .getHeaders ().getFieldNamesCollection ()).doesNotContain (entry .getKey ());
861- } else {
862- expect .that (response .getHeaders ().getValuesList (entry .getKey ())).contains (entry .getValue ());
863- }
864- }
865- });
858+ testCase
859+ .expectedResponseHeaders ()
860+ .ifPresent (
861+ expectedResponseHeaders -> {
862+ for (Map .Entry <String , String > entry : expectedResponseHeaders .entrySet ()) {
863+ if ("*" .equals (entry .getValue ())) {
864+ expect
865+ .that (response .getHeaders ().getFieldNamesCollection ())
866+ .contains (entry .getKey ());
867+ } else if ("-" .equals (entry .getValue ())) {
868+ expect
869+ .that (response .getHeaders ().getFieldNamesCollection ())
870+ .doesNotContain (entry .getKey ());
871+ } else {
872+ expect
873+ .that (response .getHeaders ().getValuesList (entry .getKey ()))
874+ .contains (entry .getValue ());
875+ }
876+ }
877+ });
866878 testCase
867879 .expectedResponseText ()
868880 .ifPresent (text -> expect .that (response .getContentAsString ()).isEqualTo (text ));
0 commit comments