cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r768350 - in /cxf/trunk/rt/frontend/jaxrs/src: main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java test/java/org/apache/cxf/jaxrs/Customer.java test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
Date Fri, 24 Apr 2009 16:19:48 GMT
Author: sergeyb
Date: Fri Apr 24 16:19:48 2009
New Revision: 768350

URL: http://svn.apache.org/viewvc?rev=768350&view=rev
Log:
JAXRS: minor update for DefaultValue for CookieParams be picked up, given that HttpHeaders
never returns null

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=768350&r1=768349&r2=768350&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java Fri
Apr 24 16:19:48 2009
@@ -637,8 +637,8 @@
     private static Object processCookieParam(Message m, String cookieName, 
                               Class<?> pClass, Type genericType, String defaultValue)
{
         List<String> values = new HttpHeadersImpl(m).getRequestHeader(HttpHeaders.COOKIE);
-        String value = values != null && values.get(0).contains(cookieName + '=')
? values.get(0) 
-                       : defaultValue != null ? cookieName + '=' + defaultValue : null;
+        String value = values.size() == 1 && values.get(0).contains(cookieName +
'=') 
+                       ? values.get(0) : defaultValue != null ? cookieName + '=' + defaultValue
: null;
         
         if (value == null) {
             return null;

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java?rev=768350&r1=768349&r2=768350&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java Fri Apr 24
16:19:48 2009
@@ -29,6 +29,8 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.ws.rs.Consumes;
+import javax.ws.rs.CookieParam;
+import javax.ws.rs.DefaultValue;
 import javax.ws.rs.FormParam;
 import javax.ws.rs.HeaderParam;
 import javax.ws.rs.MatrixParam;
@@ -297,6 +299,11 @@
         // complete
     }
     
+    public void testCookieParam(@CookieParam("c1") String c1,
+                                @CookieParam("c2") @DefaultValue("c2Value") String c2) {
+        // complete
+    }
+    
     public void testParams(@Context UriInfo info,
                            @Context HttpHeaders hs,
                            @Context Request r,

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java?rev=768350&r1=768349&r2=768350&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
Fri Apr 24 16:19:48 2009
@@ -537,6 +537,24 @@
     }
     
     @Test
+    public void testCookieParameters() throws Exception {
+        Class[] argType = {String.class, String.class};
+        Method m = Customer.class.getMethod("testCookieParam", argType);
+        MessageImpl messageImpl = new MessageImpl();
+        MultivaluedMap<String, String> headers = new MetadataMap<String, String>();
+        headers.add("Cookie", "c1=c1Value");
+        messageImpl.put(Message.PROTOCOL_HEADERS, headers);
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null),
+                                                           null, 
+                                                           messageImpl);
+        assertEquals(params.size(), 2);
+        assertEquals("c1Value", params.get(0));
+        assertEquals("c2Value", params.get(1));
+        
+        
+    }
+    
+    @Test
     public void testFromStringParameters() throws Exception {
         Class[] argType = {UUID.class, CustomerGender.class, CustomerGender.class};
         Method m = Customer.class.getMethod("testFromStringParam", argType);



Mime
View raw message