cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1240150 - in /cxf/branches/2.3.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ rt/frontend/jax...
Date Fri, 03 Feb 2012 13:21:09 GMT
Author: sergeyb
Date: Fri Feb  3 13:21:08 2012
New Revision: 1240150

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

................
  r1240148 | sergeyb | 2012-02-03 13:05:00 +0000 (Fri, 03 Feb 2012) | 16 lines
  
  Merged revisions 1240147 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/branches/2.5.x-fixes
  
  ................
    r1240147 | sergeyb | 2012-02-03 12:59:28 +0000 (Fri, 03 Feb 2012) | 9 lines
    
    Merged revisions 1240136 via svnmerge from 
    https://svn.apache.org/repos/asf/cxf/trunk
    
    ........
      r1240136 | sergeyb | 2012-02-03 12:33:08 +0000 (Fri, 03 Feb 2012) | 1 line
      
      [CXF-4086] Proper support for selecting ContextResolvers
    ........
  ................
................

Added:
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXBContextProvider2.java
      - copied unchanged from r1240148, cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXBContextProvider2.java
Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXBContextProvider.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
    cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Feb  3 13:21:08 2012
@@ -1,3 +1,3 @@
-/cxf/branches/2.4.x-fixes:1235732,1236170,1236646,1239371
-/cxf/branches/2.5.x-fixes:1235731,1236169,1236643,1239368
-/cxf/trunk:1235730,1236166,1236624,1239365
+/cxf/branches/2.4.x-fixes:1235732,1236170,1236646,1239371,1240148
+/cxf/branches/2.5.x-fixes:1235731,1236169,1236643,1239368,1240147
+/cxf/trunk:1235730,1236166,1236624,1239365,1240136

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

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java?rev=1240150&r1=1240149&r2=1240150&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java
Fri Feb  3 13:21:08 2012
@@ -56,6 +56,7 @@ import org.apache.cxf.jaxrs.utils.JAXRSU
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.message.MessageUtils;
 
 public class MessageContextImpl implements MessageContext {
 
@@ -78,7 +79,7 @@ public class MessageContextImpl implemen
             return m.getExchange().getOutMessage().get(Message.ATTACHMENTS);
         }
         Object value = m.get(key);
