cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1352616 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Date Thu, 21 Jun 2012 16:59:24 GMT
Author: sergeyb
Date: Thu Jun 21 16:59:24 2012
New Revision: 1352616

URL: http://svn.apache.org/viewvc?rev=1352616&view=rev
Log:
[CXF-4350] Checking Request URI for query parameters if no QUERY_STRING is set as in case
of JMS/Local

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSJmsTest.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JMSBookStore.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java?rev=1352616&r1=1352615&r2=1352616&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java Thu
Jun 21 16:59:24 2012
@@ -213,6 +213,13 @@ public final class HttpUtils {
             return pathToMatch; 
         }
         String requestAddress = getProtocolHeader(m, Message.REQUEST_URI, "/");
+        if (m.get(Message.QUERY_STRING) == null) {
+            int index = requestAddress.lastIndexOf('?');
+            if (index > 0 && index < requestAddress.length()) {
+                m.put(Message.QUERY_STRING, requestAddress.substring(index + 1));
+                requestAddress = requestAddress.substring(0, index);
+            }
+        }
         String baseAddress = getBaseAddress(m);
         pathToMatch = getPathToMatch(requestAddress, baseAddress, addSlash);
         m.put(var, pathToMatch);

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSJmsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSJmsTest.java?rev=1352616&r1=1352615&r2=1352616&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSJmsTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSJmsTest.java
Thu Jun 21 16:59:24 2012
@@ -125,6 +125,21 @@ public class JAXRSJmsTest extends Abstra
     }
     
     @Test
+    public void testGetBookFromProxyClientWithQuery() throws Exception {
+        // setup the the client
+        String endpointAddressUrlEncoded = "jms:jndi:dynamicQueues/test.jmstransport.text"
+             + "?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory"
+             + "&replyToName=dynamicQueues/test.jmstransport.response"
+             + "&jndiURL=tcp://localhost:" + JMS_PORT
+             + "&jndiConnectionFactoryName=ConnectionFactory";
+               
+        JMSBookStore client = JAXRSClientFactory.create(endpointAddressUrlEncoded, JMSBookStore.class);
+        Book book = client.getBookByURLQuery(new String[] {"1", "2", "3"});
+        assertEquals("Get a wrong response code.", 200, WebClient.client(client).getResponse().getStatus());
+        assertEquals("Get a wrong book id.", 123, book.getId());
+    }
+    
+    @Test
     public void testGetBook() throws Exception {
         Context ctx = getContext();
         ConnectionFactory factory = (ConnectionFactory)ctx.lookup("ConnectionFactory");

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JMSBookStore.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JMSBookStore.java?rev=1352616&r1=1352615&r2=1352616&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JMSBookStore.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JMSBookStore.java
Thu Jun 21 16:59:24 2012
@@ -41,6 +41,8 @@ import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Response;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Marshaller;
@@ -66,6 +68,16 @@ public class JMSBookStore {
     
 
     @GET
+    @Path("/bookidarray")
+    @Produces("application/xml")
+    public Book getBookByURLQuery(@QueryParam("id") String[] ids) throws Exception {
+        if (ids == null || ids.length != 3) {
+            throw new WebApplicationException(); 
+        }
+        return doGetBook(ids[0] + ids[1] + ids[2]);
+    }
+    
+    @GET
     @Path("/books/{bookId}/")
     @Produces("application/xml")
     public Book getBook(@PathParam("bookId") String id) throws BookNotFoundFault {



Mime
View raw message