cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r750948 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ systests/src/test/java/org/apache/cxf/systest/jaxrs/
Date Fri, 06 Mar 2009 15:54:08 GMT
Author: sergeyb
Date: Fri Mar  6 15:54:07 2009
New Revision: 750948

URL: http://svn.apache.org/viewvc?rev=750948&view=rev
Log:
JAXRS: client recursive subresource test

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreJaxrsJaxws.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSoapRestImpl.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java?rev=750948&r1=750947&r2=750948&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
Fri Mar  6 15:54:07 2009
@@ -72,10 +72,13 @@
     
     private ClassResourceInfo cri;
     private boolean inheritHeaders;
+    private boolean isRoot;
     
-    public ClientProxyImpl(URI baseURI, URI currentURI, ClassResourceInfo cri, boolean inheritHeaders)
{
+    public ClientProxyImpl(URI baseURI, URI currentURI, ClassResourceInfo cri, boolean isRoot,

+                           boolean inheritHeaders) {
         super(baseURI, currentURI);
         this.cri = cri;
+        this.isRoot = isRoot;
         this.inheritHeaders = inheritHeaders;
     }
     
@@ -106,7 +109,7 @@
         int bodyIndex = getBodyIndex(types, ori);
         
         UriBuilder builder = getCurrentBuilder().clone(); 
-        if (cri.isRoot()) {
+        if (isRoot) {
             builder.path(ori.getClassResourceInfo().getServiceClass());
         }
         builder.path(m);
@@ -125,7 +128,7 @@
             if (subCri == null) {
                 reportInvalidResourceMethod(m, "INVALID_SUBRESOURCE");
             }
-            ClientProxyImpl proxyImpl = new ClientProxyImpl(getBaseURI(), uri, subCri, inheritHeaders);
+            ClientProxyImpl proxyImpl = new ClientProxyImpl(getBaseURI(), uri, subCri, false,
inheritHeaders);
             proxyImpl.setBus(bus);
             proxyImpl.setConduitSelector(conduitSelector);
             proxyImpl.setInInterceptors(inInterceptors);

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java?rev=750948&r1=750947&r2=750948&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java
Fri Mar  6 15:54:07 2009
@@ -115,7 +115,7 @@
             
             return cls.cast(ProxyHelper.getProxy(cls.getClassLoader(),
                             new Class[]{cls, Client.class}, 
-                            new ClientProxyImpl(baseURI, baseURI, cri, inheritHeaders)));
+                            new ClientProxyImpl(baseURI, baseURI, cri, isRoot, inheritHeaders)));
         }
     }
     
@@ -180,7 +180,6 @@
     
     static <T> T create(Class<T> cls, InvocationHandler handler) {
         
-        return cls.cast(ProxyHelper.getProxy(cls.getClassLoader(),
-                        new Class[]{cls, Client.class}, handler));
+        return cls.cast(ProxyHelper.getProxy(cls.getClassLoader(), new Class[]{cls, Client.class},
handler));
     }
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java?rev=750948&r1=750947&r2=750948&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
Fri Mar  6 15:54:07 2009
@@ -21,6 +21,7 @@
 import java.net.URI;
 import java.util.Map;
 
+import javax.ws.rs.Path;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MultivaluedMap;
 
@@ -34,6 +35,7 @@
 import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.provider.ProviderFactory;
+import org.apache.cxf.jaxrs.utils.AnnotationUtils;
 import org.apache.cxf.service.Service;
 
 public class JAXRSClientFactoryBean extends AbstractJAXRSFactoryBean {
@@ -102,8 +104,8 @@
             Endpoint ep = createEndpoint();
             URI baseURI = URI.create(getAddress());
             ClassResourceInfo cri = serviceFactory.getClassResourceInfo().get(0);
-            
-            ClientProxyImpl proxyImpl = new ClientProxyImpl(baseURI, baseURI, cri, inheritHeaders);
+            boolean isRoot = AnnotationUtils.getClassAnnotation(cri.getServiceClass(), Path.class)
!= null;
+            ClientProxyImpl proxyImpl = new ClientProxyImpl(baseURI, baseURI, cri, isRoot,
inheritHeaders);
             initClient(proxyImpl, ep);    
             
             return (Client)ProxyHelper.getProxy(cri.getServiceClass().getClassLoader(),

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java?rev=750948&r1=750947&r2=750948&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
Fri Mar  6 15:54:07 2009
@@ -72,8 +72,10 @@
                     if (enableStatic) {
                         ClassResourceInfo subCri = cri.findResource(subClass, subClass);
                         if (subCri == null) {
-                            subCri = createClassResourceInfo(subClass, subClass, false, enableStatic);
+                            subCri = subClass == cri.getServiceClass() ? cri
+                                     : createClassResourceInfo(subClass, subClass, false,
enableStatic);
                         }
+                        
                         if (subCri != null) {
                             cri.addSubClassResourceInfo(subCri);
                         }

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreJaxrsJaxws.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreJaxrsJaxws.java?rev=750948&r1=750947&r2=750948&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreJaxrsJaxws.java
(original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreJaxrsJaxws.java
Fri Mar  6 15:54:07 2009
@@ -49,4 +49,8 @@
     @Path("/books/{id}")
     @WebMethod(exclude = true)
     BookSubresource getBookSubresource(@PathParam("id") String id);
+    
+    @Path("/thestore/{id}")
+    @WebMethod(exclude = true)
+    BookStoreJaxrsJaxws getBookStore(@PathParam("id") String id);
 }

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSoapRestImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSoapRestImpl.java?rev=750948&r1=750947&r2=750948&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSoapRestImpl.java
(original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSoapRestImpl.java
Fri Mar  6 15:54:07 2009
@@ -104,5 +104,13 @@
     public BookSubresource getBookSubresource(String id) {
         return new BookSubresourceImpl(Long.valueOf(id));
     }
+
+    @WebMethod(exclude = true)
+    public BookStoreJaxrsJaxws getBookStore(String id) {
+        if (!"number1".equals(id)) {
+            throw new WebApplicationException(404);
+        }
+        return this;
+    }
     
 }

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java?rev=750948&r1=750947&r2=750948&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java Fri
Mar  6 15:54:07 2009
@@ -40,7 +40,7 @@
     Book getTheBook() throws BookNotFoundFault;
     
     @POST
-    @Path("/subresource2/{n1}")
+    @Path("/subresource2/{n1:.*}")
     @Consumes("text/plain")
     @Produces("application/xml")
     Book getTheBook2(@PathParam("n1") String name1,

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java?rev=750948&r1=750947&r2=750948&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java Fri
Mar  6 15:54:07 2009
@@ -165,6 +165,10 @@
         BookStoreJaxrsJaxws proxy = JAXRSClientFactory.create(baseAddress,
                                                                   BookStoreJaxrsJaxws.class);
         doTestSubresource(proxy);
+        BookStoreJaxrsJaxws proxy2 = proxy.getBookStore("number1");
+        doTestSubresource(proxy2);
+        BookStoreJaxrsJaxws proxy3 = proxy2.getBookStore("number1");
+        doTestSubresource(proxy3);
     }
     
     @Test
@@ -227,6 +231,9 @@
         b = bs.getTheBook2("CXF ", "in ", "Action ", null, "7", "8");
         assertEquals(378, b.getId());
         assertEquals("CXF in Action - 478", b.getName());
+        
+        
+        
     }
     
     @Test



Mime
View raw message