chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fguilla...@apache.org
Subject svn commit: r1000509 - /incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/ContentStreamImpl.java
Date Thu, 23 Sep 2010 15:55:53 GMT
Author: fguillaume
Date: Thu Sep 23 15:55:53 2010
New Revision: 1000509

URL: http://svn.apache.org/viewvc?rev=1000509&view=rev
Log:
Convenience ContentStreamImpl constructor based on a string, for tests

Modified:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/ContentStreamImpl.java

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/ContentStreamImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/ContentStreamImpl.java?rev=1000509&r1=1000508&r2=1000509&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/ContentStreamImpl.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/ContentStreamImpl.java
Thu Sep 23 15:55:53 2010
@@ -18,8 +18,10 @@
  */
 package org.apache.chemistry.opencmis.commons.impl.dataobjects;
 
+import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
 import java.math.BigInteger;
 
 import org.apache.chemistry.opencmis.commons.data.ContentStream;
@@ -50,6 +52,23 @@ public class ContentStreamImpl extends A
         setStream(stream);
     }
 
+    /**
+     * Convenience constructor for tests.
+     */
+    public ContentStreamImpl(String filename, String mimetype, String string) {
+        byte[] bytes;
+        try {
+            bytes = string.getBytes("UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            // cannot happen
+            bytes = string.getBytes();
+        }
+        setLength(BigInteger.valueOf(bytes.length));
+        setMimeType(mimetype);
+        setFileName(filename);
+        setStream(new ByteArrayInputStream(bytes));
+    }
+
     public String getFileName() {
         return filename;
     }



Mime
View raw message