cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-5577] Initial workaround for the edge case involving matrix parameters
Date Mon, 31 Mar 2014 12:29:29 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 532c5a78a -> b3288ed94


[CXF-5577] Initial workaround for the edge case involving matrix parameters


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/b3288ed9
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/b3288ed9
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/b3288ed9

Branch: refs/heads/master
Commit: b3288ed94bd6518780839a6b9716c64575c68073
Parents: 532c5a7
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Mon Mar 31 13:29:09 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Mon Mar 31 13:29:09 2014 +0100

----------------------------------------------------------------------
 .../org/apache/cxf/jaxrs/model/URITemplate.java |  3 +-
 .../cxf/systest/jaxrs/BookStoreSpring2.java     | 43 ++++++++++++++++++++
 .../jaxrs/JAXRSClientServerSpringBookTest.java  | 41 ++++++++++++++++---
 .../src/test/resources/jaxrs/WEB-INF/beans.xml  |  1 +
 4 files changed, 82 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/b3288ed9/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
index a31444f..637beb1 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
@@ -199,9 +199,10 @@ public final class URITemplate {
         // sub-resources.
         
         String finalGroup = i > groupCount ? SLASH : m.group(groupCount);
-        if (finalGroup == null) {
+        if (finalGroup == null || finalGroup.startsWith(SLASH_QUOTE)) {
             finalGroup = SLASH;
         }
+        
         templateVariableToValue.putSingle(FINAL_MATCH_GROUP, finalGroup);
 
         return true;

http://git-wip-us.apache.org/repos/asf/cxf/blob/b3288ed9/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring2.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring2.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring2.java
new file mode 100644
index 0000000..b604c52
--- /dev/null
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring2.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.systest.jaxrs;
+
+
+import javax.ws.rs.GET;
+import javax.ws.rs.MatrixParam;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+
+@Path("2/")
+@Produces("application/json")
+public class BookStoreSpring2 {
+    @GET
+    public Book getDefaultBook(@MatrixParam("a") String a) {
+        return new Book("Default" + (a == null ? "" : a), 123L);
+    }
+    @GET
+    @Path("{id}")
+    public Book getBookWithId(@PathParam("id") Long id) {
+        return new Book("Id", id);
+    }
+}
+
+

http://git-wip-us.apache.org/repos/asf/cxf/blob/b3288ed9/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
index bea04ca..f2da064 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
@@ -152,11 +152,11 @@ public class JAXRSClientServerSpringBookTest extends AbstractBusClientServerTest
     @Test
     public void testGetGeneratedWadlWithExternalSchemas() throws Exception {
         String address = "http://localhost:" + PORT + "/the/bookstore";    
-        checkWadlResourcesInfo(address, address, "/book.xsd", 1);
+        checkWadlResourcesInfo(address, address, "/book.xsd", 2);
     
         checkSchemas(address, "/book.xsd", "/bookid.xsd", "import");
         checkSchemas(address, "/bookid.xsd", null, null);
-        checkWadlResourcesInfo(address, address, "/book.xsd", 1);
+        checkWadlResourcesInfo(address, address, "/book.xsd", 2);
     }
     
     @Test
@@ -544,9 +544,40 @@ public class JAXRSClientServerSpringBookTest extends AbstractBusClientServerTest
     
     @Test
     public void testGetDefaultBook() throws Exception {
-        String endpointAddress =
-            "http://localhost:" + PORT + "/the/bookstore"; 
-        getBook(endpointAddress, "resources/expected_get_book123json.txt"); 
+        String endpointAddress = "http://localhost:" + PORT + "/the/bookstore"; 
+        WebClient wc = WebClient.create(endpointAddress);
+        wc.accept("application/json");
+        Book book = wc.get(Book.class);
+        assertEquals(123L, book.getId()); 
+    }
+    @Test
+    public void testGetDefaultBook2() throws Exception {
+        String endpointAddress = "http://localhost:" + PORT + "/the/bookstore/2/"; 
+        WebClient wc = WebClient.create(endpointAddress);
+        wc.accept("application/json");
+        Book book = wc.get(Book.class);
+        assertEquals(123L, book.getId());
+        assertEquals("Default", book.getName());
+    }
+    @Test
+    public void testGetDefaultBookMatrixParam() throws Exception {
+        String endpointAddress = "http://localhost:" + PORT + "/the/bookstore/2/"; 
+        WebClient wc = WebClient.create(endpointAddress);
+        wc.matrix("a", "b");
+        wc.accept("application/json");
+        WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(1000000L);
+        Book book = wc.get(Book.class);
+        assertEquals(123L, book.getId());
+        assertEquals("Defaultb", book.getName());
+    }
+    @Test
+    public void testGetBookById() throws Exception {
+        String endpointAddress = "http://localhost:" + PORT + "/the/bookstore/2/123"; 
+        WebClient wc = WebClient.create(endpointAddress);
+        wc.accept("application/json");
+        Book book = wc.get(Book.class);
+        assertEquals(123L, book.getId());
+        assertEquals("Id", book.getName());
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/cxf/blob/b3288ed9/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/beans.xml
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/beans.xml b/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/beans.xml
index 4b095c1..ce1dac2 100644
--- a/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/beans.xml
+++ b/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/beans.xml
@@ -31,6 +31,7 @@
     <jaxrs:server id="bookservice" address="/bookstore">
         <jaxrs:serviceBeans>
             <ref bean="serviceBean"/>
+            <bean class="org.apache.cxf.systest.jaxrs.BookStoreSpring2"/>
         </jaxrs:serviceBeans>
         <jaxrs:providers>
             <ref bean="jaxbProvider"/>


Mime
View raw message