cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1090703 - in /cxf/branches/2.3.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/jsonp/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/jsonp/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/...
Date Sat, 09 Apr 2011 23:06:14 GMT
Author: sergeyb
Date: Sat Apr  9 23:06:14 2011
New Revision: 1090703

URL: http://svn.apache.org/viewvc?rev=1090703&view=rev
Log:
Merged revisions 1090701 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1090701 | sergeyb | 2011-04-09 23:59:40 +0100 (Sat, 09 Apr 2011) | 1 line
  
  [CXF-3005] Adding simple JSONP interceptors, patch submitted by Josh Holtzman
........

Added:
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/jsonp/
      - copied from r1090701, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/jsonp/
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/jsonp/AbstractJsonpOutInterceptor.java
      - copied unchanged from r1090701, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/jsonp/AbstractJsonpOutInterceptor.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/jsonp/JsonpInInterceptor.java
      - copied unchanged from r1090701, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/jsonp/JsonpInInterceptor.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/jsonp/JsonpPostStreamInterceptor.java
      - copied unchanged from r1090701, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/jsonp/JsonpPostStreamInterceptor.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/jsonp/JsonpPreStreamInterceptor.java
      - copied unchanged from r1090701, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/jsonp/JsonpPreStreamInterceptor.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/jsonp/
      - copied from r1090701, cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/jsonp/
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/jsonp/JsonpInterceptorTest.java
      - copied unchanged from r1090701, cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/jsonp/JsonpInterceptorTest.java
Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
    cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/beans.xml

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
    svn:mergeinfo = /cxf/trunk:1090701

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

Modified: cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java?rev=1090703&r1=1090702&r2=1090703&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
(original)
+++ cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
Sat Apr  9 23:06:14 2011
@@ -30,6 +30,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.ws.rs.core.Response;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
@@ -130,6 +131,32 @@ public class JAXRSClientServerSpringBook
                 "application/jettison");
     }
     
+    
+    @Test
+    public void testGetBookJsonp() throws Exception {
+        String url = "http://localhost:" + PORT + "/the/jsonp/books/123";
+        WebClient client = WebClient.create(url);
+        client.accept("application/json, application/x-javascript");
+        client.query("_jsonp", "callback");
+        WebClient.getConfig(client).getHttpConduit().getClient().setReceiveTimeout(1000000L);
+        Response r = client.get();
+        assertEquals("application/x+javascript", r.getMetadata().getFirst("Content-Type"));
+        assertEquals("callback({\"Book\":{\"id\":123,\"name\":\"CXF in Action\"}});",
+                     IOUtils.readStringFromStream((InputStream)r.getEntity()));
+    }
+    
+    @Test
+    public void testGetBookWithoutJsonpCallback() throws Exception {
+        String url = "http://localhost:" + PORT + "/the/jsonp/books/123";
+        WebClient client = WebClient.create(url);
+        client.accept("application/json, application/x-javascript");
+        WebClient.getConfig(client).getHttpConduit().getClient().setReceiveTimeout(1000000L);
+        Response r = client.get();
+        assertEquals("application/json", r.getMetadata().getFirst("Content-Type"));
+        assertEquals("{\"Book\":{\"id\":123,\"name\":\"CXF in Action\"}}",
+                     IOUtils.readStringFromStream((InputStream)r.getEntity()));
+    }
+    
     @Test
     public void testGetBookAsArray() throws Exception {
         URL url = new URL("http://localhost:" + PORT + "/the/bookstore/books/list/123");

Modified: cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/beans.xml?rev=1090703&r1=1090702&r2=1090703&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/beans.xml (original)
+++ cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/beans.xml Sat
Apr  9 23:06:14 2011
@@ -125,6 +125,20 @@ http://cxf.apache.org/schemas/core.xsd">
        <bean class="org.apache.cxf.systest.jaxrs.XMLStreamWriterOutInterceptor"/>
     </jaxrs:outInterceptors>
     
+  </jaxrs:server>
+  
+  <jaxrs:server id="bookJsonp" address="/jsonp">
+    <jaxrs:serviceBeans>
+      <ref bean="serviceBean" />
+    </jaxrs:serviceBeans>		  
+
+    <jaxrs:inInterceptors>
+       <bean class="org.apache.cxf.jaxrs.provider.jsonp.JsonpInInterceptor"/>
+    </jaxrs:inInterceptors>
+    <jaxrs:outInterceptors>
+       <bean class="org.apache.cxf.jaxrs.provider.jsonp.JsonpPreStreamInterceptor"/>
+       <bean class="org.apache.cxf.jaxrs.provider.jsonp.JsonpPostStreamInterceptor"/>
+    </jaxrs:outInterceptors> 
   </jaxrs:server> 
   
   <util:map id="outTemplates">



Mime
View raw message