Author: fmui
Date: Mon Sep 27 09:17:15 2010
New Revision: 1001636
URL: http://svn.apache.org/viewvc?rev=1001636&view=rev
Log:
CMIS-254: fixed AtomPub client
Modified:
incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/HttpUtils.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/AbstractWriteObjectIT.java
Modified:
incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/HttpUtils.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/HttpUtils.java?rev=1001636&r1=1001635&r2=1001636&view=diff
==============================================================================
---
incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/HttpUtils.java
(original)
+++
incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/HttpUtils.java
Mon Sep 27 09:17:15 2010
@@ -41,15 +41,12 @@ import org.apache.commons.logging.LogFac
/**
* HTTP helper methods.
- *
- * @author <a href="mailto:[email protected]">Florian Müller</a>
- *
*/
public class HttpUtils {
private static final Log log = LogFactory.getLog(HttpUtils.class);
- private static final int BUFFER_SIZE = 4096;
+ private static final int BUFFER_SIZE = 2 * 1024 * 1024;
private HttpUtils() {
}
@@ -128,6 +125,7 @@ public class HttpUtils {
// send data
if (writer != null) {
+ conn.setChunkedStreamingMode(BUFFER_SIZE);
OutputStream out = new
BufferedOutputStream(conn.getOutputStream(), BUFFER_SIZE);
writer.write(out);
out.flush();
@@ -144,16 +142,15 @@ public class HttpUtils {
}
// get the response
- return new Response(respCode, conn.getResponseMessage(),
conn.getHeaderFields(), inputStream, conn
- .getErrorStream());
+ return new Response(respCode, conn.getResponseMessage(),
conn.getHeaderFields(), inputStream,
+ conn.getErrorStream());
} catch (Exception e) {
throw new CmisConnectionException("Cannot access " + url + ": " +
e.getMessage(), e);
}
}
/**
- * @author <a href="mailto:[email protected]">Florian Müller</a>
- *
+ * HTTP Response.
*/
public static class Response {
private int fResponseCode;
Modified:
incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/AbstractWriteObjectIT.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/AbstractWriteObjectIT.java?rev=1001636&r1=1001635&r2=1001636&view=diff
==============================================================================
---
incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/AbstractWriteObjectIT.java
(original)
+++
incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/AbstractWriteObjectIT.java
Mon Sep 27 09:17:15 2010
@@ -89,6 +89,50 @@ public abstract class AbstractWriteObjec
}
@Test
+ @Ignore
+ public void createHugeDocument() throws IOException {
+ ObjectId parentId =
this.session.createObjectId(this.fixture.getTestRootId());
+ String folderName = UUID.randomUUID().toString();
+ String typeId = FixtureData.DOCUMENT_TYPE_ID.value();
+
+ Map<String, Object> properties = new HashMap<String, Object>();
+ properties.put(PropertyIds.NAME, folderName);
+ properties.put(PropertyIds.OBJECT_TYPE_ID, typeId);
+
+ String filename = UUID.randomUUID().toString();
+ String mimetype = "application/octet-stream";
+
+ ObjectId id = this.session.createDocument(properties, parentId, null,
VersioningState.NONE);
+ assertNotNull(id);
+
+ // verify content
+ Document doc = (Document) this.session.getObject(id);
+ assertNotNull(doc);
+
+ final int size = 1 * 1024 * 1024 * 1024; // 2GB
+
+ InputStream in = new InputStream() {
+
+ private int counter = -1;
+
+ @Override
+ public int read() throws IOException {
+ counter++;
+ if (counter >= size) {
+ return -1;
+ }
+
+ return '0' + (counter / 10);
+ }
+ };
+
+ ContentStream contentStream =
this.session.getObjectFactory().createContentStream(filename, size, mimetype,
in);
+ assertNotNull(contentStream);
+
+ doc.setContentStream(contentStream, true);
+ }
+
+ @Test
public void createDocumentFromSource() throws IOException {
try {
// verify content
@@ -166,7 +210,7 @@ public abstract class AbstractWriteObjec
document.updateProperties();
assertEquals("Neuer Name", document.getName());
}
-
+
@Test
public void updateSinglePropertyAndCheckName() {
// verify content
@@ -184,10 +228,10 @@ public abstract class AbstractWriteObjec
// update single property
ObjectId newId = document.updateProperties(properties);
assertNotNull(newId);
- assertEquals(id, newId.getId()); // should not be a new version
-
+ assertEquals(id, newId.getId()); // should not be a new version
+
session.clear();
-
+
// verify
String s1 = FixtureData.DOCUMENT1_NAME.toString();
String s2 = document.getName();
@@ -196,7 +240,7 @@ public abstract class AbstractWriteObjec
Property<String> p = document.getProperty(PropertyIds.NAME);
String s3 = p.getFirstValue();
assertEquals(s1, s3);
-
+
Document document2 = (Document) this.session.getObjectByPath(path);
assertNotNull("Document not found: " + path, document2);
}