http-client-branch: more test scenarios for RequestBuilderTest http-client-branch
authorchegar
Wed, 08 Nov 2017 22:51:18 +0000
branchhttp-client-branch
changeset 55791 4849d9e433be
parent 55790 d73370fdf575
child 55792 0936888d5a4a
http-client-branch: more test scenarios for RequestBuilderTest
test/jdk/java/net/httpclient/RequestBuilderTest.java
--- a/test/jdk/java/net/httpclient/RequestBuilderTest.java	Wed Nov 08 18:11:00 2017 +0000
+++ b/test/jdk/java/net/httpclient/RequestBuilderTest.java	Wed Nov 08 22:51:18 2017 +0000
@@ -351,4 +351,28 @@
         assertEquals(builder.expectContinue(false).build().expectContinue(), false);
         assertEquals(builder.expectContinue(true).build().expectContinue(), true);
     }
+
+    @Test
+    public void testEquals() {
+        assertNotEquals(newBuilder(URI.create("http://foo.com")),
+                        newBuilder(URI.create("http://bar.com")));
+
+        HttpRequest.Builder builder = newBuilder(uri);
+        assertEquals(builder.build(), builder.build());
+        assertEquals(builder.build(), newBuilder(uri).build());
+
+        builder.POST(noBody());
+        assertEquals(builder.build(), builder.build());
+        assertEquals(builder.build(), newBuilder(uri).POST(noBody()).build());
+        assertEquals(builder.build(), newBuilder(uri).POST(fromString("")).build());
+        assertNotEquals(builder.build(), newBuilder(uri).build());
+        assertNotEquals(builder.build(), newBuilder(uri).GET().build());
+        assertNotEquals(builder.build(), newBuilder(uri).PUT(noBody()).build());
+
+        builder = newBuilder(uri).header("x", "y");
+        assertEquals(builder.build(), builder.build());
+        assertEquals(builder.build(), newBuilder(uri).header("x", "y").build());
+        assertNotEquals(builder.build(), newBuilder(uri).header("x", "Z").build());
+        assertNotEquals(builder.build(), newBuilder(uri).header("z", "y").build());
+    }
 }