use of org.apache.chemistry.opencmis.tck.CmisTestResult in project copper-cms by PogeyanOSS.
the class NameCharsetTest method run.
@Override
public void run(Session session) {
CmisTestResult f;
// create a test folder
Folder testFolder = createTestFolder(session);
try {
for (int i = 0; i < NAMES.length; i++) {
Document doc = null;
Document doc2 = null;
try {
doc = null;
doc = createDocument(session, testFolder, NAMES[i], NAMES[i]);
// get the newly created object by path
String path = doc.getPaths().get(0);
doc2 = (Document) session.getObjectByPath(path, SELECT_ALL_NO_CACHE_OC);
addResult(checkObject(session, doc2, getAllProperties(doc2), "New document object spec compliance"));
f = createResult(FAILURE, "Names of the created and the fetched document don't match!");
assertEquals(NAMES[i], doc2.getName(), null, f);
ContentStream contentStream = doc.getContentStream();
f = createResult(FAILURE, "Document has no content!");
assertNotNull(contentStream, null, f);
IOUtils.consumeAndClose(contentStream.getStream());
} catch (Exception e) {
addResult(createResult(WARNING, "The name '" + NAMES[i] + "' raised this exception: " + e, e, false));
} finally {
if (doc != null) {
// delete it
try {
doc.delete(true);
} catch (Exception e) {
// ignore
}
}
}
}
addResult(createInfoResult("Tested " + NAMES.length + " different names."));
} finally {
// delete the test folder
deleteTestFolder();
}
}
use of org.apache.chemistry.opencmis.tck.CmisTestResult in project copper-cms by PogeyanOSS.
the class OperationContextTest method runLowLevelApiTests.
/**
* Checks for change events and path segments.
*/
public void runLowLevelApiTests(Session session, Folder testFolder, Document testDocument) {
CmisTestResult f;
String repositoryId = session.getRepositoryInfo().getId();
String filter = "cmis:objectId,cmis:baseTypeId,cmis:objectTypeId";
// get the object
ObjectData doc1 = session.getBinding().getObjectService().getObject(repositoryId, testDocument.getId(), filter, Boolean.FALSE, IncludeRelationships.NONE, "cmis:none", Boolean.FALSE, Boolean.FALSE, null);
// check for change events
f = createResult(CmisTestResultStatus.WARNING, "getObject() delivered a change event, which doesn't make sense.");
addResult(assertNull(doc1.getChangeEventInfo(), null, f));
// get the test folder children
ObjectInFolderList children = session.getBinding().getNavigationService().getChildren(repositoryId, testFolder.getId(), filter, null, Boolean.FALSE, IncludeRelationships.NONE, "cmis:none", Boolean.FALSE, null, BigInteger.ZERO, null);
// check for path segments
for (ObjectInFolderData child : children.getObjects()) {
f = createResult(CmisTestResultStatus.WARNING, "getChildren() delivered a path segment, although it hasn't been requested.");
addResult(assertNull(child.getPathSegment(), null, f));
}
// get the document parent
List<ObjectParentData> parents = session.getBinding().getNavigationService().getObjectParents(repositoryId, testDocument.getId(), filter, Boolean.FALSE, IncludeRelationships.NONE, "cmis:none", Boolean.FALSE, null);
// check for relative path segments
for (ObjectParentData parent : parents) {
f = createResult(CmisTestResultStatus.WARNING, "getObjectParents() delivered a relative path segment, although it hasn't been requested.");
addResult(assertNull(parent.getRelativePathSegment(), null, f));
}
}
use of org.apache.chemistry.opencmis.tck.CmisTestResult in project copper-cms by PogeyanOSS.
the class PropertyFilterTest method run.
@Override
public void run(Session session) {
CmisTestResult f;
// filter with MIME type
OperationContext testContext1 = OperationContextUtils.createMinimumOperationContext();
Set<String> testfilter1 = new HashSet<String>(testContext1.getFilter());
testfilter1.add(PropertyIds.CONTENT_STREAM_MIME_TYPE);
testContext1.setFilter(testfilter1);
// filter with path
OperationContext testContext2 = OperationContextUtils.createMinimumOperationContext();
Set<String> testfilter2 = new HashSet<String>(testContext2.getFilter());
testfilter2.add(PropertyIds.PATH);
testContext2.setFilter(testfilter2);
// filter with invalid property
OperationContext testContext3 = OperationContextUtils.createMinimumOperationContext();
Set<String> testfilter3 = new HashSet<String>(testContext3.getFilter());
testfilter3.add(INVALID_PROPERTY);
testContext3.setFilter(testfilter3);
// create a test folder
Folder testFolder = createTestFolder(session);
try {
Document doc = createDocument(session, testFolder, "doc", CONTENT);
Document doc1 = (Document) session.getObject(doc, testContext1);
// check document
f = createResult(FAILURE, "Document should have the property " + PropertyIds.CONTENT_STREAM_MIME_TYPE + "!");
addResult(assertNotNull(doc1.getProperty(PropertyIds.CONTENT_STREAM_MIME_TYPE), null, f));
f = createResult(FAILURE, "Document should not have the property " + PropertyIds.PATH + "!");
addResult(assertNull(doc1.getProperty(PropertyIds.PATH), null, f));
f = createResult(FAILURE, "Document should not have the property " + INVALID_PROPERTY + "!");
addResult(assertNull(doc1.getProperty(INVALID_PROPERTY), null, f));
Document doc2 = (Document) session.getObject(doc, testContext2);
f = createResult(WARNING, "Document should not have the property " + PropertyIds.CONTENT_STREAM_MIME_TYPE + "!");
addResult(assertNull(doc2.getProperty(PropertyIds.CONTENT_STREAM_MIME_TYPE), null, f));
// f = createResult(FAILURE, "Document should not have the property " + PropertyIds.PATH + "!");
// addResult(assertNull(doc2.getProperty(PropertyIds.PATH), null, f));
f = createResult(FAILURE, "Document should not have the property " + INVALID_PROPERTY + "!");
addResult(assertNull(doc2.getProperty(INVALID_PROPERTY), null, f));
Document doc3 = (Document) session.getObject(doc, testContext3);
f = createResult(WARNING, "Document should not have the property" + PropertyIds.CONTENT_STREAM_MIME_TYPE + "!");
addResult(assertNull(doc3.getProperty(PropertyIds.CONTENT_STREAM_MIME_TYPE), null, f));
f = createResult(FAILURE, "Document should not have the property" + PropertyIds.PATH + "!");
addResult(assertNull(doc3.getProperty(PropertyIds.PATH), null, f));
f = createResult(FAILURE, "Document should not have the property" + INVALID_PROPERTY + "!");
addResult(assertNull(doc3.getProperty(INVALID_PROPERTY), null, f));
// check folder
Folder folder1 = (Folder) session.getObject(testFolder, testContext1);
f = createResult(FAILURE, "Folder should not have the property " + PropertyIds.CONTENT_STREAM_MIME_TYPE + "!");
addResult(assertNull(folder1.getProperty(PropertyIds.CONTENT_STREAM_MIME_TYPE), null, f));
f = createResult(WARNING, "Folder should not have the property " + PropertyIds.PATH + "!");
addResult(assertNull(folder1.getProperty(PropertyIds.PATH), null, f));
f = createResult(FAILURE, "Folder should not have the property " + INVALID_PROPERTY + "!");
addResult(assertNull(folder1.getProperty(INVALID_PROPERTY), null, f));
Folder folder2 = (Folder) session.getObject(testFolder, testContext2);
f = createResult(FAILURE, "Folder should not have the property " + PropertyIds.CONTENT_STREAM_MIME_TYPE + "!");
addResult(assertNull(folder2.getProperty(PropertyIds.CONTENT_STREAM_MIME_TYPE), null, f));
f = createResult(FAILURE, "Folder should have the property " + PropertyIds.PATH + "!");
addResult(assertNotNull(folder2.getProperty(PropertyIds.PATH), null, f));
f = createResult(FAILURE, "Folder should not have the property " + INVALID_PROPERTY + "!");
addResult(assertNull(folder2.getProperty(INVALID_PROPERTY), null, f));
Folder folder3 = (Folder) session.getObject(testFolder, testContext3);
f = createResult(FAILURE, "Folder should not have the property " + PropertyIds.CONTENT_STREAM_MIME_TYPE + "!");
addResult(assertNull(folder3.getProperty(PropertyIds.CONTENT_STREAM_MIME_TYPE), null, f));
f = createResult(WARNING, "Folder should not have the property " + PropertyIds.PATH + "!");
addResult(assertNull(folder3.getProperty(PropertyIds.PATH), null, f));
f = createResult(FAILURE, "Folder should not have the property " + INVALID_PROPERTY + "!");
addResult(assertNull(folder3.getProperty(INVALID_PROPERTY), null, f));
// check children
CmisObject obj1 = testFolder.getChildren(testContext1).iterator().next();
f = createResult(WARNING, "Child should have the property " + PropertyIds.CONTENT_STREAM_MIME_TYPE + "!");
addResult(assertNotNull(obj1.getProperty(PropertyIds.CONTENT_STREAM_MIME_TYPE), null, f));
f = createResult(WARNING, "Child should not have the property " + PropertyIds.PATH + "!");
addResult(assertNull(obj1.getProperty(PropertyIds.PATH), null, f));
f = createResult(FAILURE, "Child should not have the property " + INVALID_PROPERTY + "!");
addResult(assertNull(obj1.getProperty(INVALID_PROPERTY), null, f));
CmisObject obj2 = testFolder.getChildren(testContext2).iterator().next();
f = createResult(WARNING, "Child should not have the property " + PropertyIds.CONTENT_STREAM_MIME_TYPE + "!");
addResult(assertNull(obj2.getProperty(PropertyIds.CONTENT_STREAM_MIME_TYPE), null, f));
f = createResult(WARNING, "Child should not have the property " + PropertyIds.PATH + "!");
addResult(assertNull(obj2.getProperty(PropertyIds.PATH), null, f));
f = createResult(FAILURE, "Child should not have the property " + INVALID_PROPERTY + "!");
addResult(assertNull(obj2.getProperty(INVALID_PROPERTY), null, f));
CmisObject obj3 = testFolder.getChildren(testContext3).iterator().next();
f = createResult(WARNING, "Child should not have the property" + PropertyIds.CONTENT_STREAM_MIME_TYPE + "!");
addResult(assertNull(obj3.getProperty(PropertyIds.CONTENT_STREAM_MIME_TYPE), null, f));
f = createResult(WARNING, "Child should not have the property" + PropertyIds.PATH + "!");
addResult(assertNull(obj3.getProperty(PropertyIds.PATH), null, f));
f = createResult(FAILURE, "Child should not have the property" + INVALID_PROPERTY + "!");
addResult(assertNull(obj3.getProperty(INVALID_PROPERTY), null, f));
} finally {
// delete the test folder
deleteTestFolder();
}
}
use of org.apache.chemistry.opencmis.tck.CmisTestResult in project copper-cms by PogeyanOSS.
the class SetAndDeleteContentTest method testAppendStream.
private void testAppendStream(Session session, Folder testFolder, int bufferSize) {
CmisTestResult f;
// create an empty document
Document doc = createDocument(session, testFolder, "appendstreamtest.txt", "");
Document workDoc = doc;
boolean checkedout = false;
DocumentTypeDefinition docType = (DocumentTypeDefinition) doc.getType();
if (Boolean.TRUE.equals(docType.isVersionable())) {
workDoc = (Document) session.getObject(doc.checkOut(), SELECT_ALL_NO_CACHE_OC);
checkedout = true;
}
try {
// create an overwrite OutputStream
OutputStream out1 = workDoc.createOverwriteOutputStream("appendstreamtest", "text/plain", bufferSize);
out1.write(IOUtils.toUTF8Bytes("line 1\n"));
out1.write(IOUtils.toUTF8Bytes("line 2\n"));
out1.flush();
out1.write(IOUtils.toUTF8Bytes("line 3\n"));
out1.close();
// check document content
workDoc.refresh();
String content1 = getStringFromContentStream(workDoc.getContentStream());
f = createResult(FAILURE, "Overwrite OutputStream: wrong content!");
addResult(assertEquals("line 1\nline 2\nline 3\n", content1, null, f));
// create an append OutputStream
OutputStream out2 = workDoc.createAppendOutputStream(bufferSize);
out2.write(IOUtils.toUTF8Bytes("line 4\n"));
out2.write(IOUtils.toUTF8Bytes("line 5\n"));
out2.flush();
out2.write(IOUtils.toUTF8Bytes("line 6\n"));
out2.close();
// check document content
workDoc.refresh();
String content2 = getStringFromContentStream(workDoc.getContentStream());
f = createResult(FAILURE, "Overwrite OutputStream: wrong content!");
addResult(assertEquals("line 1\nline 2\nline 3\nline 4\nline 5\nline 6\n", content2, null, f));
} catch (IOException e) {
addResult(createResult(UNEXPECTED_EXCEPTION, "Appending content via an OutputStream failed! Exception: " + e.getMessage(), e, false));
} finally {
// cancel a possible check out
if (checkedout) {
workDoc.cancelCheckOut();
}
// remove the document
deleteObject(doc);
}
}
use of org.apache.chemistry.opencmis.tck.CmisTestResult in project copper-cms by PogeyanOSS.
the class UpdateSmokeTest method updateDocument.
private void updateDocument(Session session, Folder testFolder) {
CmisTestResult f;
// create document
Document doc1 = createDocument(session, testFolder, DOC_NAME1, "rename me!");
Document workDoc = doc1;
f = createResult(FAILURE, "Document name doesn't match the given name!");
addResult(assertEquals(DOC_NAME1, doc1.getName(), null, f));
// test if check out is required
boolean checkedout = false;
DocumentTypeDefinition type = (DocumentTypeDefinition) doc1.getType();
PropertyDefinition<?> namePropDef = type.getPropertyDefinitions().get(PropertyIds.NAME);
if (namePropDef.getUpdatability() == Updatability.WHENCHECKEDOUT || (!doc1.getAllowableActions().getAllowableActions().contains(Action.CAN_UPDATE_PROPERTIES) && Boolean.TRUE.equals(type.isVersionable()))) {
workDoc = (Document) session.getObject(doc1.checkOut(), SELECT_ALL_NO_CACHE_OC);
checkedout = true;
}
// update
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.NAME, DOC_NAME2);
ObjectId newId = workDoc.updateProperties(properties, false);
Document doc2 = (Document) session.getObject(newId, SELECT_ALL_NO_CACHE_OC);
addResult(checkObject(session, doc2, getAllProperties(doc2), "Updated document compliance"));
f = createResult(FAILURE, "Document name doesn't match updated value!");
addResult(assertEquals(DOC_NAME2, doc2.getName(), null, f));
// delete
if (!workDoc.getId().equals(doc2.getId())) {
deleteObject(doc2);
}
// cancel a possible check out
if (checkedout) {
workDoc.cancelCheckOut();
}
if (!doc1.getId().equals(doc2.getId())) {
if (exists(doc1)) {
deleteObject(doc1);
}
}
}
Aggregations