You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2013/06/12 15:16:06 UTC
svn commit: r1492183 -
/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/SetAndDeleteContentTest.java
Author: fmui
Date: Wed Jun 12 13:16:06 2013
New Revision: 1492183
URL: http://svn.apache.org/r1492183
Log:
TCK: fixed clean up if appendContentStream() is not supported
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/SetAndDeleteContentTest.java
Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/SetAndDeleteContentTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/SetAndDeleteContentTest.java?rev=1492183&r1=1492182&r2=1492183&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/SetAndDeleteContentTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/SetAndDeleteContentTest.java Wed Jun 12 13:16:06 2013
@@ -100,7 +100,7 @@ public class SetAndDeleteContentTest ext
// test if the content stream can be deleted
if (docType.getContentStreamAllowed() == ContentStreamAllowed.REQUIRED) {
addResult(createResult(SKIPPED,
- "A content stream is required for this docuemnt type. deleteContentStream() test skipped!"));
+ "A content stream is required for this document type. deleteContentStream() test skipped!"));
} else {
// delete content stream
try {
@@ -126,27 +126,33 @@ public class SetAndDeleteContentTest ext
} catch (Exception e) {
}
- ContentStream contentStream = session.getObjectFactory().createContentStream(workDoc.getName(),
- contentBytes.length, "text/plain", new ByteArrayInputStream(contentBytes));
+ try {
+ ContentStream contentStream = session.getObjectFactory().createContentStream(workDoc.getName(),
+ contentBytes.length, "text/plain", new ByteArrayInputStream(contentBytes));
- ObjectId newObjectId = workDoc.setContentStream(contentStream, true, true);
+ ObjectId newObjectId = workDoc.setContentStream(contentStream, true, true);
- try {
- contentStream.getStream().close();
- } catch (Exception e) {
- }
+ try {
+ contentStream.getStream().close();
+ } catch (Exception e) {
+ }
- // setContentStream may have created a new version
- Document contentDoc = getNewVersion(session, workDoc, checkedout, newObjectId, "setContentStream()");
+ // setContentStream may have created a new version
+ Document contentDoc = getNewVersion(session, workDoc, checkedout, newObjectId, "setContentStream()");
- // test new content
- try {
- String content = getStringFromContentStream(contentDoc.getContentStream());
- f = createResult(FAILURE, "Document content doesn't match the content set by setContentStream()!");
- addResult(assertEquals(CONTENT2, content, null, f));
- } catch (IOException e) {
- addResult(createResult(UNEXPECTED_EXCEPTION,
- "Document content couldn't be read! Exception: " + e.getMessage(), e, true));
+ // test new content
+ try {
+ String content = getStringFromContentStream(contentDoc.getContentStream());
+ f = createResult(FAILURE, "Document content doesn't match the content set by setContentStream()!");
+ addResult(assertEquals(CONTENT2, content, null, f));
+ } catch (IOException e) {
+ addResult(createResult(UNEXPECTED_EXCEPTION,
+ "Document content couldn't be read! Exception: " + e.getMessage(), e, true));
+ }
+
+ workDoc = contentDoc;
+ } catch (CmisNotSupportedException e) {
+ addResult(createResult(WARNING, "setContentStream() is not supported!"));
}
// test appendContentStream
@@ -157,24 +163,28 @@ public class SetAndDeleteContentTest ext
} catch (Exception e) {
}
- contentStream = session.getObjectFactory().createContentStream(contentDoc.getName(),
- contentBytes.length, "text/plain", new ByteArrayInputStream(contentBytes));
+ try {
+ ContentStream contentStream = session.getObjectFactory().createContentStream(workDoc.getName(),
+ contentBytes.length, "text/plain", new ByteArrayInputStream(contentBytes));
- newObjectId = contentDoc.appendContentStream(contentStream, true);
+ ObjectId newObjectId = workDoc.appendContentStream(contentStream, true);
- // appendContentStream may have created a new version
- Document contentDoc2 = getNewVersion(session, contentDoc, checkedout, newObjectId,
- "appendContentStream()");
+ // appendContentStream may have created a new version
+ Document contentDoc = getNewVersion(session, workDoc, checkedout, newObjectId,
+ "appendContentStream()");
- // test new content
- try {
- String content = getStringFromContentStream(contentDoc2.getContentStream());
- f = createResult(FAILURE,
- "Document content doesn't match the content set by setContentStream() followed by appendContentStream()!");
- addResult(assertEquals(CONTENT2 + CONTENT3, content, null, f));
- } catch (IOException e) {
- addResult(createResult(UNEXPECTED_EXCEPTION,
- "Document content couldn't be read! Exception: " + e.getMessage(), e, true));
+ // test new content
+ try {
+ String content = getStringFromContentStream(contentDoc.getContentStream());
+ f = createResult(FAILURE,
+ "Document content doesn't match the content set by setContentStream() followed by appendContentStream()!");
+ addResult(assertEquals(CONTENT2 + CONTENT3, content, null, f));
+ } catch (IOException e) {
+ addResult(createResult(UNEXPECTED_EXCEPTION, "Document content couldn't be read! Exception: "
+ + e.getMessage(), e, true));
+ }
+ } catch (CmisNotSupportedException e) {
+ addResult(createResult(WARNING, "appendContentStream() is not supported!"));
}
}