cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1498397 - in /cxf/branches/2.7.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ systests/jaxrs/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Date Mon, 01 Jul 2013 12:05:29 GMT
Author: sergeyb
Date: Mon Jul  1 12:05:28 2013
New Revision: 1498397

URL: http://svn.apache.org/r1498397
Log:
Merged revisions 1498353 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1498353 | sergeyb | 2013-07-01 11:24:09 +0100 (Mon, 01 Jul 2013) | 1 line
  
  [CXF-5093] Updates to JAX-RS related code
........

Added:
    cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServerAsyncClient.java
      - copied unchanged from r1498353, cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServerAsyncClient.java
    cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java
      - copied, changed from r1498353, cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java
Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
    cxf/branches/2.7.x-fixes/systests/jaxrs/pom.xml
    cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java
    cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
    cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
    cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1498353

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

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java?rev=1498397&r1=1498396&r2=1498397&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java
Mon Jul  1 12:05:28 2013
@@ -92,6 +92,9 @@ public class MessageContextImpl implemen
                 if (inMessage != null && inMessage != m) {
                     value = inMessage.get(key);
                 }
+                if (value == null) {
+                    value = m.getExchange().get(key);
+                }
             }
         } 
         return value;

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=1498397&r1=1498396&r2=1498397&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
Mon Jul  1 12:05:28 2013
@@ -161,6 +161,7 @@ public final class JAXRSUtils {
     public static final String MEDIA_TYPE_Q_PARAM = "q";
     public static final String MEDIA_TYPE_QS_PARAM = "qs";
     private static final String MEDIA_TYPE_DISTANCE_PARAM = "d";
+    private static final String DEFAULT_CONTENT_TYPE = "default.content.type";
     
     private static final Logger LOG = LogUtils.getL7dLogger(JAXRSUtils.class);
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(JAXRSUtils.class);
@@ -782,7 +783,8 @@ public final class JAXRSUtils {
                                                            BUNDLE, 
                                                            ori.getHttpMethod());
                 LOG.fine(errorMsg.toString());
-                contentType = MediaType.WILDCARD;
+                String defaultCt = (String)message.getContextualProperty(DEFAULT_CONTENT_TYPE);
+                contentType = defaultCt == null ? MediaType.APPLICATION_OCTET_STREAM : defaultCt;
             }
 
             return readFromMessageBody(parameterClass,
@@ -1248,17 +1250,15 @@ public final class JAXRSUtils {
                 } catch (Exception ex) {
                     throw new Fault(ex);
                 }
-            } else {
-                String errorMessage = new org.apache.cxf.common.i18n.Message("NO_MSG_READER",
-                                                       BUNDLE,
-                                                       targetTypeClass.getSimpleName(),
-                                                       mediaTypeToString(contentType)).toString();
-                LOG.warning(errorMessage);
-                throw new WebApplicationException(Response.Status.UNSUPPORTED_MEDIA_TYPE);
             }
         }
 
