use of org.apache.chemistry.opencmis.tck.CmisTestResult in project copper-cms by PogeyanOSS.
the class TextReport method printTestResults.
private void printTestResults(CmisTest test, Writer writer) throws IOException {
if (!test.isEnabled()) {
return;
}
writer.write("---------------------------------------------------------------" + NL);
writer.write(test.getName() + " (" + test.getTime() + " ms)" + NL);
writer.write("---------------------------------------------------------------" + NL + NL);
if (test.getResults() != null) {
for (CmisTestResult result : test.getResults()) {
printResult(1, result, writer);
writer.write(NL);
}
}
writer.write(NL);
}
use of org.apache.chemistry.opencmis.tck.CmisTestResult in project copper-cms by PogeyanOSS.
the class XmlReport method printTestResults.
private void printTestResults(CmisTest test, XMLStreamWriter xml) throws Exception {
if (!test.isEnabled()) {
return;
}
xml.writeStartElement(TAG_TEST);
xml.writeAttribute(ATTR_NAME, test.getName());
xml.writeAttribute(ATTR_TIME, String.valueOf(test.getTime()));
if (test.getResults() != null) {
for (CmisTestResult result : test.getResults()) {
printResult(result, xml);
}
}
xml.writeEndElement();
}
use of org.apache.chemistry.opencmis.tck.CmisTestResult in project copper-cms by PogeyanOSS.
the class RootFolderTest method run.
@Override
public void run(Session session) throws Exception {
CmisTestResult success;
CmisTestResult failure;
// check root folder id
RepositoryInfo ri = getRepositoryInfo(session);
success = createResult(OK, "Root folder id: " + ri.getRootFolderId());
failure = createResult(FAILURE, "Root folder id is not set!");
addResult(assertStringNotEmpty(ri.getRootFolderId(), success, failure));
// get the root folder
Folder rootFolder = session.getRootFolder(SELECT_ALL_NO_CACHE_OC);
if (rootFolder == null) {
addResult(createResult(FAILURE, "Root folder is not available!"));
return;
}
// check existence
failure = createResult(FAILURE, "Root folder doesn't exist?!");
addResult(assertIsTrue(session.exists(ri.getRootFolderId()), null, failure));
// check folder object
addResult(checkObject(session, rootFolder, getAllProperties(rootFolder), "Root folder object spec compliance"));
// folder and path
failure = createResult(FAILURE, "Root folder id in the repository info doesn't match the root folder object id!");
addResult(assertEquals(ri.getRootFolderId(), rootFolder.getId(), null, failure));
failure = createResult(FAILURE, "Root folder is not a cmis:folder!");
addResult(assertEquals(BaseTypeId.CMIS_FOLDER, rootFolder.getBaseTypeId(), null, failure));
failure = createResult(FAILURE, "Root folder path is not '/'!");
addResult(assertEquals("/", rootFolder.getPath(), null, failure));
failure = createResult(FAILURE, "Root folder has parents!");
addResult(assertEquals(0, rootFolder.getParents().size(), null, failure));
// allowable actions
failure = createResult(FAILURE, "Root folder has CAN_GET_FOLDER_PARENT allowable action!");
addResult(assertNotAllowableAction(rootFolder, Action.CAN_GET_FOLDER_PARENT, null, failure));
failure = createResult(WARNING, "Root folder has no CAN_GET_CHILDREN allowable action!");
addResult(assertAllowableAction(rootFolder, Action.CAN_GET_CHILDREN, null, failure));
// simple children test
addResult(checkChildren(session, rootFolder, "Root folder children check"));
}
use of org.apache.chemistry.opencmis.tck.CmisTestResult in project copper-cms by PogeyanOSS.
the class SecurityTest method run.
@Override
public void run(Session session) throws Exception {
CmisTestResult f;
BindingType binding = getBinding();
addResult(createInfoResult("Binding: " + binding));
f = createResult(WARNING, "HTTPS is not used. Credentials might be transferred as plain text!");
switch(binding) {
case ATOMPUB:
if (!isHttpsUrl(getParameters().get(SessionParameter.ATOMPUB_URL))) {
addResult(f);
}
break;
case WEBSERVICES:
if (!isHttpsUrl(getParameters().get(SessionParameter.WEBSERVICES_REPOSITORY_SERVICE))) {
addResult(f);
}
break;
case BROWSER:
if (!isHttpsUrl(getParameters().get(SessionParameter.BROWSER_URL))) {
addResult(f);
}
break;
default:
}
}
use of org.apache.chemistry.opencmis.tck.CmisTestResult in project copper-cms by PogeyanOSS.
the class AsyncCreateAndDeleteFolderTest method run.
@Override
public void run(Session session) {
CmisTestResult f;
int numOfFolders = 100;
// create an async session
AsyncSession asyncSession = AsyncSessionFactoryImpl.newInstance().createAsyncSession(session, 10);
// create a test folder
Folder testFolder = createTestFolder(session);
try {
// create folders
List<Future<ObjectId>> folderFutures = new ArrayList<Future<ObjectId>>();
for (int i = 0; i < numOfFolders; i++) {
String name = "asyncfolder" + i;
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.NAME, name);
properties.put(PropertyIds.OBJECT_TYPE_ID, getFolderTestTypeId());
Future<ObjectId> newFolder = asyncSession.createFolder(properties, testFolder);
folderFutures.add(newFolder);
}
// wait for all folders being created
List<ObjectId> folderIds = new ArrayList<ObjectId>();
try {
for (Future<ObjectId> folderFuture : folderFutures) {
ObjectId id = folderFuture.get();
folderIds.add(id);
}
} catch (Exception e) {
addResult(createResult(UNEXPECTED_EXCEPTION, "Folder could not been created! Exception: " + e.getMessage(), e, true));
}
// check children of test folder
int count = countChildren(testFolder);
f = createResult(FAILURE, "Test folder should have " + numOfFolders + " children but has " + count + "!");
addResult(assertEquals(count, numOfFolders, null, f));
// get folders
Map<String, Future<CmisObject>> getObjectFutures = new HashMap<String, Future<CmisObject>>();
for (ObjectId folderId : folderIds) {
Future<CmisObject> getObjectFuture = asyncSession.getObject(folderId, SELECT_ALL_NO_CACHE_OC);
getObjectFutures.put(folderId.getId(), getObjectFuture);
}
// wait for all folders being fetched
List<String> paths = new ArrayList<String>();
try {
for (Map.Entry<String, Future<CmisObject>> getObjectFuture : getObjectFutures.entrySet()) {
CmisObject object = getObjectFuture.getValue().get();
f = createResult(FAILURE, "Fetching folder failed!");
addResult(assertIsTrue(object instanceof Folder, null, f));
if (object != null) {
f = createResult(FAILURE, "Fetched wrong folder!");
addResult(assertEquals(getObjectFuture.getKey(), object.getId(), null, f));
paths.add(((Folder) object).getPath());
}
}
} catch (Exception e) {
addResult(createResult(UNEXPECTED_EXCEPTION, "Folders could not been fetched! Exception: " + e.getMessage(), e, true));
}
// get folders by path
Map<String, Future<CmisObject>> getObjectByPathFutures = new HashMap<String, Future<CmisObject>>();
for (String path : paths) {
Future<CmisObject> getObjectByPathFuture = asyncSession.getObjectByPath(path, SELECT_ALL_NO_CACHE_OC);
getObjectByPathFutures.put(path, getObjectByPathFuture);
}
// wait for all folders being fetched
try {
for (Map.Entry<String, Future<CmisObject>> getObjectByPathFuture : getObjectByPathFutures.entrySet()) {
CmisObject object = getObjectByPathFuture.getValue().get();
f = createResult(FAILURE, "Fetching folder failed!");
addResult(assertIsTrue(object instanceof Folder, null, f));
if (object != null) {
f = createResult(FAILURE, "Fetched wrong folder!");
addResult(assertEquals(getObjectByPathFuture.getKey(), ((Folder) object).getPath(), null, f));
}
}
} catch (Exception e) {
addResult(createResult(UNEXPECTED_EXCEPTION, "Folders could not been fetched! Exception: " + e.getMessage(), e, true));
}
// delete folders
List<Future<?>> delFutures = new ArrayList<Future<?>>();
for (ObjectId folderId : folderIds) {
Future<?> delFuture = asyncSession.deleteTree(folderId, true, UnfileObject.DELETE, true);
delFutures.add(delFuture);
}
// wait for all folders being deleted
try {
for (Future<?> delFuture : delFutures) {
delFuture.get();
}
} catch (Exception e) {
addResult(createResult(UNEXPECTED_EXCEPTION, "Folder could not been deleted! Exception: " + e.getMessage(), e, true));
}
// check children of test folder
count = countChildren(testFolder);
f = createResult(FAILURE, "Test folder should be empty but has " + count + " children!");
addResult(assertEquals(count, 0, null, f));
} finally {
// delete the test folder
deleteTestFolder();
if (asyncSession instanceof AbstractExecutorServiceAsyncSession<?>) {
((AbstractExecutorServiceAsyncSession<?>) asyncSession).shutdown();
}
}
addResult(createInfoResult("Tested the parallel creation and deletion of " + numOfFolders + " folders."));
}
Aggregations