/** * Creates a test folder. */ protected Folder createTestFolder(Session session) { String testFolderParentPath = getParameters().get(TestParameters.DEFAULT_TEST_FOLDER_PARENT); if (testFolderParentPath == null) { testFolderParentPath = TestParameters.DEFAULT_TEST_FOLDER_PARENT_VALUE; } String name = "cmistck" + System.currentTimeMillis() + session.getRepositoryInfo().hashCode(); Folder parent = null; try { CmisObject parentObject = session.getObjectByPath(testFolderParentPath, SELECT_ALL_NO_CACHE_OC); if (!(parentObject instanceof Folder)) { addResult(createResult(FAILURE, "Parent folder of the test folder is actually not a folder! Path: " + testFolderParentPath, true)); } parent = (Folder) parentObject; } catch (CmisBaseException e) { addResult(createResult(UNEXPECTED_EXCEPTION, "Test folder could not be created! Exception: " + e.getMessage(), e, true)); } if (parent != null) { testFolder = createFolder(session, parent, name); } return testFolder; }
} catch (CmisBaseException e) { addResult(createResult(UNEXPECTED_EXCEPTION, "Newly created document is invalid! Exception: " + e.getMessage(), e, true));
/** * Deletes an object and checks if it is deleted. */ protected void deleteObject(CmisObject object) { if (object != null) { if (object instanceof Folder) { try { ((Folder) object).deleteTree(true, null, true); } catch (CmisBaseException e) { addResult(createResult(UNEXPECTED_EXCEPTION, "Folder could not be deleted! Exception: " + e.getMessage(), e, true)); } } else { try { object.delete(true); } catch (CmisBaseException e) { addResult(createResult(UNEXPECTED_EXCEPTION, "Object could not be deleted! Exception: " + e.getMessage(), e, true)); } } CmisTestResult f = createResult(FAILURE, "Object should not exist anymore but it is still there! ID: " + object.getId(), true); addResult(assertIsFalse(exists(object), null, f)); } }
addResult(createResult(UNEXPECTED_EXCEPTION, "Item could not be created! Exception: " + e.getMessage(), e, true)); return null; addResult(createResult(UNEXPECTED_EXCEPTION, "Newly created item is invalid! Exception: " + e.getMessage(), e, true));
addResult(createResult(UNEXPECTED_EXCEPTION, "Policy could not be created! Exception: " + e.getMessage(), e, true)); return null; } catch (CmisBaseException e) { addResult(createResult(UNEXPECTED_EXCEPTION, "Newly created policy is invalid! Exception: " + e.getMessage(), e, true));
addResult(createResult(UNEXPECTED_EXCEPTION, "Folder could not be created! Exception: " + e.getMessage(), e, true)); return null; "Newly created folder is invalid! Exception: " + e.getMessage(), e, true));
"Newly created document is invalid! Exception: " + e.getMessage(), e, true));
} catch (CmisBaseException e) { addResult(createResult(FAILURE, inWhat + " query failed: " + e.getClass().getSimpleName() + ": " + e.getMessage(), e, false));
session.deleteType(typeId); } catch (CmisBaseException e) { addResult(createResult(FAILURE, "Deleting type '" + typeId + "' failed: " + e.getMessage(), e, false)); return;
/** * Creates a new type. */ protected ObjectType createType(Session session, TypeDefinition typeDef) { NewTypeSettableAttributes settableAttributes = session.getRepositoryInfo().getCapabilities() .getNewTypeSettableAttributes(); if (settableAttributes == null) { addResult(createResult(WARNING, "Repository Info does not indicate, which type attributes can be set!")); } else { // TODO: add more tests } ObjectType newType = null; try { newType = session.createType(typeDef); addResult(createInfoResult("Created type '" + typeDef.getId() + "'. Repository assigned the following type ID: " + newType.getId())); } catch (CmisBaseException e) { addResult(createResult(FAILURE, "Creating type '" + typeDef.getId() + "' failed: " + e.getMessage(), e, false)); return null; } addResult(checkTypeDefinition(session, newType, "Newly created type spec compliance.")); if (newType.getTypeMutability() == null) { addResult(createResult(FAILURE, "Newly created type does not provide type mutability data! ID: " + newType.getId())); } return newType; }