cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1567699 - in /cxf/branches/2.7.x-fixes: ./ rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/jsonp/ rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/jsonp/
Date Wed, 12 Feb 2014 17:42:38 GMT
Author: sergeyb
Date: Wed Feb 12 17:42:37 2014
New Revision: 1567699

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

........
  r1567696 | sergeyb | 2014-02-12 17:36:05 +0000 (Wed, 12 Feb 2014) | 1 line
  
  [CXF-5558] Updating JSONPInInterceptor to recognize custom callback parameters
........

Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/jsonp/JsonpInInterceptor.java
    cxf/branches/2.7.x-fixes/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/jsonp/JsonpInterceptorTest.java

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

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

Modified: cxf/branches/2.7.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/jsonp/JsonpInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/jsonp/JsonpInInterceptor.java?rev=1567699&r1=1567698&r2=1567699&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/jsonp/JsonpInInterceptor.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/jsonp/JsonpInInterceptor.java
Wed Feb 12 17:42:37 2014
@@ -54,7 +54,7 @@ public class JsonpInInterceptor extends 
         if (!StringUtils.isEmpty(callbackValue)) {
             if (getAcceptType() != null) {
                 // may be needed to enforce the selection of 
-                // JSON-awarenprovider
+                // JSON-aware provider
                 message.put(Message.ACCEPT_CONTENT_TYPE, getAcceptType());
             }
             message.getExchange().put(CALLBACK_KEY, callbackValue);
@@ -63,7 +63,7 @@ public class JsonpInInterceptor extends 
 
     protected String getCallbackValue(Message message) {
         String theQuery = (String)message.get(Message.QUERY_STRING);
-        String callback = JAXRSUtils.getStructuredParams(theQuery, "&", false, false).getFirst(CALLBACK_PARAM);
+        String callback = JAXRSUtils.getStructuredParams(theQuery, "&", false, false).getFirst(callbackParam);
         if (StringUtils.isEmpty(callback)) {
             String httpAcceptType = (String)message.get(Message.ACCEPT_CONTENT_TYPE);
             if (httpAcceptType != null && mediaType.equals(httpAcceptType)) {

Modified: cxf/branches/2.7.x-fixes/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/jsonp/JsonpInterceptorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/jsonp/JsonpInterceptorTest.java?rev=1567699&r1=1567698&r2=1567699&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/jsonp/JsonpInterceptorTest.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/jsonp/JsonpInterceptorTest.java
Wed Feb 12 17:42:37 2014
@@ -66,6 +66,28 @@ public class JsonpInterceptorTest extend
     }
     
     @Test
+    public void testJsonWithPaddingCustomCallbackParam() throws Exception {
+        Message message = new MessageImpl();
+        message.put(Message.CONTENT_TYPE, MediaType.APPLICATION_JSON);
+        message.setExchange(new ExchangeImpl());
+        message.put(Message.QUERY_STRING, "_customjsonp=myCallback");
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        message.setContent(OutputStream.class, bos);
+        
+        // Process the message
+        try {
+            in.setCallbackParam("_customjsonp");
+            in.handleMessage(message);
+            preStream.handleMessage(message);
+            postStream.handleMessage(message);
+            assertEquals("myCallback();", bos.toString());
+        } finally {
+            in.setCallbackParam("_jsonp");
+        }
+
+    }
+    
+    @Test
     public void testJsonWithDefaultPadding() throws Exception {
         Message message = new MessageImpl();
         message.put(Message.ACCEPT_CONTENT_TYPE, JsonpInInterceptor.JSONP_TYPE);



Mime
View raw message