You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by jl...@apache.org on 2008/01/10 10:14:52 UTC

svn commit: r610729 - in /incubator/cxf/trunk: distribution/src/main/release/samples/jax_rs/content_negotiation/src/demo/jaxrs/server/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/ systests/src/test/java/org/apache/cxf/systest/jaxrs/

Author: jliu
Date: Thu Jan 10 01:14:39 2008
New Revision: 610729

URL: http://svn.apache.org/viewvc?rev=610729&view=rev
Log:
Test case for CXF-1361: Output MIME type did not set correctly when there are multiple values for @ProduceMime

Modified:
    incubator/cxf/trunk/distribution/src/main/release/samples/jax_rs/content_negotiation/src/demo/jaxrs/server/CustomerService.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java

Modified: incubator/cxf/trunk/distribution/src/main/release/samples/jax_rs/content_negotiation/src/demo/jaxrs/server/CustomerService.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/jax_rs/content_negotiation/src/demo/jaxrs/server/CustomerService.java?rev=610729&r1=610728&r2=610729&view=diff
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/jax_rs/content_negotiation/src/demo/jaxrs/server/CustomerService.java (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/jax_rs/content_negotiation/src/demo/jaxrs/server/CustomerService.java Thu Jan 10 01:14:39 2008
@@ -44,16 +44,6 @@
         return c;
     }
 
-    @HttpMethod("GET")
-    @UriTemplate("/customersjson/{id}/")
-    @ProduceMime("application/json")
-    public Customer getCustomerJSON(@UriParam("id") String id) {
-        System.out.println("----invoking getCustomerJSON, Customer id is: " + id);
-        long idNumber = Long.parseLong(id);
-        Customer c = customers.get(idNumber);
-        return c;
-    }
-
     final void init() {
         Customer c = new Customer();
         c.setName("John");

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java?rev=610729&r1=610728&r2=610729&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java Thu Jan 10 01:14:39 2008
@@ -95,7 +95,8 @@
                                                                        contentType, acceptContentType);
 
         if (ori == null) {
-            LOG.severe("No operation found");
+            LOG.severe("No operation found for path: " + path + ", contentType: " + contentType
+                       + ", Accept contentType: " + acceptContentType);
             //throw new Fault(new org.apache.cxf.common.i18n.Message("NO_OP", BUNDLE, method, path));
         }
         LOG.info("Found operation: " + ori.getMethod().getName());

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=610729&r1=610728&r2=610729&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java Thu Jan 10 01:14:39 2008
@@ -161,24 +161,23 @@
 
     @HttpMethod("GET")
     @UriTemplate("/cd/{CDId}/")
-    @ProduceMime("application/xml")
     public CD getCD(@UriParam("CDId") String id) {
         System.out.println("----invoking getCD with cdId: " + id);
         CD cd = cds.get(Long.parseLong(id));
 
         return cd;
     }
-    
+
     @HttpMethod("GET")
-    @UriTemplate("/cd/{CDId}/")
-    @ProduceMime("application/json")
-    public CD getCDJSON(@UriParam("CDId") String id) {
-        System.out.println("----invoking getCDJSON with cdId: " + id);
+    @UriTemplate("/cdwithmultitypes/{CDId}/")
+    @ProduceMime({"application/xml", "application/json" }) 
+    public CD getCDWithMultiContentTypes(@UriParam("CDId") String id) {
+        System.out.println("----invoking getCDWithMultiContentTypes with cdId: " + id);
         CD cd = cds.get(Long.parseLong(id));
 
         return cd;
     }
-
+    
     @HttpMethod("GET")
     @UriTemplate("/cds/")
     public CDs getCDs() {

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=610729&r1=610728&r2=610729&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java Thu Jan 10 01:14:39 2008
@@ -309,8 +309,7 @@
             // Release current connection to the connection pool once you are done
             get.releaseConnection();
         }  
-    }
-    
+    }    
     
     @Test
     public void testGetCDXML() throws Exception {
@@ -327,6 +326,53 @@
             assertEquals(200, result);
 
             InputStream expected = getClass().getResourceAsStream("resources/expected_get_cd.txt");
+            
+            assertEquals(getStringFromInputStream(expected), get.getResponseBodyAsString());
+        } finally {
+            // Release current connection to the connection pool once you are done
+            get.releaseConnection();
+        }  
+    }
+    
+    
+    @Test
+    public void testGetCDWithMultiContentTypesXML() throws Exception {
+        String endpointAddress =
+            "http://localhost:9080/bookstore/cdwithmultitypes/123"; 
+
+        GetMethod get = new GetMethod(endpointAddress);
+        get.addRequestHeader("Accept" , "application/xml");
+
+        HttpClient httpclient = new HttpClient();
+        
+        try {
+            int result = httpclient.executeMethod(get);
+            assertEquals(200, result);
+
+            InputStream expected = getClass().getResourceAsStream("resources/expected_get_cd.txt");
+            
+            assertEquals(getStringFromInputStream(expected), get.getResponseBodyAsString());
+        } finally {
+            // Release current connection to the connection pool once you are done
+            get.releaseConnection();
+        }  
+    }
+    
+    @Test
+    public void testGetCDWithMultiContentTypesJSON() throws Exception {
+        String endpointAddress =
+            "http://localhost:9080/bookstore/cdwithmultitypes/123"; 
+
+        GetMethod get = new GetMethod(endpointAddress);
+        get.addRequestHeader("Accept" , "application/json");
+
+        HttpClient httpclient = new HttpClient();
+        
+        try {
+            int result = httpclient.executeMethod(get);
+            assertEquals(200, result);
+
+            InputStream expected = getClass().getResourceAsStream("resources/expected_get_cdjson.txt");
             
             assertEquals(getStringFromInputStream(expected), get.getResponseBodyAsString());
         } finally {