use of org.apache.chemistry.opencmis.tck.CmisTestResult in project copper-cms by PogeyanOSS.
the class BulkUpdatePropertiesTest method run.
@Override
public void run(Session session) {
if (session.getRepositoryInfo().getCmisVersion() == CmisVersion.CMIS_1_0) {
addResult(createResult(SKIPPED, "Bulk Update Properties is not supported by CMIS 1.0. Test skipped!"));
return;
}
CmisTestResult failure = null;
int numOfObjects = 20;
// create a test folder
Folder testFolder = createTestFolder(session);
try {
Map<String, Folder> folders = new HashMap<String, Folder>();
Map<String, Document> documents = new HashMap<String, Document>();
// create folders and documents
for (int i = 0; i < numOfObjects; i++) {
Folder newFolder = createFolder(session, testFolder, "bufolder" + i);
folders.put(newFolder.getId(), newFolder);
Document newDocument = createDocument(session, newFolder, "budoc" + i + ".txt", CONTENT);
documents.put(newDocument.getId(), newDocument);
}
// update cmis:name of all the documents
List<CmisObject> objects = new ArrayList<CmisObject>(documents.values());
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.NAME, NEW_NAME);
List<BulkUpdateObjectIdAndChangeToken> updatedIds = session.bulkUpdateProperties(objects, properties, null, null);
// check the result
if (getBinding() == BindingType.WEBSERVICES) {
// TODO: review after TC clarification
addResult(createResult(INFO, "The Web Services binding does not return the updated ids." + " This issue has to be clarified by the CMIS TC and the test to adopted later."));
} else {
if (updatedIds == null || updatedIds.isEmpty()) {
addResult(createResult(FAILURE, "Bulk Update Properties did not update any documents!"));
} else {
failure = createResult(FAILURE, "Bulk Update Properties did not update all test documents!");
addResult(assertEquals(documents.size(), updatedIds.size(), null, failure));
}
}
// check all documents
for (Folder folder : folders.values()) {
List<CmisObject> children = new ArrayList<CmisObject>();
for (CmisObject child : folder.getChildren(SELECT_ALL_NO_CACHE_OC)) {
children.add(child);
}
if (children.size() != 1) {
addResult(createResult(FAILURE, "Test folder should have exactly one child, but it has " + children.size() + "!"));
} else {
failure = createResult(FAILURE, "Document does not have the new name! Id: " + children.get(0).getId());
addResult(assertEquals(NEW_NAME, children.get(0).getName(), null, failure));
}
}
// delete folders and documents
for (Folder folder : folders.values()) {
folder.deleteTree(true, null, true);
}
} finally {
// delete the test folder
deleteTestFolder();
}
}
use of org.apache.chemistry.opencmis.tck.CmisTestResult in project copper-cms by PogeyanOSS.
the class CreateAndDeleteTypeTest method createDocumentTypeDefinition.
private DocumentTypeDefinitionImpl createDocumentTypeDefinition(Session session, String typeId, ObjectType parentType) {
CmisTestResult failure = null;
NewTypeSettableAttributes settableAttributes = session.getRepositoryInfo().getCapabilities().getNewTypeSettableAttributes();
if (settableAttributes == null) {
addResult(createResult(WARNING, "Capability NewTypeSettableAttributes is not set!"));
}
DocumentTypeDefinitionImpl result = new DocumentTypeDefinitionImpl();
result.setBaseTypeId(parentType.getBaseTypeId());
result.setParentTypeId(parentType.getId());
if (settableAttributes == null || Boolean.TRUE.equals(settableAttributes.canSetId())) {
result.setId(typeId);
} else if (settableAttributes != null) {
failure = createResult(WARNING, "Flag 'id' in capability NewTypeSettableAttributes is not set!");
addResult(assertNotNull(settableAttributes.canSetId(), null, failure));
}
if (settableAttributes == null || Boolean.TRUE.equals(settableAttributes.canSetLocalName())) {
result.setLocalName("tck:testlocal");
} else if (settableAttributes != null) {
failure = createResult(WARNING, "Flag 'localName' in capability NewTypeSettableAttributes is not set!");
addResult(assertNotNull(settableAttributes.canSetLocalName(), null, failure));
}
if (settableAttributes == null || Boolean.TRUE.equals(settableAttributes.canSetLocalNamespace())) {
result.setLocalNamespace("http://tck/testlocalnamespace");
} else if (settableAttributes != null) {
failure = createResult(WARNING, "Flag 'localNamespace' in capability NewTypeSettableAttributes is not set!");
addResult(assertNotNull(settableAttributes.canSetLocalNamespace(), null, failure));
}
if (settableAttributes == null || Boolean.TRUE.equals(settableAttributes.canSetDisplayName())) {
result.setDisplayName("TCK Document Type");
} else if (settableAttributes != null) {
failure = createResult(WARNING, "Flag 'displayName' in capability NewTypeSettableAttributes is not set!");
addResult(assertNotNull(settableAttributes.canSetDisplayName(), null, failure));
}
if (settableAttributes == null || Boolean.TRUE.equals(settableAttributes.canSetDescription())) {
result.setDescription("This is the TCK document type");
} else if (settableAttributes != null) {
failure = createResult(WARNING, "Flag 'description' in capability NewTypeSettableAttributes is not set!");
addResult(assertNotNull(settableAttributes.canSetDescription(), null, failure));
}
if (settableAttributes == null || Boolean.TRUE.equals(settableAttributes.canSetQueryName())) {
result.setQueryName("tck:testqueryname");
} else if (settableAttributes != null) {
failure = createResult(WARNING, "Flag 'queryName' in capability NewTypeSettableAttributes is not set!");
addResult(assertNotNull(settableAttributes.canSetQueryName(), null, failure));
}
if (settableAttributes == null || Boolean.TRUE.equals(settableAttributes.canSetQueryable())) {
result.setIsQueryable(false);
} else if (settableAttributes != null) {
failure = createResult(WARNING, "Flag 'queryable' in capability NewTypeSettableAttributes is not set!");
addResult(assertNotNull(settableAttributes.canSetQueryable(), null, failure));
}
if (settableAttributes == null || Boolean.TRUE.equals(settableAttributes.canSetFulltextIndexed())) {
result.setIsFulltextIndexed(false);
} else if (settableAttributes != null) {
failure = createResult(WARNING, "Flag 'fulltextIndexed' in capability NewTypeSettableAttributes is not set!");
addResult(assertNotNull(settableAttributes.canSetFulltextIndexed(), null, failure));
}
if (settableAttributes == null || Boolean.TRUE.equals(settableAttributes.canSetIncludedInSupertypeQuery())) {
result.setIsIncludedInSupertypeQuery(false);
} else if (settableAttributes != null) {
failure = createResult(WARNING, "Flag 'includedInSupertypeQuery' in capability NewTypeSettableAttributes is not set!");
addResult(assertNotNull(settableAttributes.canSetIncludedInSupertypeQuery(), null, failure));
}
if (settableAttributes == null || Boolean.TRUE.equals(settableAttributes.canSetControllableAcl())) {
result.setIsControllableAcl(false);
} else if (settableAttributes != null) {
failure = createResult(WARNING, "Flag 'controllableACL' in capability NewTypeSettableAttributes is not set!");
addResult(assertNotNull(settableAttributes.canSetControllableAcl(), null, failure));
}
if (settableAttributes == null || Boolean.TRUE.equals(settableAttributes.canSetControllablePolicy())) {
result.setIsControllablePolicy(false);
} else if (settableAttributes != null) {
failure = createResult(WARNING, "Flag 'controllablePolicy' in capability NewTypeSettableAttributes is not set!");
addResult(assertNotNull(settableAttributes.canSetControllablePolicy(), null, failure));
}
if (settableAttributes == null || Boolean.TRUE.equals(settableAttributes.canSetCreatable())) {
result.setIsCreatable(true);
} else if (settableAttributes != null) {
failure = createResult(WARNING, "Flag 'creatable' in capability NewTypeSettableAttributes is not set!");
addResult(assertNotNull(settableAttributes.canSetCreatable(), null, failure));
}
if (settableAttributes == null || Boolean.TRUE.equals(settableAttributes.canSetFileable())) {
result.setIsFileable(true);
} else if (settableAttributes != null) {
failure = createResult(WARNING, "Flag 'fileable' in capability NewTypeSettableAttributes is not set!");
addResult(assertNotNull(settableAttributes.canSetFileable(), null, failure));
}
result.setIsVersionable(false);
result.setContentStreamAllowed(ContentStreamAllowed.ALLOWED);
return result;
}
use of org.apache.chemistry.opencmis.tck.CmisTestResult in project copper-cms by PogeyanOSS.
the class CreateAndDeleteTypeTest method createTypeWithProperties.
private void createTypeWithProperties(Session session, ObjectType parentType) {
CmisTestResult failure = null;
CreatablePropertyTypes cpt = session.getRepositoryInfo().getCapabilities().getCreatablePropertyTypes();
if (cpt == null || cpt.canCreate() == null || cpt.canCreate().isEmpty()) {
addResult(createResult(FAILURE, "Repository Info does not indicate, which property types can be created!"));
return;
}
// define the type
DocumentTypeDefinitionImpl newTypeDef = createDocumentTypeDefinition(session, "tck:testid_with_properties", parentType);
// add a property for each creatable property type
for (PropertyType propType : PropertyType.values()) {
if (!cpt.canCreate().contains(propType)) {
continue;
}
newTypeDef.addPropertyDefinition(createPropertyDefinition(propType));
}
// create the type
ObjectType newType = createType(session, newTypeDef);
if (newType == null) {
return;
}
// get the type
ObjectType newType2 = null;
try {
newType2 = session.getTypeDefinition(newType.getId());
// assert type definitions
failure = createResult(FAILURE, "The type definition returned by createType() doesn't match the type definition returned by getTypeDefinition()!");
addResult(assertEquals(newType, newType2, null, failure));
} catch (CmisObjectNotFoundException e) {
addResult(createResult(FAILURE, "Newly created type can not be fetched. Id: " + newType.getId(), e, false));
}
// check properties
List<PropertyDefinition<?>> newPropDefs = new ArrayList<PropertyDefinition<?>>();
for (Map.Entry<String, PropertyDefinition<?>> propDef : newType.getPropertyDefinitions().entrySet()) {
if (Boolean.FALSE.equals(propDef.getValue().isInherited())) {
newPropDefs.add(propDef.getValue());
}
}
failure = createResult(FAILURE, "The number of defined properties and the number of non-inherited properties don't match!");
addResult(assertEquals(newTypeDef.getPropertyDefinitions().size(), newPropDefs.size(), null, failure));
// check the order of the properties, which must match the order of the
// original type definition
// (OpenCMIS keeps the order of the property definitions.)
int i = 0;
for (Map.Entry<String, PropertyDefinition<?>> propDef : newTypeDef.getPropertyDefinitions().entrySet()) {
PropertyDefinition<?> newPropDef = newPropDefs.get(i);
failure = createResult(FAILURE, "Property " + (i + 1) + " must be of type " + propDef.getValue().getPropertyType() + " but is of type " + newPropDef.getPropertyType() + "!");
addResult(assertEquals(propDef.getValue().getPropertyType(), newPropDef.getPropertyType(), null, failure));
addResult(createInfoResult("Repository assigned the property '" + propDef.getValue().getId() + "' the following property id: " + newPropDef.getId()));
i++;
}
// delete the type
deleteType(session, newType.getId());
}
use of org.apache.chemistry.opencmis.tck.CmisTestResult in project copper-cms by PogeyanOSS.
the class SecondaryTypesTest method checkSecondaryType.
private boolean checkSecondaryType(Document doc, ObjectType secondaryTestType) {
CmisTestResult f;
// check if the secondary type is there
boolean found = false;
if (doc.getSecondaryTypes() == null) {
addResult(createResult(FAILURE, "Document does not have the attached secondary type!"));
} else {
for (SecondaryType secType : doc.getSecondaryTypes()) {
if (secondaryTestType.getId().equals(secType.getId())) {
found = true;
break;
}
}
f = createResult(FAILURE, "Document does not have the attached secondary type!");
addResult(assertIsTrue(found, null, f));
}
// check properties of secondary type
if (found) {
Set<String> secondaryTypeProperties = new HashSet<String>();
if (secondaryTestType.getPropertyDefinitions() != null) {
for (PropertyDefinition<?> propDef : secondaryTestType.getPropertyDefinitions().values()) {
secondaryTypeProperties.add(propDef.getId());
}
}
for (Property<?> prop : doc.getProperties()) {
secondaryTypeProperties.remove(prop.getId());
}
f = createResult(FAILURE, "Documents lacks the following secondary type properties: " + secondaryTypeProperties);
addResult(assertIsTrue(secondaryTypeProperties.isEmpty(), null, f));
}
return found;
}
use of org.apache.chemistry.opencmis.tck.CmisTestResult in project copper-cms by PogeyanOSS.
the class CheckedOutTest method checkPWCs.
private int checkPWCs(Session session, ItemIterable<Document> pwcs, boolean checkOrder) {
if (pwcs == null) {
return 0;
}
CmisTestResult f;
int i = 0;
int orderByNameIssues = 0;
String lastName = null;
for (Document pwc : pwcs) {
if (pwc == null) {
addResult(createResult(FAILURE, "The list of checked out documents contains a null entry!"));
continue;
}
String[] propertiesToCheck = getAllProperties(pwc);
addResult(checkObject(session, pwc, propertiesToCheck, "PWC check: " + pwc.getId()));
if (session.getRepositoryInfo().getCmisVersion() == CmisVersion.CMIS_1_0) {
f = createResult(WARNING, "PWC is not the latest version! Id: " + pwc.getId() + " (Note: The words of the CMIS specification define that the PWC is the latest version." + " But that is not the intention of the spec and will be changed in CMIS 1.1." + " Thus this a warning, not an error.)");
addResult(assertIsTrue(pwc.isLatestVersion(), null, f));
} else {
f = createResult(FAILURE, "The property value of 'cmis:isLatestVersion' is TRUE for a PWC! Id: " + pwc.getId());
addResult(assertIsFalse(pwc.isLatestVersion(), null, f));
f = createResult(FAILURE, "The property value of 'cmis:isLatestMajorVersion' is TRUE for a PWC! Id: " + pwc.getId());
addResult(assertIsFalse(pwc.isLatestMajorVersion(), null, f));
}
if (lastName != null && pwc.getName() != null) {
if (pwc.getName().compareToIgnoreCase(lastName) < 0) {
orderByNameIssues++;
}
}
lastName = pwc.getName();
i++;
}
if (checkOrder) {
f = createResult(WARNING, "Checked-out documents should be ordered by cmis:name, but they are not! (It might be a collation mismatch.)");
addResult(assertEquals(0, orderByNameIssues, null, f));
} else {
addResult(createResult(INFO, "Repository doesn't support Order By for getCheckedOutDocs()."));
}
return i;
}
Aggregations