cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r756439 [2/2] - in /cxf/branches/2.1.x-fixes: ./ rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/ rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/main/...
Date Fri, 20 Mar 2009 12:57:14 GMT
Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java?rev=756439&r1=756438&r2=756439&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
Fri Mar 20 12:57:13 2009
@@ -42,6 +42,7 @@
 import javax.ws.rs.ext.MessageBodyWorkers;
 import javax.xml.bind.JAXBContext;
 
+import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.jaxrs.Customer;
 import org.apache.cxf.jaxrs.CustomerGender;
 import org.apache.cxf.jaxrs.CustomerParameterHandler;
@@ -65,6 +66,8 @@
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.jaxrs.model.URITemplate;
 import org.apache.cxf.jaxrs.provider.ProviderFactory;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.transport.http.AbstractHTTPDestination;
@@ -523,7 +526,7 @@
         Class[] argType = {UUID.class, CustomerGender.class, CustomerGender.class};
         Method m = Customer.class.getMethod("testFromStringParam", argType);
         UUID u = UUID.randomUUID();
-        MessageImpl messageImpl = new MessageImpl();
+        Message messageImpl = createMessage();
         messageImpl.put(Message.QUERY_STRING, "p1=" + u.toString() + "&p2=1&p3=2");
         List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null),
                                                            null, 
@@ -537,11 +540,12 @@
     
     @Test
     public void testCustomerParameter() throws Exception {
-        ProviderFactory.getInstance().registerUserProvider(
+        Message messageImpl = createMessage();
+        ProviderFactory.getInstance(messageImpl).registerUserProvider(
             new CustomerParameterHandler());
         Class[] argType = {Customer.class};
         Method m = Customer.class.getMethod("testCustomerParam", argType);
-        MessageImpl messageImpl = new MessageImpl();
+        
         messageImpl.put(Message.QUERY_STRING, "p1=Fred");
         List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null),
                                                            null, 
@@ -555,7 +559,7 @@
     public void testWrongType() throws Exception {
         Class[] argType = {HashMap.class};
         Method m = Customer.class.getMethod("testWrongType", argType);
-        MessageImpl messageImpl = new MessageImpl();
+        Message messageImpl = createMessage();
         messageImpl.put(Message.QUERY_STRING, "p1=1");
         try {
             JAXRSUtils.processParameters(new OperationResourceInfo(m, null),
@@ -864,7 +868,7 @@
         
         Customer c = new Customer();
         
-        Message m = new MessageImpl();
+        Message m = createMessage();
         m.put(Message.PROTOCOL_HEADERS, new HashMap<String, List<String>>());
         
         InjectionUtils.injectContextFields(c, ori.getClassResourceInfo(), m);
@@ -883,7 +887,7 @@
         Customer c = new Customer();
         cri.setResourceProvider(new SingletonResourceProvider(c));
         
-        Message m = new MessageImpl();
+        Message m = createMessage();
         m.put(Message.PROTOCOL_HEADERS, new HashMap<String, List<String>>());
         ServletContext servletContextMock = EasyMock.createNiceMock(ServletContext.class);
         m.put(AbstractHTTPDestination.HTTP_CONTEXT, servletContextMock);
@@ -1001,10 +1005,10 @@
                                          cri);
         ori.setHttpMethod("GET");
         
+        Message m = createMessage();
         ContextResolver<JAXBContext> cr = new JAXBContextProvider();
-        ProviderFactory.getInstance().registerUserProvider(cr);
+        ProviderFactory.getInstance(m).registerUserProvider(cr);
         
-        Message m = new MessageImpl();
         m.put(Message.BASE_PATH, "/");    
         List<Object> params = 
             JAXRSUtils.processParameters(ori, new MetadataMap<String, String>(), m);
@@ -1019,11 +1023,11 @@
         cri.setResourceProvider(new PerRequestResourceProvider(Customer.class));
         OperationResourceInfo ori = new OperationResourceInfo(null, cri);
         
+        Message m = createMessage();
         Customer c = new Customer();
         ContextResolver<JAXBContext> cr = new JAXBContextProvider();
-        ProviderFactory.getInstance().registerUserProvider(cr);
+        ProviderFactory.getInstance(m).registerUserProvider(cr);
         
-        Message m = new MessageImpl();
         m.put(Message.BASE_PATH, "/");    
         InjectionUtils.injectContextFields(c, ori.getClassResourceInfo(), m);
         assertSame(cr.getClass(), c.getContextResolver().getClass());
@@ -1046,7 +1050,7 @@
         EasyMock.replay(response);
         EasyMock.replay(context);
         
-        Message m = new MessageImpl();
+        Message m = createMessage();
         m.put(AbstractHTTPDestination.HTTP_REQUEST, request);
         m.put(AbstractHTTPDestination.HTTP_RESPONSE, response);
         m.put(AbstractHTTPDestination.HTTP_CONTEXT, context);
@@ -1084,7 +1088,7 @@
         values.putSingle("id1", "1");
         values.putSingle("id2", "2");
         
-        Message m = new MessageImpl();
+        Message m = createMessage();
         
         
         List<Object> params = 
@@ -1117,4 +1121,18 @@
         
         return null;
     }
+    
+    private Message createMessage() {
+        ProviderFactory factory = ProviderFactory.getInstance();
+        Message m = new MessageImpl();
+        Exchange e = new ExchangeImpl();
+        m.setExchange(e);
+        e.setInMessage(m);
+        Endpoint endpoint = EasyMock.createMock(Endpoint.class);
+        endpoint.get(ProviderFactory.class.getName());
+        EasyMock.expectLastCall().andReturn(factory).anyTimes();
+        EasyMock.replay(endpoint);
+        e.put(Endpoint.class, endpoint);
+        return m;
+    }
 }

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=756439&r1=756438&r2=756439&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Fri Mar 20 12:57:13 2009
@@ -228,7 +228,7 @@
         // just to verify the interface call goes through CGLIB proxy too
         assertEquals("http://localhost:9080", WebClient.client(bs).getBaseURI().toString());
         Book b = bs.getBook("123");
-        assertEquals(b.getId(), 123);
+        assertEquals(b.getId(), 123L);
     }
     
     @Test

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java?rev=756439&r1=756438&r2=756439&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
(original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
Fri Mar 20 12:57:13 2009
@@ -44,6 +44,7 @@
 import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
 import org.apache.cxf.jaxrs.client.ResponseExceptionMapper;
 import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.cxf.jaxrs.client.XMLSource;
 import org.apache.cxf.jaxrs.ext.form.Form;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
@@ -100,11 +101,11 @@
     }
     
     @Test
-    public void testGetBook123WebClientBean() throws Exception {
+    public void testGetBook123XMLSource() throws Exception {
         String baseAddress = "http://localhost:9092/test/services/rest";
         WebClient client = WebClient.create(baseAddress);
         client.path("/bookstore/123").accept(MediaType.APPLICATION_XML_TYPE);
-        Book b = client.get(Book.class);
+        Book b = client.get(XMLSource.class).getNode("/Book", Book.class);
         assertEquals(123L, b.getId());
         assertEquals("CXF in Action", b.getName());
     }



Mime
View raw message