cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1460735 - in /cxf/trunk/rt/frontend/jaxrs/src: main/java/org/apache/cxf/jaxrs/impl/LinkBuilderImpl.java test/java/org/apache/cxf/jaxrs/impl/TestLinkBuilderImpl.java
Date Mon, 25 Mar 2013 15:54:27 GMT
Author: sergeyb
Date: Mon Mar 25 15:54:27 2013
New Revision: 1460735

URL: http://svn.apache.org/r1460735
Log:
Merge branch 'jaxrs-linkbuilder-reset' of https://github.com/stain/cxf into trunk

Added:
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/TestLinkBuilderImpl.java
  (with props)
Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/LinkBuilderImpl.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/LinkBuilderImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/LinkBuilderImpl.java?rev=1460735&r1=1460734&r2=1460735&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/LinkBuilderImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/LinkBuilderImpl.java
Mon Mar 25 15:54:27 2013
@@ -44,7 +44,7 @@ public class LinkBuilderImpl implements 
     @Override
     public Link build(Object... values) {
         URI uri = ub.build(values);
-        return new LinkImpl(uri, params);
+        return new LinkImpl(uri, new HashMap<String, String>(params));
     }
 
     @Override
@@ -54,7 +54,7 @@ public class LinkBuilderImpl implements 
         URI resolvedLinkUri = baseUri != null 
             ? HttpUtils.resolve(UriBuilder.fromUri(baseUri), uri) : uri;
         URI relativized = HttpUtils.relativize(requestUri, resolvedLinkUri);
-        return new LinkImpl(relativized, params);
+        return new LinkImpl(relativized, new HashMap<String, String>(params));
     }
 
     @Override

Added: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/TestLinkBuilderImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/TestLinkBuilderImpl.java?rev=1460735&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/TestLinkBuilderImpl.java
(added)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/TestLinkBuilderImpl.java
Mon Mar 25 15:54:27 2013
@@ -0,0 +1,55 @@
+package org.apache.cxf.jaxrs.impl;
+
+import static org.junit.Assert.assertEquals;
+
+import java.net.URI;
+
+import javax.ws.rs.core.Link;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class TestLinkBuilderImpl {
+    Link.Builder linkBuilder = new LinkBuilderImpl();
+
+    @Test
+    public void build() throws Exception {
+        Link prevLink = linkBuilder.uri("http://example.com/page1").rel("previous").build();
+        assertEquals("<http://example.com/page1>;rel=\"previous\"", prevLink.toString());
+    }
+
+    @Test
+    public void relativeBuild() throws Exception {
+        URI base = URI.create("http://example.com/page2");
+        Link prevLink = linkBuilder.uri("http://example.com/page1").rel("previous").buildRelativized(base);
+        assertEquals("<page1>;rel=\"previous\"", prevLink.toString());
+    }
+
+    @Test
+    public void severalAttributes() throws Exception {
+        Link prevLink = linkBuilder.uri("http://example.com/page1").rel("previous").title("A
title").build();
+        assertEquals("<http://example.com/page1>;rel=\"previous\";title=\"A title\"",
prevLink.toString());
+    }
+
+    @Test
+    public void copyOnBuild() throws Exception {
+        Link prevLink = linkBuilder.uri("http://example.com/page1").rel("previous").build();
+        Link nextLink = linkBuilder.uri("http://example.com/page3").rel("next").build();
+
+        // Previously built link should not be affected by reuse of link builder
+        assertEquals("<http://example.com/page1>;rel=\"previous\"", prevLink.toString());
+        assertEquals("<http://example.com/page3>;rel=\"next\"", nextLink.toString());
+    }
+
+    @Ignore("Ignored due to CXF-4919")
+    @Test
+    public void copyOnRelativeBuild() throws Exception {
+        URI base = URI.create("http://example.com/page2");
+        Link prevLink = linkBuilder.uri("http://example.com/page1").rel("previous").buildRelativized(base);
+        Link nextLink = linkBuilder.uri("http://example.com/page3").rel("next").buildRelativized(base);
+
+        // Previously built link should not be affected by reuse of link builder
+        assertEquals("<page1>;rel=\"previous\"", prevLink.toString());
+        assertEquals("<page3>;rel=\"next\"", nextLink.toString());
+    }
+}

Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/TestLinkBuilderImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/TestLinkBuilderImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message