cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r721501 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/ rt/frontend/jaxrs/src/main/java/org/...
Date Fri, 28 Nov 2008 14:04:45 GMT
Author: sergeyb
Date: Fri Nov 28 06:04:44 2008
New Revision: 721501

URL: http://svn.apache.org/viewvc?rev=721501&view=rev
Log:
JAXRS : support for per-endpoint providers 

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MessageBodyWorkersImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
    cxf/trunk/systests/src/test/resources/jaxrs/WEB-INF/beans.xml

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java?rev=721501&r1=721500&r2=721501&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java Fri Nov
28 06:04:44 2008
@@ -108,9 +108,10 @@
         try {
             result = invoke(exchange, resourceObject, methodToInvoke, params);
         } catch (Fault ex) {
-            Response excResponse = JAXRSUtils.convertFaultToResponse(ex.getCause());
+            String baseAddress = (String)exchange.getInMessage().get(Message.BASE_PATH);
+            Response excResponse = JAXRSUtils.convertFaultToResponse(ex.getCause(), baseAddress);
             if (excResponse == null) {
-                ProviderFactory.getInstance().cleatThreadLocalProxies();
+                ProviderFactory.getInstance(baseAddress).cleatThreadLocalProxies();
                 ClassResourceInfo criRoot =
                     (ClassResourceInfo)exchange.get(JAXRSInInterceptor.ROOT_RESOURCE_CLASS);
                 if (criRoot != null) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java?rev=721501&r1=721500&r2=721501&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
Fri Nov 28 06:04:44 2008
@@ -97,12 +97,12 @@
                 ep.getService().setInvoker(invoker);
             }
             if (entityProviders != null) {
-                ProviderFactory.getInstance().setUserProviders(entityProviders); 
+                ProviderFactory.getInstance(getAddress()).setUserProviders(entityProviders);

             }
-            ProviderFactory.getInstance().setRequestPreporcessor(
+            ProviderFactory.getInstance(getAddress()).setRequestPreporcessor(
                 new RequestPreprocessor(languageMappings, extensionMappings));
             if (schemaLocations != null) {
-                ProviderFactory.getInstance().setSchemaLocations(schemaLocations);
+                ProviderFactory.getInstance(getAddress()).setSchemaLocations(schemaLocations);
             }
             
             if (start) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MessageBodyWorkersImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MessageBodyWorkersImpl.java?rev=721501&r1=721500&r2=721501&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MessageBodyWorkersImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MessageBodyWorkersImpl.java
Fri Nov 28 06:04:44 2008
@@ -41,22 +41,23 @@
     
     public <T> MessageBodyReader<T> getMessageBodyReader(
          Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType)
{
-        return ProviderFactory.getInstance().createMessageBodyReader(
+        return ProviderFactory.getInstance((String)m.get(Message.BASE_PATH)).createMessageBodyReader(
             type, genericType, annotations, mediaType, m);
     }
 
     public <T> MessageBodyWriter<T> getMessageBodyWriter(
         Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType)
{
-        return ProviderFactory.getInstance().createMessageBodyWriter(
+        return ProviderFactory.getInstance((String)m.get(Message.BASE_PATH)).createMessageBodyWriter(
                    type, genericType, annotations, mediaType, m);
     }
 
     public <T> ContextResolver<T> getContextResolver(Class<T> contextType,
MediaType mediaType) {
-        return ProviderFactory.getInstance().createContextResolver(contextType, m, mediaType);
+        return ProviderFactory.getInstance((String)m.get(Message.BASE_PATH))
+            .createContextResolver(contextType, m, mediaType);
     }
 
     public <T extends Throwable> ExceptionMapper<T> getExceptionMapper(Class<T>
type) {
-        return ProviderFactory.getInstance().createExceptionMapper(type, m);
+        return ProviderFactory.getInstance((String)m.get(Message.BASE_PATH)).createExceptionMapper(type,
m);
     }
 
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java?rev=721501&r1=721500&r2=721501&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
Fri Nov 28 06:04:44 2008
@@ -61,12 +61,13 @@
 
     public void handleMessage(Message message) {
         
+        String baseAddress = (String)message.get(Message.BASE_PATH);
         try {
-            processRequest(message);
+            processRequest(message, baseAddress);
         } catch (RuntimeException ex) {
-            Response excResponse = JAXRSUtils.convertFaultToResponse(ex);
+            Response excResponse = JAXRSUtils.convertFaultToResponse(ex, baseAddress);
             if (excResponse == null) {
-                ProviderFactory.getInstance().cleatThreadLocalProxies();
+                ProviderFactory.getInstance(baseAddress).cleatThreadLocalProxies();
                 throw ex;
             }
             message.getExchange().put(Response.class, excResponse);
@@ -86,35 +87,28 @@
         return path;
     }
     
-    private void processRequest(Message message) {
+    private void processRequest(Message message, String baseAddress) {
         
         if (message.getExchange().get(OperationResourceInfo.class) != null) {
             // it's a suspended invocation;
             return;
         }
         
+        String path = (String)message.get(Message.REQUEST_URI);
+        
         RequestPreprocessor rp = 
-            ProviderFactory.getInstance().getRequestPreprocessor();
+            ProviderFactory.getInstance(baseAddress).getRequestPreprocessor();
         if (rp != null) {
             rp.preprocess(message, new UriInfoImpl(message, null));
         }
         
-        String path = (String)message.get(Message.REQUEST_URI);
-        String address = (String)message.get(Message.BASE_PATH);
-        
         String httpMethod = (String)message.get(Message.HTTP_REQUEST_METHOD);
         String requestContentType = (String)message.get(Message.CONTENT_TYPE);
         if (requestContentType == null) {
             requestContentType = "*/*";
         }
         
-        if (address.startsWith("http")) {
-            int idx = address.indexOf('/', 7);
-            if (idx != -1) {
-                address = address.substring(idx);
-            }
-        }
-        path = updatePath(path, address);
+        path = updatePath(path, baseAddress);
         
         //1. Matching target resource class
         Service service = message.getExchange().get(Service.class);
@@ -145,7 +139,7 @@
         OperationResourceInfo ori = null;     
         
         List<ProviderInfo<RequestHandler>> shs = 
-            ProviderFactory.getInstance().getRequestHandlers();
+            ProviderFactory.getInstance(baseAddress).getRequestHandlers();
         for (ProviderInfo<RequestHandler> sh : shs) {
             String newAcceptTypes = (String)message.get(Message.ACCEPT_CONTENT_TYPE);
             if (!acceptTypes.equals(newAcceptTypes) || ori == null) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java?rev=721501&r1=721500&r2=721501&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
Fri Nov 28 06:04:44 2008
@@ -57,10 +57,11 @@
 
     public void handleMessage(Message message) {
         
+        String baseAddress = (String)message.getExchange().getInMessage().get(Message.BASE_PATH);
         try {
-            processResponse(message);
+            processResponse(message, baseAddress);
         } finally {
-            ProviderFactory.getInstance().cleatThreadLocalProxies();
+            ProviderFactory.getInstance(baseAddress).cleatThreadLocalProxies();
             ClassResourceInfo cri =
                 (ClassResourceInfo)message.getExchange().get(JAXRSInInterceptor.ROOT_RESOURCE_CLASS);
             if (cri != null) {
@@ -72,7 +73,7 @@
     }
     
     @SuppressWarnings("unchecked")
-    private void processResponse(Message message) {
+    private void processResponse(Message message, String baseAddress) {
         
         MessageContentsList objs = MessageContentsList.getContentsList(message);
         if (objs == null || objs.size() == 0) {
@@ -93,7 +94,7 @@
                 .getName());
 
             List<ProviderInfo<ResponseHandler>> handlers = 
-                ProviderFactory.getInstance().getResponseHandlers();
+                ProviderFactory.getInstance(baseAddress).getResponseHandlers();
             for (ProviderInfo<ResponseHandler> rh : handlers) {
                 Response r = rh.getProvider().handleResponse(message, operation, response);
                 if (r != null) {
@@ -118,7 +119,7 @@
             MessageBodyWriter writer = null;
             MediaType responseType = null;
             for (MediaType type : availableContentTypes) { 
-                writer = ProviderFactory.getInstance()
+                writer = ProviderFactory.getInstance(baseAddress)
                     .createMessageBodyWriter(targetType, 
                           invoked != null ? invoked.getGenericReturnType() : null, 
                           invoked != null ? invoked.getAnnotations() : new Annotation[]{},


Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java?rev=721501&r1=721500&r2=721501&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
Fri Nov 28 06:04:44 2008
@@ -26,7 +26,9 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import javax.ws.rs.Consumes;
 import javax.ws.rs.Produces;
@@ -48,26 +50,31 @@
 
 public final class ProviderFactory {
     
-    private static final ProviderFactory PF = new ProviderFactory();
+    private static final Map<String, ProviderFactory> FACTORIES = 
+        new HashMap<String, ProviderFactory>();
+    
+    static {
+        FACTORIES.put("/", new ProviderFactory());
+    }
     
     private List<ProviderInfo<MessageBodyReader>> defaultMessageReaders = 
         new ArrayList<ProviderInfo<MessageBodyReader>>();
     private List<ProviderInfo<MessageBodyWriter>> defaultMessageWriters = 
         new ArrayList<ProviderInfo<MessageBodyWriter>>();
     private List<ProviderInfo<MessageBodyReader>> userMessageReaders = 
-        new ArrayList<ProviderInfo<MessageBodyReader>>();
+        new ArrayList<ProviderInfo<MessageBodyReader>>(1);
     private List<ProviderInfo<MessageBodyWriter>> userMessageWriters = 
-        new ArrayList<ProviderInfo<MessageBodyWriter>>();
+        new ArrayList<ProviderInfo<MessageBodyWriter>>(1);
     private List<ProviderInfo<ContextResolver>> userContextResolvers = 
-        new ArrayList<ProviderInfo<ContextResolver>>();
+        new ArrayList<ProviderInfo<ContextResolver>>(1);
     private List<ProviderInfo<ExceptionMapper>> defaultExceptionMappers = 
-        new ArrayList<ProviderInfo<ExceptionMapper>>();
+        new ArrayList<ProviderInfo<ExceptionMapper>>(1);
     private List<ProviderInfo<ExceptionMapper>> userExceptionMappers = 
-        new ArrayList<ProviderInfo<ExceptionMapper>>();
+        new ArrayList<ProviderInfo<ExceptionMapper>>(1);
     private List<ProviderInfo<RequestHandler>> requestHandlers = 
-        new ArrayList<ProviderInfo<RequestHandler>>();
+        new ArrayList<ProviderInfo<RequestHandler>>(1);
     private List<ProviderInfo<ResponseHandler>> responseHandlers = 
-        new ArrayList<ProviderInfo<ResponseHandler>>();
+        new ArrayList<ProviderInfo<ResponseHandler>>(1);
     private RequestPreprocessor requestPreprocessor;
     
     private ProviderFactory() {
@@ -91,7 +98,19 @@
     }
     
     public static ProviderFactory getInstance() {
-        return PF;
+        return getInstance("/");
+    }
+    
+    public static ProviderFactory getInstance(String baseAddress) {
+        ProviderFactory pf = null;
+        synchronized (ProviderFactory.class) { 
+            pf = FACTORIES.get(baseAddress);
+            if (pf == null) {
+                pf = new ProviderFactory();
+                FACTORIES.put(baseAddress, pf);
+            }
+        }
+        return pf;
     }
 
     public <T> ContextResolver<T> createContextResolver(Type contextType, 

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=721501&r1=721500&r2=721501&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java Fri
Nov 28 06:04:44 2008
@@ -567,7 +567,7 @@
     
     public static ContextResolver<?> createContextResolver(Type genericType, Message
m) {
         if (genericType instanceof ParameterizedType) {
-            return ProviderFactory.getInstance().createContextResolver(
+            return ProviderFactory.getInstance((String)m.get(Message.BASE_PATH)).createContextResolver(
                       ((ParameterizedType)genericType).getActualTypeArguments()[0], m);
         }
         return null;
@@ -694,7 +694,7 @@
         MessageBodyReader provider = null;
         
         for (MediaType type : types) { 
-            provider = ProviderFactory.getInstance()
+            provider = ProviderFactory.getInstance((String)m.get(Message.BASE_PATH))
                 .createMessageBodyReader(targetTypeClass,
                                          parameterType,
                                          parameterAnnotations,
@@ -834,10 +834,10 @@
     }
     
     @SuppressWarnings("unchecked")
-    public static Response convertFaultToResponse(Throwable ex) {
+    public static Response convertFaultToResponse(Throwable ex, String baseAddress) {
         
         ExceptionMapper mapper = 
-            ProviderFactory.getInstance().createExceptionMapper(ex.getClass(),
+            ProviderFactory.getInstance(baseAddress).createExceptionMapper(ex.getClass(),
                                                                 new MessageImpl());
         if (mapper != null) {
             Response excResponse = mapper.toResponse(ex);

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java?rev=721501&r1=721500&r2=721501&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
Fri Nov 28 06:04:44 2008
@@ -63,6 +63,13 @@
     }
     
     @Test
+    public void testMultipleFactories() {
+        assertSame(ProviderFactory.getInstance(), ProviderFactory.getInstance());
+        assertSame(ProviderFactory.getInstance("/bar"), ProviderFactory.getInstance("/bar"));
+        assertNotSame(ProviderFactory.getInstance("/bar"), ProviderFactory.getInstance("/"));
+    }
+    
+    @Test
     public void testExceptionMappers() throws Exception {
         ProviderFactory pf = ProviderFactory.getInstance();
         ExceptionMapper<?> mapper = 

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java?rev=721501&r1=721500&r2=721501&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
Fri Nov 28 06:04:44 2008
@@ -909,7 +909,7 @@
         ProviderFactory.getInstance().registerUserProvider(cr);
         
         Message m = new MessageImpl();
-            
+        m.put(Message.BASE_PATH, "/");    
         List<Object> params = 
             JAXRSUtils.processParameters(ori, new MetadataMap<String, String>(), m);
         assertEquals("1 parameters expected", 1, params.size());
@@ -928,7 +928,7 @@
         ProviderFactory.getInstance().registerUserProvider(cr);
         
         Message m = new MessageImpl();
-            
+        m.put(Message.BASE_PATH, "/");    
         InjectionUtils.injectContextFields(c, ori.getClassResourceInfo(), m);
         assertSame(cr.getClass(), c.getContextResolver().getClass());
     }

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java?rev=721501&r1=721500&r2=721501&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java Fri
Nov 28 06:04:44 2008
@@ -34,7 +34,7 @@
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.UriInfo;
 
-@Path("/bookstore")
+@Path("/")
 @Produces("application/json")
 public class BookStoreSpring {
 

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java?rev=721501&r1=721500&r2=721501&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
(original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
Fri Nov 28 06:04:44 2008
@@ -45,7 +45,7 @@
     @Test
     public void testGetBookByUriInfo() throws Exception {
         String endpointAddress =
-            "http://localhost:9080/bookstore/bookinfo?"
+            "http://localhost:9080/thebooks/bookstore/bookinfo?"
                                + "param1=12&param2=3"; 
         getBook(endpointAddress, "resources/expected_get_book123json.txt");
     }
@@ -108,6 +108,12 @@
                "application/xml",
                "resources/add_book.txt",
                null);
+        
+        doPost("http://localhost:9080/thebooks/bookstore/books/convert",
+               500,
+               "application/xml",
+               "resources/add_book.txt",
+               null);
                 
     }
     
@@ -119,6 +125,12 @@
                "application/json",
                "resources/add_book2json_invalid.txt",
                null);
+        
+        doPost("http://localhost:9080/thebooks/bookstore/books/convert",
+               500,
+               "application/json",
+               "resources/add_book2json_invalid.txt",
+               null);
                 
     }
     
@@ -130,6 +142,12 @@
                "application/xml",
                "resources/add_book2.txt",
                "resources/expected_get_book123.txt");
+        
+        doPost("http://localhost:9080/thebooks/bookstore/books/convert",
+               200,
+               "application/xml",
+               "resources/add_book2.txt",
+               "resources/expected_get_book123.txt");
                 
     }
     
@@ -140,6 +158,12 @@
                "application/json",
                "resources/add_book2json.txt",
                "resources/expected_get_book123.txt");
+        
+        doPost("http://localhost:9080/thebooks/bookstore/books/convert",
+               200,
+               "application/json",
+               "resources/add_book2json.txt",
+               "resources/expected_get_book123.txt");
     }
     
     private void doPost(String endpointAddress, int expectedStatus, String contentType,

Modified: cxf/trunk/systests/src/test/resources/jaxrs/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/resources/jaxrs/WEB-INF/beans.xml?rev=721501&r1=721500&r2=721501&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/resources/jaxrs/WEB-INF/beans.xml (original)
+++ cxf/trunk/systests/src/test/resources/jaxrs/WEB-INF/beans.xml Fri Nov 28 06:04:44 2008
@@ -40,10 +40,12 @@
   <import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
   <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
   
+  <bean class="org.apache.cxf.systest.jaxrs.BookStoreSpring" id="serviceBean"/>
+  
   <jaxrs:server id="bookservice"
-		        address="/">
+		        address="/bookstore">
     <jaxrs:serviceBeans>
-      <bean class="org.apache.cxf.systest.jaxrs.BookStoreSpring" />
+      <ref bean="serviceBean" />
     </jaxrs:serviceBeans>		   
     <jaxrs:providers>
        <ref bean="jaxbProvider"/>
@@ -52,6 +54,18 @@
     
   </jaxrs:server>
 
+  <jaxrs:server id="bookservice2"
+		        address="/thebooks/bookstore">
+    <jaxrs:serviceBeans>
+      <ref bean="serviceBean" />
+    </jaxrs:serviceBeans>		  
+    <jaxrs:providers>
+       <ref bean="jaxbProvider"/>
+       <ref bean="jsonProvider"/>
+    </jaxrs:providers> 
+    
+  </jaxrs:server>
+
   <bean id="jaxbProvider" class="org.apache.cxf.jaxrs.provider.JAXBElementProvider">
       <property name="schemaHandler" ref="schemaHolder"/>
   </bean>



Mime
View raw message