cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-5910] Using a more specific name binding for DynamicFeature
Date Wed, 30 Jul 2014 12:28:35 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes 778ab445b -> ee4ff74b0


[CXF-5910] Using a more specific name binding for DynamicFeature


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/ee4ff74b
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/ee4ff74b
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/ee4ff74b

Branch: refs/heads/2.7.x-fixes
Commit: ee4ff74b04451a89709b01dfaa187bb4192e8db5
Parents: 778ab44
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Wed Jul 30 14:53:39 2014 +0300
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Wed Jul 30 15:28:03 2014 +0300

----------------------------------------------------------------------
 .../cxf/jaxrs/provider/ProviderFactory.java     |  2 +-
 .../apache/cxf/systest/jaxrs/BookServer20.java  | 20 ++++++++++++++++++++
 .../org/apache/cxf/systest/jaxrs/BookStore.java |  7 ++++++-
 .../jaxrs/JAXRS20ClientServerBookTest.java      | 18 ++++++++++++++++++
 4 files changed, 45 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/ee4ff74b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
index 7ddad14..664d0d3 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
@@ -1417,7 +1417,7 @@ public final class ProviderFactory {
             nameBinding = DEFAULT_FILTER_NAME_BINDING 
                 + ori.getClassResourceInfo().getServiceClass().getName()
                 + "."
-                + ori.getMethodToInvoke().getName()
+                + ori.getMethodToInvoke().toString()
                 + ":dynamic";
         }
         

http://git-wip-us.apache.org/repos/asf/cxf/blob/ee4ff74b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java
index 1c6102a..33f4e9d 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java
@@ -27,6 +27,7 @@ import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
+import java.lang.reflect.Method;
 import java.lang.reflect.Type;
 import java.net.URI;
 import java.util.ArrayList;
@@ -343,6 +344,18 @@ public class BookServer20 extends AbstractBusTestServerBase {
         }
         
     }
+    public static class PostMatchDynamicEchoBookFilter implements ContainerResponseFilter
{
+        private int supplement;
+        public PostMatchDynamicEchoBookFilter(int supplement) {
+            this.supplement = supplement;
+        }
+        @Override
+        public void filter(ContainerRequestContext requestContext,
+                           ContainerResponseContext responseContext) throws IOException {
+            Book book = (Book)responseContext.getEntity();
+            responseContext.setEntity(new Book(book.getName(), book.getId() + supplement),
null, null);
+        }
+    }
     
     @BindingPriority(2)
     public static class PostMatchDynamicContainerResponseFilter implements ContainerResponseFilter
{
@@ -425,6 +438,13 @@ public class BookServer20 extends AbstractBusTestServerBase {
             configurable.register(new PreMatchDynamicContainerRequestFilter());
             configurable.register(new PostMatchDynamicContainerResponseFilter());
             configurable.register(RESPONSE_FILTER);
+            Method m = resourceInfo.getResourceMethod();
+            if ("echoBookElement".equals(m.getName())) {
+                Class<?> paramType = m.getParameterTypes()[0];
+                if (paramType == Book.class) {
+                    configurable.register(new PostMatchDynamicEchoBookFilter(2));
+                }
+            }
         }
         
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/ee4ff74b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
index d8fc681..bafb0d2 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
@@ -998,10 +998,15 @@ public class BookStore {
     public JAXBElement<Book> echoBookElement(JAXBElement<Book> element) throws
Exception {
         return element;
     }
+    @POST
+    @Path("/books/echo")
+    public Book echoBookElement(Book element) throws Exception {
+        return element;
+    }
     
     @SuppressWarnings("unchecked")
     @POST
-    @Path("/books/element/echo")
+    @Path("/books/element/echo/wildcard")
     public JAXBElement<? super Book> echoBookElementWildcard(JAXBElement<? extends
Book> element) 
         throws Exception {
         return (JAXBElement<? super Book>)element;

http://git-wip-us.apache.org/repos/asf/cxf/blob/ee4ff74b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
index 55ab174..26a8fe6 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
@@ -44,8 +44,11 @@ import javax.ws.rs.ext.ReaderInterceptor;
 import javax.ws.rs.ext.ReaderInterceptorContext;
 import javax.ws.rs.ext.WriterInterceptor;
 import javax.ws.rs.ext.WriterInterceptorContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
 import javax.xml.ws.Holder;
 
+import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 
@@ -62,6 +65,21 @@ public class JAXRS20ClientServerBookTest extends AbstractBusClientServerTestBase
     }
     
     @Test
+    public void testEchoBookElement() throws Exception {
+        BookStore store = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class);
+        JAXBElement<Book> element = store.echoBookElement(new JAXBElement<Book>(new
QName("", "Book"),
+                                     Book.class,
+                                     new Book("CXF", 123L)));
+        Book book = element.getValue();
+        assertEquals(123L, book.getId());
+        assertEquals("CXF", book.getName());
+        
+        Book book2 = store.echoBookElement(new Book("CXF3", 128L));
+        assertEquals(130L, book2.getId());
+        assertEquals("CXF3", book2.getName());
+    }
+    
+    @Test
     public void testGetGenericBook() throws Exception {
         String address = "http://localhost:" + PORT + "/bookstore/genericbooks/123";
         doTestGetGenericBook(address, 124L, false);


Mime
View raw message