cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1038722 - in /cxf/trunk/rt/frontend/jaxrs/src: main/java/org/apache/cxf/jaxrs/utils/FormUtils.java test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
Date Wed, 24 Nov 2010 17:48:28 GMT
Author: sergeyb
Date: Wed Nov 24 17:48:27 2010
New Revision: 1038722

URL: http://svn.apache.org/viewvc?rev=1038722&view=rev
Log:
[CXF-3147] Defaulting to UTF-8 if form media type is null

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java?rev=1038722&r1=1038721&r2=1038722&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java Wed
Nov 24 17:48:27 2010
@@ -71,7 +71,7 @@ public final class FormUtils {
     }
     
     private static String getCharset(MediaType mt) {
-        String charset = mt.getParameters().get("charset");
+        String charset = mt == null ? "UTF-8" : mt.getParameters().get("charset");
         return charset == null ? "UTF-8" : charset;
     }
     

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java?rev=1038722&r1=1038721&r2=1038722&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
Wed Nov 24 17:48:27 2010
@@ -989,16 +989,27 @@ public class JAXRSUtilsTest extends Asse
         assertEquals("bar foo", params.get(1));
     }
     
-    @SuppressWarnings("unchecked")
     @Test
     public void testFormParameters() throws Exception {
+        doTestFormParameters(true);
+    }
+    
+    @Test
+    public void testFormParametersWithoutMediaType() throws Exception {
+        doTestFormParameters(false);
+    }
+    
+    @SuppressWarnings("unchecked")
+    private void doTestFormParameters(boolean useMediaType) throws Exception {
         Class[] argType = {String.class, List.class};
         Method m = Customer.class.getMethod("testFormParam", argType);
         MessageImpl messageImpl = new MessageImpl();
         String body = "p1=1&p2=2&p2=3";
         messageImpl.put(Message.REQUEST_URI, "/foo");
         MultivaluedMap<String, String> headers = new MetadataMap<String, String>();
-        headers.putSingle("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
+        if (useMediaType) {
+            headers.putSingle("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
+        }
         messageImpl.put(Message.PROTOCOL_HEADERS, headers);
         messageImpl.setContent(InputStream.class, new ByteArrayInputStream(body.getBytes()));
         List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null), 



Mime
View raw message