You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2012/07/09 19:47:34 UTC

svn commit: r1359308 - in /cxf/branches/2.5.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/

Author: sergeyb
Date: Mon Jul  9 17:47:34 2012
New Revision: 1359308

URL: http://svn.apache.org/viewvc?rev=1359308&view=rev
Log:
Merged revisions 1359302 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes

................
  r1359302 | sergeyb | 2012-07-09 18:35:25 +0100 (Mon, 09 Jul 2012) | 13 lines
  
  Merged revisions 1359298,1359300 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1359298 | sergeyb | 2012-07-09 18:29:14 +0100 (Mon, 09 Jul 2012) | 1 line
    
    Updates to the test filter to validate that UriInfo.getPathParameters is working as expected
  ........
    r1359300 | sergeyb | 2012-07-09 18:30:44 +0100 (Mon, 09 Jul 2012) | 1 line
    
    [CXF-4409] Updating ProviderFactory to avoid clearing the proxies during recursive calls
  ........
................

Modified:
    cxf/branches/2.5.x-fixes/   (props changed)
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
    cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
    cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/FaultyRequestHandler.java
    cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
    cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
    cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java

Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1359298-1359300
  Merged /cxf/branches/2.6.x-fixes:r1359302

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

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java?rev=1359308&r1=1359307&r2=1359308&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java (original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java Mon Jul  9 17:47:34 2012
@@ -74,6 +74,7 @@ import org.apache.cxf.message.MessageUti
 public class MultipartProvider extends AbstractConfigurableProvider
     implements MessageBodyReader<Object>, MessageBodyWriter<Object> {
     
+    private static final String ACTIVE_JAXRS_PROVIDER_KEY = "active.jaxrs.provider";
     private static final Logger LOG = LogUtils.getL7dLogger(MultipartProvider.class);
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(MultipartProvider.class);
 
@@ -357,8 +358,14 @@ public class MultipartProvider extends A
                                             Annotation[] anns,
                                             String mimeType, int id) {
         MediaType mt = MediaType.valueOf(mimeType);
-        MessageBodyWriter<Object> r = 
-            (MessageBodyWriter)mc.getProviders().getMessageBodyWriter(cls, genericType, anns, mt);
+        mc.put(ACTIVE_JAXRS_PROVIDER_KEY, this);
+        
+        MessageBodyWriter<Object> r = null;
+        try {
+            r = (MessageBodyWriter)mc.getProviders().getMessageBodyWriter(cls, genericType, anns, mt);
+        } finally {
+            mc.put("active.jaxrs.provider", null); 
+        }
         if (r == null) {
             org.apache.cxf.common.i18n.Message message = 
                 new org.apache.cxf.common.i18n.Message("NO_MSG_WRITER",

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java?rev=1359308&r1=1359307&r2=1359308&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java (original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java Mon Jul  9 17:47:34 2012
@@ -63,6 +63,7 @@ import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageUtils;
 
 public final class ProviderFactory {
+    private static final String ACTIVE_JAXRS_PROVIDER_KEY = "active.jaxrs.provider";
     private static final Logger LOG = LogUtils.getL7dLogger(ProviderFactory.class);
     private static final ProviderFactory SHARED_FACTORY = new ProviderFactory();
     
@@ -642,7 +643,8 @@ public final class ProviderFactory {
             return false;
         }
         boolean injected = false;
-        if (this != SHARED_FACTORY || !isJaxbBasedProvider(ep)) {
+        if ((this != SHARED_FACTORY || !isJaxbBasedProvider(ep))
+            && m.get(ACTIVE_JAXRS_PROVIDER_KEY) != ep) {
             injectContextValues(pi, m);
             injected = true;
         }

Modified: cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=1359308&r1=1359307&r2=1359308&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java (original)
+++ cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java Mon Jul  9 17:47:34 2012
@@ -214,6 +214,12 @@ public class BookStore {
     }
     
     @GET
+    @Path("propogateExceptionVar/{i}")
+    public Book propogateExceptionWithVar() throws BookNotFoundFault {
+        return null;
+    }
+    
+    @GET
     @Path("name-in-query")
     @Produces("application/xml")
     @XMLInstruction("<!DOCTYPE Something SYSTEM 'my.dtd'><?xmlstylesheet href='common.css'?>")

Modified: cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/FaultyRequestHandler.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/FaultyRequestHandler.java?rev=1359308&r1=1359307&r2=1359308&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/FaultyRequestHandler.java (original)
+++ cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/FaultyRequestHandler.java Mon Jul  9 17:47:34 2012
@@ -19,6 +19,7 @@
 package org.apache.cxf.systest.jaxrs;
 
 import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 
@@ -32,9 +33,16 @@ public class FaultyRequestHandler implem
     private UriInfo uriInfo;
     
     public Response handleRequest(Message m, ClassResourceInfo resourceClass) {
-        if (uriInfo.getPath().endsWith("/propogateexception4")) {
-            m.getExchange().put("org.apache.cxf.systest.for-out-fault-interceptor", Boolean.TRUE);
-            throw new RuntimeException();
+        if (uriInfo.getPath().endsWith("/propogateExceptionVar/1")) {
+            MultivaluedMap<String, String> vars = uriInfo.getPathParameters();
+            if (vars.size() == 1 
+                && vars.get("i") != null 
+                && vars.get("i").size() == 1 
+                && "1".equals(vars.getFirst("i"))) {
+                
+                m.getExchange().put("org.apache.cxf.systest.for-out-fault-interceptor", Boolean.TRUE);
+                throw new RuntimeException();
+            }
         }
         return null;
     }

Modified: cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1359308&r1=1359307&r2=1359308&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java (original)
+++ cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java Mon Jul  9 17:47:34 2012
@@ -376,7 +376,7 @@ public class JAXRSClientServerBookTest e
     @Test
     public void testPropogateException4() throws Exception {
         String data = "<nobook/>";
-        getAndCompare("http://localhost:" + PORT + "/bookstore/propogateexception4",
+        getAndCompare("http://localhost:" + PORT + "/bookstore/propogateExceptionVar/1",
                       data, "application/xml", 500);
     }
     

Modified: cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java?rev=1359308&r1=1359307&r2=1359308&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java (original)
+++ cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java Mon Jul  9 17:47:34 2012
@@ -240,7 +240,6 @@ public class JAXRSMultipartTest extends 
     public void testAddBookAsJAXBJSONProxy() throws Exception {
         MultipartStore store = 
             JAXRSClientFactory.create("http://localhost:" + PORT, MultipartStore.class);
-        
         Book b = store.addBookJaxbJsonWithConsumes(new Book2("CXF in Action", 1L), 
                                            new Book("CXF in Action - 2", 2L));
         assertEquals(124L, b.getId());
@@ -248,6 +247,15 @@ public class JAXRSMultipartTest extends 
     }
     
     @Test
+    public void testUseProxyToAddBookAndSimpleParts() throws Exception {
+        MultipartStore store = 
+            JAXRSClientFactory.create("http://localhost:" + PORT, MultipartStore.class);
+        Book b = store.testAddBookAndSimpleParts(new Book("CXF in Action", 124L), "1", "2");
+        assertEquals(124L, b.getId());
+        assertEquals("CXF in Action - 12", b.getName());
+    }
+    
+    @Test
     public void testAddBookAsJAXBOnlyProxy() throws Exception {
         MultipartStore store = 
             JAXRSClientFactory.create("http://localhost:" + PORT, MultipartStore.class);

Modified: cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java?rev=1359308&r1=1359307&r2=1359308&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java (original)
+++ cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java Mon Jul  9 17:47:34 2012
@@ -374,6 +374,17 @@ public class MultipartStore {
     }
     
     @POST
+    @Path("/books/jaxbandsimpleparts")
+    @Consumes("multipart/related")
+    @Produces("text/xml")
+    public Book testAddBookAndSimpleParts(
+        @Multipart(value = "rootPart", type = "text/xml") Book b1,
+        @Multipart(value = "simplePart1") String simplePart1,
+        @Multipart(value = "simplePart2") String simplePart2) throws Exception {
+        return new Book(b1.getName() + " - " + simplePart1 + simplePart2, b1.getId());   
+    }
+    
+    @POST
     @Path("/books/jaxbonly")
     @Consumes("multipart/related")
     @Produces("text/xml")