-        return null;
+        String errorMessage = new org.apache.cxf.common.i18n.Message("NO_MSG_READER",
+                                                                     BUNDLE,
+                                                                     targetTypeClass.getSimpleName(),
+                                                                     mediaTypeToString(contentType)).toString();
+        LOG.warning(errorMessage);
+        throw new WebApplicationException(Response.Status.UNSUPPORTED_MEDIA_TYPE);
     }
     
     @SuppressWarnings("unchecked")

Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/pom.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/pom.xml?rev=1498397&r1=1498396&r2=1498397&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/pom.xml (original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/pom.xml Mon Jul  1 12:05:28 2013
@@ -198,6 +198,14 @@
             <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-transports-http-hc</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+
         <dependency>
           <groupId>javax.annotation</groupId>
           <artifactId>jsr250-api</artifactId>

Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java?rev=1498397&r1=1498396&r2=1498397&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java
Mon Jul  1 12:05:28 2013
@@ -31,6 +31,7 @@ import javax.ws.rs.ext.ExceptionMapper;
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
 import org.apache.cxf.jaxrs.ext.search.QueryContextProvider;
 import org.apache.cxf.jaxrs.ext.search.SearchBean;
@@ -54,7 +55,7 @@ public class BookServer extends Abstract
         JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
         sf.setBus(bus);
         sf.setResourceClasses(BookStore.class, SimpleBookStore.class, BookStorePerRequest.class);
-        
+        sf.getInInterceptors().add(new LoggingInInterceptor());
         List<Object> providers = new ArrayList<Object>();
         
         //default lifecycle is per-request, change it to singleton
@@ -88,6 +89,7 @@ public class BookServer extends Abstract
         sf.getProperties(true).put("org.apache.cxf.jaxrs.mediaTypeCheck.strict", true);
         sf.getProperties().put("search.visitor", new SQLPrinterVisitor<SearchBean>("books"));
         sf.getProperties().put("org.apache.cxf.http.header.split", true);
+        sf.getProperties().put("default.content.type", "*/*");
         server = sf.create();
         BusFactory.setDefaultBus(null);
         BusFactory.setThreadDefaultBus(null);

Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=1498397&r1=1498396&r2=1498397&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
Mon Jul  1 12:05:28 2013
@@ -59,7 +59,6 @@ import javax.ws.rs.container.ResourceCon
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.Cookie;
 import javax.ws.rs.core.EntityTag;
-import javax.ws.rs.core.Form;
 import javax.ws.rs.core.GenericEntity;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
@@ -82,6 +81,7 @@ import org.apache.cxf.common.util.ProxyH
 import org.apache.cxf.jaxrs.ext.MessageContext;
 import org.apache.cxf.jaxrs.ext.Nullable;
 import org.apache.cxf.jaxrs.ext.Oneway;
+import org.apache.cxf.jaxrs.ext.form.Form;
 import org.apache.cxf.jaxrs.ext.search.QueryContext;
 import org.apache.cxf.jaxrs.ext.search.SearchCondition;
 import org.apache.cxf.jaxrs.ext.search.SearchContext;
@@ -150,12 +150,20 @@ public class BookStore {
         return doGetBook("123");
     }
     
+    @RETRIEVE
+    @Path("/retrieve")
+    @Produces("application/xml")
+    @Consumes("application/xml")
+    public Book retrieveBook(Book book) {
+        return book;
+    }
+    
     @POST
     @Path("/emptyform")
     @Produces("text/plain")
     @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
     public String postEmptyForm(Form form) {
-        if (!form.asMap().isEmpty()) {
+        if (!form.getData().isEmpty()) {
             throw new WebApplicationException(400);
         }
         return "empty form";

Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java?rev=1498397&r1=1498396&r2=1498397&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
Mon Jul  1 12:05:28 2013
@@ -49,7 +49,6 @@ import org.apache.cxf.jaxrs.client.WebCl
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Test;
 
 public class JAXRS20ClientServerBookTest extends AbstractBusClientServerTestBase {
@@ -92,35 +91,19 @@ public class JAXRS20ClientServerBookTest
     @Test
     public void testGetBook() {
         String address = "http://localhost:" + PORT + "/bookstore/bookheaders/simple";
-        doTestGetBook(address);
+        doTestGetBook(address, false);
     }
     
     @Test
-    public void testGetBookAsync() throws Exception {
+    public void testGetBookSyncWithAsync() {
         String address = "http://localhost:" + PORT + "/bookstore/bookheaders/simple";
-        doTestGetBookAsync(address, false);
-    }
-    
-    @Test
-    @Ignore
-    public void testGetBookAsync404() throws Exception {
-        String address = "http://localhost:" + PORT + "/bookstore/bookheaders/404";
-        WebClient wc = createWebClient(address);
-        Future<Book> future = wc.async().get(Book.class);
-        Book book = future.get();
-        assertEquals(124L, book.getId());
+        doTestGetBook(address, true);
     }
     
     @Test
-    @Ignore
-    public void testGetBookAsync404Callback() throws Exception {
-        String address = "http://localhost:" + PORT + "/bookstore/bookheaders/404";
-        WebClient wc = createWebClient(address);
-        final Holder<Book> holder = new Holder<Book>();
-        InvocationCallback<Book> callback = createCallback(holder);
-        Future<Book> future = wc.async().get(callback);
-        Book book = future.get();
-        assertEquals(124L, book.getId());
+    public void testGetBookAsync() throws Exception {
+        String address = "http://localhost:" + PORT + "/bookstore/bookheaders/simple";
+        doTestGetBookAsync(address, false);
     }
     
     @Test
@@ -181,7 +164,7 @@ public class JAXRS20ClientServerBookTest
     @Test
     public void testGetBookWrongPath() {
         String address = "http://localhost:" + PORT + "/wrongpath";
-        doTestGetBook(address);
+        doTestGetBook(address, false);
     }
     @Test
     public void testGetBookWrongPathAsync() throws Exception {
@@ -342,8 +325,11 @@ public class JAXRS20ClientServerBookTest
         
     }
     
-    private void doTestGetBook(String address) {
+    private void doTestGetBook(String address, boolean useAsync) {
         WebClient wc = createWebClient(address);
+        if (useAsync) {
+            WebClient.getConfig(wc).getRequestContext().put("use.async.http.conduit", true);
+        }
         Book book = wc.get(Book.class);
         assertEquals(124L, book.getId());
         validateResponse(wc);

Copied: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java
(from r1498353, cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java)
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java?p2=cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java&p1=cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java&r1=1498353&r2=1498397&rev=1498397&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java
Mon Jul  1 12:05:28 2013
@@ -23,6 +23,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.Future;
 
+import javax.ws.rs.client.ClientException;
 import javax.ws.rs.client.Entity;
 import javax.ws.rs.client.InvocationCallback;
 import javax.xml.ws.Holder;
@@ -100,7 +101,7 @@ public class JAXRSAsyncClientTest extend
             public void completed(Book response) {
                 holder.value = response;
             }
-            public void failed(Throwable error) {
+            public void failed(ClientException error) {
                 error.printStackTrace();
             }
         };

Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1498397&r1=1498396&r2=1498397&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Mon Jul  1 12:05:28 2013
@@ -37,7 +37,6 @@ import javax.ws.rs.NotAcceptableExceptio
 import javax.ws.rs.ServerErrorException;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.client.ClientException;
-import javax.ws.rs.core.Form;
 import javax.ws.rs.core.GenericEntity;
 import javax.ws.rs.core.GenericType;
 import javax.ws.rs.core.HttpHeaders;
@@ -63,6 +62,7 @@ import org.apache.cxf.jaxrs.client.JAXRS
 import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
 import org.apache.cxf.jaxrs.client.ResponseExceptionMapper;
 import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.cxf.jaxrs.ext.form.Form;
 import org.apache.cxf.jaxrs.ext.xml.XMLSource;
 import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
 import org.apache.cxf.jaxrs.provider.JAXBElementProvider;



Mime
View raw message