chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fguilla...@apache.org
Subject svn commit: r895671 - in /incubator/chemistry/trunk/chemistry: chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntry.java chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java
Date Mon, 04 Jan 2010 16:01:37 GMT
Author: fguillaume
Date: Mon Jan  4 16:01:37 2010
New Revision: 895671

URL: http://svn.apache.org/viewvc?rev=895671&view=rev
Log:
Fix AtomPub send of entry with non-text content

Modified:
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntry.java
    incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntry.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntry.java?rev=895671&r1=895670&r2=895671&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntry.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntry.java
Mon Jan  4 16:01:37 2010
@@ -329,6 +329,7 @@
             // || mimeTypeLower.endsWith("/xml")) {
             // ...
         } else {
+            xw.attr("type", mimeType);
             // encode as base64
             xw.contentBase64(localContentStream.getStream());
         }

Modified: incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java?rev=895671&r1=895670&r2=895671&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java
Mon Jan  4 16:01:37 2010
@@ -527,10 +527,12 @@
     }
 
     public void testUpdate() throws Exception {
-        byte[] blobBytes = "A file...\n".getBytes("UTF-8");
-        String filename = "doc.txt";
-        ContentStream cs = new SimpleContentStream(blobBytes,
-                "text/plain;charset=UTF-8", filename);
+        // a non-text content type (-> base64)
+        String string = "A file...\n";
+        byte[] blobBytes = string.getBytes("UTF-8");
+        String filename = "doc.gif";
+        ContentStream cs = new SimpleContentStream(blobBytes, "image/gif",
+                filename);
 
         // update a doc with a content stream
         ObjectEntry ob = spi.getObjectByPath("/folder 1/folder 2/doc 3", null);
@@ -538,6 +540,14 @@
         doc.setContentStream(cs);
         doc.setValue("title", "my doc 3");
         doc.save();
+        // refetch
+        doc = (Document) conn.getObject(spi.newObjectId(ob.getId()));
+        ContentStream cs2 = doc.getContentStream();
+        assertEquals("doc.gif", cs2.getFileName());
+        assertEquals("image/gif", cs2.getMimeType());
+        assertEquals(blobBytes.length, cs2.getLength());
+        byte[] array = IOUtils.toByteArray(cs2.getStream());
+        assertEquals(string, new String(array, "UTF-8"));
 
         // update a doc that doesn't have a content stream yet
         ob = spi.getObjectByPath("/folder 1/doc 1", null);



Mime
View raw message