incubator-wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject svn commit: r886702 - in /incubator/wink/trunk/wink-common/src: main/java/org/apache/wink/common/model/multipart/ test/java/org/apache/wink/common/internal/providers/multipart/
Date Thu, 03 Dec 2009 08:15:57 GMT
Author: elib
Date: Thu Dec  3 08:15:56 2009
New Revision: 886702

URL: http://svn.apache.org/viewvc?rev=886702&view=rev
Log:
Fix issue WINK-230 "NullPointerException occurs when Content type in MultiPart isn't sent"

Modified:
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/multipart/InPart.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/multipart/OutPart.java
    incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/providers/multipart/TestMultiPartProvider.java

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/multipart/InPart.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/multipart/InPart.java?rev=886702&r1=886701&r2=886702&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/multipart/InPart.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/multipart/InPart.java
Thu Dec  3 08:15:56 2009
@@ -99,7 +99,11 @@
 
 
     public String getContentType() {
-        return getHeaders().getFirst(HttpHeaders.CONTENT_TYPE);
+        String res = getHeaders().getFirst(HttpHeaders.CONTENT_TYPE);
+        if(res == null)
+        	res = MediaType.TEXT_PLAIN;
+        return res;
+        
     }
 
     public Set<String> getHeadersName() {

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/multipart/OutPart.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/multipart/OutPart.java?rev=886702&r1=886701&r2=886702&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/multipart/OutPart.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/multipart/OutPart.java
Thu Dec  3 08:15:56 2009
@@ -65,7 +65,11 @@
     }
 
     public String getContentType() {
-        return getHeaders().getFirst(HttpHeaders.CONTENT_TYPE);
+    	String res = getHeaders().getFirst(HttpHeaders.CONTENT_TYPE);
+        if(res == null)
+        	res = MediaType.TEXT_PLAIN;
+        return res;
+        //return getHeaders().getFirst(HttpHeaders.CONTENT_TYPE);
     }
 
     /**

Modified: incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/providers/multipart/TestMultiPartProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/providers/multipart/TestMultiPartProvider.java?rev=886702&r1=886701&r2=886702&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/providers/multipart/TestMultiPartProvider.java
(original)
+++ incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/providers/multipart/TestMultiPartProvider.java
Thu Dec  3 08:15:56 2009
@@ -50,6 +50,14 @@
 import org.apache.wink.common.model.multipart.OutPart;
 
 public class TestMultiPartProvider extends TestCase {
+	 public void testBufferdMultiPartNoContentType() throws IOException {
+		 runTestBufferdMultiPart(null);
+		 
+	 }
+	 public void testBufferdMultiPart() throws IOException {
+		 runTestBufferdMultiPart(MediaType.TEXT_PLAIN);
+		 
+	 }
 
     /**
      * create A BufferdMultipart ,serialized it, un serilized it using providers
@@ -57,7 +65,7 @@
      * 
      * @throws IOException
      */
-    public void testBufferdMultiPart() throws IOException {
+    public void runTestBufferdMultiPart(String contentType) throws IOException {
         String bounary = "1267h27";
         String body = "This is the Body String";
         BufferedOutMultiPart bomp = new BufferedOutMultiPart();
@@ -67,7 +75,8 @@
 
         op.addHeader("nAme", "value");
         assertEquals(op.getHeaders().getFirst("NaMe"), "value");
-        op.setContentType(MediaType.TEXT_PLAIN);
+        if(contentType!= null)
+        	op.setContentType(contentType);
         op.setBody(body);
         bomp.addPart(op);
 
@@ -90,6 +99,9 @@
         // bomp.write(os, null);
 
     }
+    
+    
+    
 
     /**
      * extends the OutMultiPart (FileOutMultiPart) pass a file, serialized



Mime
View raw message