cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject [cxf] branch 3.1.x-fixes updated: [CXF-7629] Checking MBR and MBW as well
Date Fri, 02 Feb 2018 10:58:49 GMT
This is an automated email from the ASF dual-hosted git repository.

sergeyb pushed a commit to branch 3.1.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/3.1.x-fixes by this push:
     new c24a6fa  [CXF-7629] Checking MBR and MBW as well
c24a6fa is described below

commit c24a6fa49075924fe136fcc6f5f23b182e438b3b
Author: Sergey Beryozkin <sberyozkin@gmail.com>
AuthorDate: Fri Feb 2 10:41:08 2018 +0000

    [CXF-7629] Checking MBR and MBW as well
---
 .../apache/cxf/jaxrs/provider/ProviderFactory.java |  8 ++---
 .../cxf/jaxrs/provider/ProviderFactoryTest.java    | 40 ++++++++++++++++++++++
 2 files changed, 44 insertions(+), 4 deletions(-)

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 e1cc66c..a2735b7 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
@@ -570,12 +570,12 @@ public abstract class ProviderFactory {
             new LinkedList<ProviderInfo<WriterInterceptor>>();
         for (ProviderInfo<? extends Object> provider : theProviders) {
             Class<?> providerCls = ClassHelper.getRealClass(bus, provider.getProvider());
-            
-            if (MessageBodyReader.class.isAssignableFrom(providerCls)) {
+
+            if (filterContractSupported(provider, providerCls, MessageBodyReader.class))
{
                 addProviderToList(messageReaders, provider);
             }
-            
-            if (MessageBodyWriter.class.isAssignableFrom(providerCls)) {
+
+            if (filterContractSupported(provider, providerCls, MessageBodyWriter.class))
{
                 addProviderToList(messageWriters, provider);
             }
             
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
index 7758210..cbaac45 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
@@ -126,6 +126,46 @@ public class ProviderFactoryTest extends Assert {
     }
     
     @Test
+    public void testRegisterMbrMbwProviderAsMbrOnly() {
+        ServerProviderFactory pf = ServerProviderFactory.getInstance();
+        final JAXBElementProvider<Book> customProvider = new JAXBElementProvider<Book>();
+        pf.registerUserProvider(new Feature() {
+            public boolean configure(FeatureContext context) {
+                context.register(customProvider, MessageBodyReader.class);
+                return true;
+            }
+        });
+        MessageBodyReader<Book> reader = pf.createMessageBodyReader(Book.class, null,
null,
+                                                                    MediaType.TEXT_XML_TYPE,
new MessageImpl());
+        assertSame(reader, customProvider);
+
+        MessageBodyWriter<Book> writer = pf.createMessageBodyWriter(Book.class, null,
null,
+                                                                    MediaType.TEXT_XML_TYPE,
new MessageImpl());
+        assertTrue(writer instanceof JAXBElementProvider);
+        assertNotSame(writer, customProvider);
+    }
+    
+    @Test
+    public void testRegisterMbrMbwProviderAsMbwOnly() {
+        ServerProviderFactory pf = ServerProviderFactory.getInstance();
+        final JAXBElementProvider<Book> customProvider = new JAXBElementProvider<Book>();
+        pf.registerUserProvider(new Feature() {
+            public boolean configure(FeatureContext context) {
+                context.register(customProvider, MessageBodyWriter.class);
+                return true;
+            }
+        });
+        MessageBodyWriter<Book> writer = pf.createMessageBodyWriter(Book.class, null,
null,
+                                                                    MediaType.TEXT_XML_TYPE,
new MessageImpl());
+        assertSame(writer, customProvider);
+
+        MessageBodyReader<Book> reader = pf.createMessageBodyReader(Book.class, null,
null,
+                                                                    MediaType.TEXT_XML_TYPE,
new MessageImpl());
+        assertTrue(reader instanceof JAXBElementProvider);
+        assertNotSame(reader, customProvider);
+    }
+    
+    @Test
     public void testOrderOfProvidersWithSameProperties() {
         ProviderFactory pf = ServerProviderFactory.getInstance();
         WildcardReader reader1 = new WildcardReader();

-- 
To stop receiving notification emails like this one, please contact
sergeyb@apache.org.

Mime
View raw message