cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1004847 - in /cxf/branches/2.2.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Date Tue, 05 Oct 2010 22:53:35 GMT
Author: sergeyb
Date: Tue Oct  5 22:53:34 2010
New Revision: 1004847

URL: http://svn.apache.org/viewvc?rev=1004847&view=rev
Log:
Merged revisions 1004846 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1004846 | sergeyb | 2010-10-05 23:48:06 +0100 (Tue, 05 Oct 2010) | 1 line
  
  [CXF-3035] : Explictly dealing with Set-Cookie headers containing Expires fields, and applying
a patch from Joachim Kainz
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
    svn:mergeinfo = /cxf/trunk:1004846

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java?rev=1004847&r1=1004846&r2=1004847&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
Tue Oct  5 22:53:34 2010
@@ -335,14 +335,20 @@ public class AbstractClient implements C
             if (null == entry.getKey()) {
                 continue;
             }
-            if (HttpUtils.isDateRelatedHeader(entry.getKey())) {
-                currentResponseBuilder.header(entry.getKey(), entry.getValue());
-            } else if (entry.getValue().size() > 0) {
-                String[] values = entry.getValue().get(0).split(",");
-                for (String s : values) {
-                    String theValue = s.trim();
-                    if (theValue.length() > 0) {
-                        currentResponseBuilder.header(entry.getKey(), theValue);
+            if (entry.getValue().size() > 0) {
+                if (HttpUtils.isDateRelatedHeader(entry.getKey())) {
+                    currentResponseBuilder.header(entry.getKey(), entry.getValue().get(0));
+                    continue;                    
+                }
+                boolean splitPossible = !(HttpHeaders.SET_COOKIE.equalsIgnoreCase(entry.getKey())
+                                          && entry.getValue().get(0).contains(HttpHeaders.EXPIRES));
+                for (String val : entry.getValue()) {
+                    String[] values = splitPossible ? val.split(",") : new String[]{val};
+                    for (String s : values) {
+                        String theValue = s.trim();
+                        if (theValue.length() > 0) {
+                            currentResponseBuilder.header(entry.getKey(), theValue);
+                        }
                     }
                 }
             }

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=1004847&r1=1004846&r2=1004847&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
(original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
Tue Oct  5 22:53:34 2010
@@ -116,10 +116,21 @@ public class BookStore {
     
     @GET
     @Path("tempredirect")
-    public Response tempRedirect() {
+    public Response tempRedirectAndSetCookies() {
         URI uri = UriBuilder.fromPath("whatever/redirection")
             .queryParam("css1", "http://bar").build();
-        return Response.temporaryRedirect(uri).build();
+        return Response.temporaryRedirect(uri)
+                       .header("Set-Cookie", "a=b").header("Set-Cookie", "c=d")
+                       .build();
+    }
+    
+    @GET
+    @Path("setcookies")
+    public Response setComplexCookies() {
+        return Response.ok().header("Set-Cookie", 
+                                    "bar.com.anoncart=107894933471602436; Domain=.bar.com;"
+                                    + " Expires=Thu, 01-Oct-2020 23:44:22 GMT; Path=/")
+                                    .build();
     }
     
     @GET

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1004847&r1=1004846&r2=1004847&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Tue Oct  5 22:53:34 2010
@@ -77,6 +77,19 @@ public class JAXRSClientServerBookTest e
         MultivaluedMap<String, Object> map = r.getMetadata();
         assertEquals("http://localhost:" + PORT + "/whatever/redirection?css1=http%3A//bar",
                      map.getFirst("Location").toString());
+        List<Object> cookies = r.getMetadata().get("Set-Cookie");
+        assertNotNull(cookies);
+        assertEquals(2, cookies.size());
+    }
+    
+    @Test
+    public void testSetCookieWebClient() throws Exception {
+        WebClient client = WebClient.create("http://localhost:" + PORT + "/bookstore/setcookies");
+        Response r = client.type("*/*").get();
+        assertEquals(200, r.getStatus());
+        List<Object> cookies = r.getMetadata().get("Set-Cookie");
+        assertNotNull(cookies);
+        assertEquals(1, cookies.size());
     }
     
     
@@ -235,6 +248,9 @@ public class JAXRSClientServerBookTest e
         assertTrue(values.contains("POST") && values.contains("GET")
                    && values.contains("DELETE") && values.contains("PUT"));
         assertEquals(0, ((InputStream)response.getEntity()).available());
+        List<Object> date = response.getMetadata().get("Date");
+        assertNotNull(date);
+        assertEquals(1, date.size());
     }
     
     @Test

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java?rev=1004847&r1=1004846&r2=1004847&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
(original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
Tue Oct  5 22:53:34 2010
@@ -45,6 +45,7 @@ import org.apache.commons.httpclient.met
 import org.apache.commons.httpclient.methods.RequestEntity;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.jaxrs.ext.multipart.Attachment;
@@ -253,6 +254,23 @@ public class JAXRSMultipartTest extends 
     }
     
     @Test
+    public void testAddCollectionOfBooksWithProxy() {
+        String address = "http://localhost:" + PORT;
+        MultipartStore client = JAXRSClientFactory.create(address, MultipartStore.class);
+        
+        WebClient.client(client).header("Content-Type", "multipart/mixed;type=application/xml");
+        
+        List<Book> books = new ArrayList<Book>();
+        books.add(new Book("CXF 1", 1L));
+        books.add(new Book("CXF 2", 2L));
+        List<Book> books2 = client.addBooks(books);
+        assertNotSame(books, books2);
+        assertEquals(2, books2.size());
+        assertEquals(books.get(0).getId(), books2.get(0).getId());
+        assertEquals(books.get(1).getId(), books2.get(1).getId());
+    }
+    
+    @Test
     public void testXopWebClient() throws Exception {
         String address = "http://localhost:" + PORT + "/bookstore/xop";
         JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();



Mime
View raw message