-        if (value == null && isRequestor()) {
+        if (value == null && MessageUtils.isRequestor(m)) {
             Message inMessage = m.getExchange().getInMessage();
             if (inMessage != null) {
                 value = inMessage.get(key);
@@ -87,12 +88,8 @@ public class MessageContextImpl implemen
         return value;
     }
     
-    private boolean isRequestor() {
-        return Boolean.TRUE.equals(m.containsKey(Message.REQUESTOR_ROLE));
-    }
-    
     public <T> T getContent(Class<T> format) {
-        if (isRequestor() && m.getExchange().getInMessage() != null) {
+        if (MessageUtils.isRequestor(m) && m.getExchange().getInMessage() != null)
{
             Message inMessage = m.getExchange().getInMessage();
             return inMessage.getContent(format);
         } 
@@ -164,7 +161,7 @@ public class MessageContextImpl implemen
             convertToAttachments(value);
         }
         m.put(key.toString(), value);
-        if (!isRequestor()) {
+        if (!MessageUtils.isRequestor(m)) {
             m.getExchange().put(key.toString(), value);
         }
             

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java?rev=1240150&r1=1240149&r2=1240150&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
Fri Feb  3 13:21:08 2012
@@ -33,7 +33,9 @@ import java.util.List;
 import java.util.Set;
 import java.util.logging.Logger;
 
+import javax.ws.rs.Produces;
 import javax.ws.rs.core.Application;
+import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.ext.ContextResolver;
 import javax.ws.rs.ext.ExceptionMapper;
@@ -49,6 +51,7 @@ import org.apache.cxf.jaxrs.client.Respo
 import org.apache.cxf.jaxrs.ext.ParameterHandler;
 import org.apache.cxf.jaxrs.ext.RequestHandler;
 import org.apache.cxf.jaxrs.ext.ResponseHandler;
+import org.apache.cxf.jaxrs.impl.HttpHeadersImpl;
 import org.apache.cxf.jaxrs.impl.RequestPreprocessor;
 import org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
@@ -57,6 +60,7 @@ import org.apache.cxf.jaxrs.model.wadl.W
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageUtils;
 
 public final class ProviderFactory {
     private static final Logger LOG = LogUtils.getL7dLogger(ProviderFactory.class);
@@ -129,9 +133,29 @@ public final class ProviderFactory {
     
     public <T> ContextResolver<T> createContextResolver(Type contextType, 
                                                         Message m) {
-        Object mt = m.get(Message.CONTENT_TYPE);
+        boolean isRequestor = MessageUtils.isRequestor(m);
+        Message requestMessage = isRequestor ? m.getExchange().getOutMessage() 
+                                             : m.getExchange().getInMessage();
+        HttpHeaders requestHeaders = new HttpHeadersImpl(requestMessage);
+        MediaType mt = null;
+        
+        Message responseMessage = isRequestor ? m.getExchange().getInMessage() 
+                                              : m.getExchange().getOutMessage();
+        if (responseMessage != null) {
+            if (!responseMessage.containsKey(Message.CONTENT_TYPE)) {
+                List<MediaType> accepts = requestHeaders.getAcceptableMediaTypes();
+                if (accepts.size() > 0) {
+                    mt = accepts.get(0);
+                }
+            } else {
+                mt = MediaType.valueOf(responseMessage.get(Message.CONTENT_TYPE).toString());
+            }
+        } else {
+            mt = requestHeaders.getMediaType();
+        }
+        
         return createContextResolver(contextType, m,
-               mt == null ? MediaType.valueOf("*/*") : MediaType.valueOf(mt.toString()));
+               mt == null ? MediaType.WILDCARD_TYPE : mt);
         
     }
     
@@ -139,22 +163,41 @@ public final class ProviderFactory {
     public <T> ContextResolver<T> createContextResolver(Type contextType, 
                                                         Message m,
                                                         MediaType type) {
+        Class<?> contextCls = InjectionUtils.getActualType(contextType);
+        if (contextCls == null) {
+            return null;
+        }
+        List<ContextResolver<T>> candidates = new LinkedList<ContextResolver<T>>();
         for (ProviderInfo<ContextResolver> cr : contextResolvers) {
             Type[] types = cr.getProvider().getClass().getGenericInterfaces();
             for (Type t : types) {
                 if (t instanceof ParameterizedType) {
                     ParameterizedType pt = (ParameterizedType)t;
                     Type[] args = pt.getActualTypeArguments();
-                    for (int i = 0; i < args.length; i++) {
-                        if (contextType == args[i]) {
-                            injectContextValues(cr, m);
-                            return cr.getProvider();
+                    if (args.length > 0) {
+                        Class<?> argCls = InjectionUtils.getActualType(args[0]);
+                        
+                        if (argCls != null && argCls.isAssignableFrom(contextCls))
{
+                            List<MediaType> mTypes = JAXRSUtils.getProduceTypes(
+                                 cr.getProvider().getClass().getAnnotation(Produces.class));
+                            if (JAXRSUtils.intersectMimeTypes(mTypes, type).size() > 0)
{
+                                injectContextValues(cr, m);
+                                candidates.add((ContextResolver<T>)cr.getProvider());
+                            }
                         }
                     }
                 }
             }
         }
-        return null;
+        if (candidates.size() == 0) {
+            return null;
+        } else if (candidates.size() == 1) {
+            return candidates.get(0);
+        } else {
+            Collections.sort(candidates, new ClassComparator());
+            return new ContextResolverProxy(candidates);
+        }
+        
     }
     
     
@@ -385,6 +428,7 @@ public final class ProviderFactory {
         
         sortReaders();
         sortWriters();
+        sortContextResolvers();
         
         injectContextProxies(messageReaders, messageWriters, contextResolvers, requestHandlers,
responseHandlers,
                        exceptionMappers);
@@ -422,6 +466,10 @@ public final class ProviderFactory {
         Collections.sort(messageWriters, new MessageBodyWriterComparator());
     }
     
+    private void sortContextResolvers() {
+        Collections.sort(contextResolvers, new ContextResolverComparator());
+    }
+    
         
     
     /**
@@ -594,6 +642,25 @@ public final class ProviderFactory {
         }
     }
     
+    private static class ContextResolverComparator 
+        implements Comparator<ProviderInfo<ContextResolver>> {
+        
+        public int compare(ProviderInfo<ContextResolver> p1, 
+                           ProviderInfo<ContextResolver> p2) {
+            ContextResolver<?> e1 = p1.getProvider();
+            ContextResolver<?> e2 = p2.getProvider();
+            
+            List<MediaType> types1 =
+                JAXRSUtils.sortMediaTypes(JAXRSUtils.getProduceTypes(
+                                               e1.getClass().getAnnotation(Produces.class)));
+            List<MediaType> types2 =
+                JAXRSUtils.sortMediaTypes(JAXRSUtils.getProduceTypes(
+                                               e2.getClass().getAnnotation(Produces.class)));
+    
+            return JAXRSUtils.compareSortedMediaTypes(types1, types2);
+        }
+    }
+    
     public void setApplicationProvider(ProviderInfo<Application> app) {
         application = app;
     }
@@ -752,4 +819,24 @@ public final class ProviderFactory {
         }
         return getGenericInterfaces(cls.getSuperclass());
     }
+    
+    static class ContextResolverProxy<T> implements ContextResolver<T> {
+        private List<ContextResolver<T>> candidates; 
+        public ContextResolverProxy(List<ContextResolver<T>> candidates) {
+            this.candidates = candidates;
+        }
+        public T getContext(Class<?> cls) {
+            for (ContextResolver<T> resolver : candidates) {
+                T context = resolver.getContext(cls);
+                if (context != null) {
+                    return context;
+                }
+            }
+            return null;
+        } 
+        
+        public List<ContextResolver<T>> getResolvers() {
+            return candidates;
+        }
+    }
 }

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=1240150&r1=1240149&r2=1240150&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
Fri Feb  3 13:21:08 2012
@@ -160,20 +160,19 @@ public final class JAXRSUtils {
         String[] values = getUserMediaTypes(provider, "getConsumeMediaTypes");
         
         if (values == null) {
-            Consumes c = provider.getClass().getAnnotation(Consumes.class);
-            values = c == null ? new String[]{"*/*"} : c.value();
+            return getConsumeTypes(provider.getClass().getAnnotation(Consumes.class));
+        } else {
+            return JAXRSUtils.getMediaTypes(values);
         }
-        return JAXRSUtils.getMediaTypes(values);
     }
     
     public static List<MediaType> getProviderProduceTypes(MessageBodyWriter provider)
{
         String[] values = getUserMediaTypes(provider, "getProduceMediaTypes");
-        
         if (values == null) {
-            Produces c = provider.getClass().getAnnotation(Produces.class);
-            values = c == null ? new String[]{"*/*"} : c.value();
+            return getProduceTypes(provider.getClass().getAnnotation(Produces.class));
+        } else {
+            return JAXRSUtils.getMediaTypes(values);
         }
-        return JAXRSUtils.getMediaTypes(values);
     }
     
     public static List<MediaType> getMediaTypes(String[] values) {
@@ -1120,14 +1119,24 @@ public final class JAXRSUtils {
                 if (!isCompatible && requiredType.getType().equalsIgnoreCase(userType.getType()))
{
                     // check if we have composite subtypes
                     String subType1 = requiredType.getSubtype();
-                    String subTypeAfterPlus1 = splitMediaSubType(subType1); 
                     String subType2 = userType.getSubtype();
-                    String subTypeAfterPlus2 = splitMediaSubType(subType2);
                     
-                    if (subTypeAfterPlus1 != null && subTypeAfterPlus2 != null
-                        && subTypeAfterPlus1.equalsIgnoreCase(subTypeAfterPlus2)
-                        && (subType1.charAt(0) == '*' || subType2.charAt(0) == '*'))
{
-                        isCompatible = true;
+                    String subTypeAfterPlus1 = splitMediaSubType(subType1, true); 
+                    String subTypeAfterPlus2 = splitMediaSubType(subType2, true);
+                    
+                    if (subTypeAfterPlus1 != null && subTypeAfterPlus2 != null) {
+                    
+                        isCompatible = subTypeAfterPlus1.equalsIgnoreCase(subTypeAfterPlus2)
+                            && (subType1.charAt(0) == '*' || subType2.charAt(0) ==
'*');
+                        
+                        if (!isCompatible) {
+                            String subTypeBeforePlus1 = splitMediaSubType(subType1, false);
+                            String subTypeBeforePlus2 = splitMediaSubType(subType2, false);
+                            
+                            isCompatible = subTypeBeforePlus1.equalsIgnoreCase(subTypeBeforePlus2)
+                                && (subType1.charAt(subType1.length() - 1) == '*'

+                                    || subType2.charAt(subType2.length() - 1) == '*');
+                        }
                     }
                 }
                 if (isCompatible) {
@@ -1165,9 +1174,9 @@ public final class JAXRSUtils {
         
     }
     
-    static String splitMediaSubType(String type) {
+    private static String splitMediaSubType(String type, boolean after) {
         int index = type.indexOf('+');
-        return index == -1 ? null : type.substring(index + 1);
+        return index == -1 ? null : after ? type.substring(index + 1) : type.substring(0,
index);
     }
     
     public static List<MediaType> intersectMimeTypes(List<MediaType> mimeTypesA,


Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXBContextProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXBContextProvider.java?rev=1240150&r1=1240149&r2=1240150&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXBContextProvider.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXBContextProvider.java
Fri Feb  3 13:21:08 2012
@@ -19,9 +19,11 @@
  
 package org.apache.cxf.jaxrs;
 
+import javax.ws.rs.Produces;
 import javax.ws.rs.ext.ContextResolver;
 import javax.xml.bind.JAXBContext;
 
+@Produces("text/xml+a")
 public class JAXBContextProvider implements ContextResolver<JAXBContext> {
 
     public JAXBContext getContext(Class type) {

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java?rev=1240150&r1=1240149&r2=1240150&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
Fri Feb  3 13:21:08 2012
@@ -29,6 +29,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+import java.util.Map;
 
 import javax.ws.rs.Consumes;
 import javax.ws.rs.Produces;
@@ -51,8 +52,10 @@ import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.jaxrs.Customer;
 import org.apache.cxf.jaxrs.CustomerParameterHandler;
 import org.apache.cxf.jaxrs.JAXBContextProvider;
+import org.apache.cxf.jaxrs.JAXBContextProvider2;
 import org.apache.cxf.jaxrs.ext.ParameterHandler;
 import org.apache.cxf.jaxrs.ext.RequestHandler;
+import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.model.ProviderInfo;
@@ -376,13 +379,80 @@ public class ProviderFactoryTest extends
     public void testRegisterCustomResolver() throws Exception {
         ProviderFactory pf = ProviderFactory.getInstance();
         pf.registerUserProvider(new JAXBContextProvider());
-        ContextResolver<JAXBContext> cr = pf.createContextResolver(JAXBContext.class,
new MessageImpl());
+        Message message = prepareMessage("*/*", null);
+        ContextResolver<JAXBContext> cr = pf.createContextResolver(JAXBContext.class,
message);
+        assertFalse(cr instanceof ProviderFactory.ContextResolverProxy);
         assertTrue("JAXBContext ContextProvider can not be found", 
                    cr instanceof JAXBContextProvider);
         
     }
     
     @Test
+    public void testRegisterCustomResolver2() throws Exception {
+        ProviderFactory pf = ProviderFactory.getInstance();
+        pf.registerUserProvider(new JAXBContextProvider());
+        pf.registerUserProvider(new JAXBContextProvider2());
+        Message message = prepareMessage("text/xml+b", null);
+        ContextResolver<JAXBContext> cr = pf.createContextResolver(JAXBContext.class,
message);
+        assertFalse(cr instanceof ProviderFactory.ContextResolverProxy);
+        assertTrue("JAXBContext ContextProvider can not be found", 
+                   cr instanceof JAXBContextProvider2);
+        
+    }
+    
+    @Test
+    public void testNoCustomResolver() throws Exception {
+        ProviderFactory pf = ProviderFactory.getInstance();
+        pf.registerUserProvider(new JAXBContextProvider());
+        pf.registerUserProvider(new JAXBContextProvider2());
+        Message message = prepareMessage("text/xml+c", null);
+        ContextResolver<JAXBContext> cr = pf.createContextResolver(JAXBContext.class,
message);
+        assertNull(cr);
+    }
+    
+    @Test
+    public void testCustomResolverOut() throws Exception {
+        ProviderFactory pf = ProviderFactory.getInstance();
+        pf.registerUserProvider(new JAXBContextProvider());
+        pf.registerUserProvider(new JAXBContextProvider2());
+        Message message = prepareMessage("text/xml+c", "text/xml+a");
+        ContextResolver<JAXBContext> cr = pf.createContextResolver(JAXBContext.class,
message);
+        assertFalse(cr instanceof ProviderFactory.ContextResolverProxy);
+        assertTrue("JAXBContext ContextProvider can not be found", 
+                   cr instanceof JAXBContextProvider);
+    }
+    
+    @Test
+    public void testCustomResolverProxy() throws Exception {
+        ProviderFactory pf = ProviderFactory.getInstance();
+        pf.registerUserProvider(new JAXBContextProvider());
+        pf.registerUserProvider(new JAXBContextProvider2());
+        Message message = prepareMessage("text/xml+*", null);
+        ContextResolver<JAXBContext> cr = pf.createContextResolver(JAXBContext.class,
message);
+        assertTrue(cr instanceof ProviderFactory.ContextResolverProxy);
+        assertTrue(((ProviderFactory.ContextResolverProxy)cr).getResolvers().get(0) 
+                   instanceof JAXBContextProvider);
+        assertTrue(((ProviderFactory.ContextResolverProxy)cr).getResolvers().get(1) 
+                   instanceof JAXBContextProvider2);
+    }
+    
+    private Message prepareMessage(String contentType, String acceptType) {
+        Message message = new MessageImpl();
+        Map<String, List<String>> headers = new MetadataMap<String, String>();
+        message.put(Message.PROTOCOL_HEADERS, headers);
+        Exchange exchange = new ExchangeImpl();
+        exchange.setInMessage(message);
+        if (acceptType != null) {
+            headers.put("Accept", Collections.singletonList(acceptType));
+            exchange.setOutMessage(new MessageImpl());
+        } else {
+            headers.put("Content-Type", Collections.singletonList(contentType));
+        }
+        message.setExchange(exchange);
+        return message;
+    }
+    
+    @Test
     public void testRegisterCustomEntityProvider() throws Exception {
         ProviderFactory pf = (ProviderFactory)ProviderFactory.getInstance();
         pf.registerUserProvider(new CustomWidgetProvider());

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java?rev=1240150&r1=1240149&r2=1240150&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
Fri Feb  3 13:21:08 2012
@@ -437,6 +437,15 @@ public class JAXRSUtilsTest extends Asse
     }
     
     @Test
+    public void testIntersectMimeTypesCompositeSubtype5() throws Exception {
+        List <MediaType> candidateList = 
+            JAXRSUtils.intersectMimeTypes("application/bar+xml", "application/bar+*");  
+
+        assertEquals(1, candidateList.size());
+        assertEquals("application/bar+xml", candidateList.get(0).toString());
+    }
+    
+    @Test
     public void testIntersectMimeTypes() throws Exception {
         //test basic
         List<MediaType> methodMimeTypes = new ArrayList<MediaType>(

Modified: cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java?rev=1240150&r1=1240149&r2=1240150&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
(original)
+++ cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
Fri Feb  3 13:21:08 2012
@@ -85,7 +85,7 @@ public class JAXRSSoapBookTest extends A
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue("server did not launch correctly", 
-                   launchServer(BookServerRestSoap.class));
+                   launchServer(BookServerRestSoap.class, true));
     }
     
     @Test



Mime
View raw message