diff --git a/gradle.properties b/gradle.properties index 18bd384..dbac760 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ group = org.xbib name = net -version = 1.3.3 +version = 1.3.4 # test jackson.version = 2.8.11 diff --git a/net-url/src/main/java/org/xbib/net/URL.java b/net-url/src/main/java/org/xbib/net/URL.java index c9007a8..0c089b1 100755 --- a/net-url/src/main/java/org/xbib/net/URL.java +++ b/net-url/src/main/java/org/xbib/net/URL.java @@ -325,10 +325,14 @@ public class URL implements Comparable { } } - public Builder newBuilder() { + public Builder mutator() { return builder; } + public Builder newBuilder() { + return new Builder(); + } + private String toString(boolean withFragment) { if (internalStringRepresentation != null) { return internalStringRepresentation; diff --git a/net-url/src/test/java/org/xbib/net/URLBuilderTest.java b/net-url/src/test/java/org/xbib/net/URLBuilderTest.java index 5de5ed3..bebac25 100644 --- a/net-url/src/test/java/org/xbib/net/URLBuilderTest.java +++ b/net-url/src/test/java/org/xbib/net/URLBuilderTest.java @@ -118,7 +118,7 @@ class URLBuilderTest { @Test void testAllParts() { - assertUrl(URL.https().resolveFromHost("foo.bar.com").port(3333) + assertUrl(URL.https().resolveFromHost("foobar.com").port(3333) .pathSegment("foo") .pathSegment("bar") .matrixParam("mtx1", "val1") @@ -127,11 +127,11 @@ class URLBuilderTest { .queryParam("q2", "v2") .fragment("zomg it's a fragment") .toUrlString(), - "https://foo.bar.com:3333/foo/bar;mtx1=val1;mtx2=val2?q1=v1&q2=v2#zomg%20it's%20a%20fragment"); + "https://foobar.com:3333/foo/bar;mtx1=val1;mtx2=val2?q1=v1&q2=v2#zomg%20it's%20a%20fragment"); } @Test - void testSlashInHost() { + void testSlashHost() { URL.http().resolveFromHost("/").toUrlString(); } @@ -259,12 +259,21 @@ class URLBuilderTest { } @Test - void testNewBuilder() { - URL.Builder builder = URL.from("http://google.com:8008/foobar").newBuilder(); + void testMutator() { + URL.Builder builder = URL.from("http://google.com:8008/foobar").mutator(); builder.scheme("https"); assertEquals("https://google.com:8008/foobar", builder.build().toString()); } + @Test + void testNewBuilder() { + URL url = URL.from("http://google.com:8008/foobar"); + URL.Builder builder = url.newBuilder() + .scheme(url.getScheme()) + .schemeSpecificPart(url.getSchemeSpecificPart()); + assertEquals("http://google.com:8008/foobar", builder.build().toString()); + } + @Test void testUserInfo(){ String s = URL.http().userInfo("foo:bar").host("foo.com").toUrlString(); diff --git a/net-url/src/test/java/org/xbib/net/URLResolverTest.java b/net-url/src/test/java/org/xbib/net/URLResolverTest.java index cc9c55d..dfd9a2a 100644 --- a/net-url/src/test/java/org/xbib/net/URLResolverTest.java +++ b/net-url/src/test/java/org/xbib/net/URLResolverTest.java @@ -14,6 +14,10 @@ class URLResolverTest { void testResolveURI() throws Exception { URI base = URI.create("http://example.org/foo"); assertEquals("http://example.org/", base.resolve("/").toString()); + assertEquals("http://example.org/foo", base.toString()); + URI rel = URI.create("http://foobar/rel"); + assertEquals("http://foobar/rel", base.resolve(rel).toString()); + assertEquals("http://example.org/foo", base.toString()); assertEquals("http://example.org/foobar", base.resolve("/foobar").toString()); assertEquals("http://example.org/foobar", base.resolve("foobar").toString()); base = URI.create("http://example.org/foo/"); diff --git a/net-url/src/test/java/org/xbib/net/URLTest.java b/net-url/src/test/java/org/xbib/net/URLTest.java index 14233a5..9e40585 100644 --- a/net-url/src/test/java/org/xbib/net/URLTest.java +++ b/net-url/src/test/java/org/xbib/net/URLTest.java @@ -20,14 +20,12 @@ class URLTest { for (JsonTest test : tests) { String base = test.base; String input = test.input; - //System.err.println("testing: " + base + " " + input + " " + test.failure); if (test.skip) { continue; } if (test.failure) { try { URL url = URL.base(base).resolve(input); - //System.err.println("resolved: " + url.toString()); fail(); } catch (Exception e) { // pass @@ -36,7 +34,6 @@ class URLTest { if (base != null && input != null) { try { URL url = URL.base(base).resolve(input); - //System.err.println("resolved: " + url.toString()); if (test.protocol != null) { assertEquals(test.protocol, url.getScheme() + ":"); }