use of org.apache.chemistry.opencmis.tck.CmisTestResult in project copper-cms by PogeyanOSS.
the class CreateAndDeleteItemTest method run.
@Override
public void run(Session session) {
if (session.getRepositoryInfo().getCmisVersion() == CmisVersion.CMIS_1_0) {
addResult(createResult(SKIPPED, "Items are not supported by CMIS 1.0. Test skipped!"));
return;
}
if (hasItems(session)) {
CmisTestResult f;
int numOfItems = 20;
// create a test folder
Folder testFolder = createTestFolder(session);
try {
Map<String, Item> items = new HashMap<String, Item>();
// create items
for (int i = 0; i < numOfItems; i++) {
Item newItem = createItem(session, testFolder, "item" + i);
items.put(newItem.getId(), newItem);
}
// check if all items are there
ItemIterable<CmisObject> children = testFolder.getChildren(SELECT_ALL_NO_CACHE_OC);
List<String> childrenIds = new ArrayList<String>();
for (CmisObject child : children) {
if (child != null) {
childrenIds.add(child.getId());
Item item = items.get(child.getId());
f = createResult(FAILURE, "Item and test folder child don't match! Id: " + child.getId());
addResult(assertShallowEquals(item, child, null, f));
}
}
f = createResult(FAILURE, "Number of created items does not match the number of existing items!");
addResult(assertEquals(numOfItems, childrenIds.size(), null, f));
for (Item item : items.values()) {
if (!childrenIds.contains(item.getId())) {
addResult(createResult(FAILURE, "Created item not found in test folder children! Id: " + item.getId()));
}
}
// delete all item
for (Item item : items.values()) {
item.delete(true);
f = createResult(FAILURE, "Item should not exist anymore but it is still there! Id: " + item.getId());
addResult(assertIsFalse(exists(item), null, f));
}
} finally {
// delete the test folder
deleteTestFolder();
}
addResult(createInfoResult("Tested the creation and deletion of " + numOfItems + " items."));
} else {
addResult(createResult(SKIPPED, "Items not supported. Test skipped!"));
}
}
use of org.apache.chemistry.opencmis.tck.CmisTestResult in project copper-cms by PogeyanOSS.
the class CreateDocumentWithoutContent method run.
@Override
public void run(Session session) {
CmisTestResult f;
String objectTypeId = getDocumentTestTypeId();
TypeDefinition type = session.getTypeDefinition(objectTypeId);
if (!(type instanceof DocumentTypeDefinition)) {
addResult(createResult(FAILURE, "Type is not a document type! Type: " + objectTypeId, true));
return;
}
DocumentTypeDefinition docType = (DocumentTypeDefinition) type;
if (docType.getContentStreamAllowed() == ContentStreamAllowed.REQUIRED) {
addResult(createResult(SKIPPED, "The test document type does not support documents without content. Test skipped!"));
return;
}
// create a test folder
Folder testFolder = createTestFolder(session);
try {
String name = "nocontent";
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.NAME, name);
properties.put(PropertyIds.OBJECT_TYPE_ID, objectTypeId);
VersioningState versioningState = (Boolean.TRUE.equals(docType.isVersionable()) ? VersioningState.MAJOR : VersioningState.NONE);
// create and fetch the document
ObjectId id = session.createDocument(properties, testFolder, null, versioningState);
Document doc = (Document) session.getObject(id, SELECT_ALL_NO_CACHE_OC);
// check the new document
addResult(checkObject(session, doc, getAllProperties(doc), "New document object spec compliance"));
// check the MIME type
f = createResult(FAILURE, "The document has no content but a MIME type!", true);
assertNull(doc.getContentStreamMimeType(), null, f);
// check the content size
if (doc.getContentStreamLength() == 0) {
addResult(createResult(WARNING, "The document has no content but the content length is set to 0! " + "The content length shouldn't be set."));
} else if (doc.getContentStreamLength() > 0) {
addResult(createResult(FAILURE, "The document has no content but the content length is set and >0! " + "(content length: " + doc.getContentStreamLength() + ")"));
}
// delete it
doc.delete(true);
} finally {
// delete the test folder
deleteTestFolder();
}
}
use of org.apache.chemistry.opencmis.tck.CmisTestResult in project copper-cms by PogeyanOSS.
the class CoreHtmlReport method printResult.
private void printResult(CmisTestResult result, Writer writer) throws IOException {
stackTraceCounter++;
String stackTraceId = "tckTrace" + stackTraceCounter;
String exceptionId = "tckException" + stackTraceCounter;
boolean hasStackTrace = result.getStackTrace() != null && result.getStackTrace().length > 0;
boolean hasException = result.getStatus() == CmisTestResultStatus.UNEXPECTED_EXCEPTION && result.getException() != null;
writer.write("<div class=\"tckResult" + result.getStatus().name() + "\">\n");
writer.write("<b>" + result.getStatus() + "</b>: " + escape(result.getMessage()));
if (hasStackTrace) {
writer.write(" (" + getSourceCodeLink(result.getStackTrace()[0], revision) + ")");
writer.write(" [<span class=\"tckTraceLink\" onClick=\"tckToggleDisplay('" + stackTraceId + "');\">stacktrace</span>]");
}
if (hasException) {
writer.write(" [<span class=\"tckTraceLink\" onClick=\"tckToggleDisplay('" + exceptionId + "');\">exception details</span>]");
}
writer.write("<br/>\n");
if (hasStackTrace) {
writer.write("<div class=\"tckTrace\" id=\"" + stackTraceId + "\" style=\"display:none\">\n");
for (StackTraceElement ste : result.getStackTrace()) {
if (AbstractRunner.class.getName().equals(ste.getClassName())) {
break;
}
writer.write(ste.getClassName() + "." + ste.getMethodName() + "(" + getSourceCodeLink(ste, revision) + ")<br/>\n");
}
writer.write("</div>\n");
}
if (hasException) {
writer.write("<div class=\"tckTrace\" id=\"" + exceptionId + "\" style=\"display:none\">\n");
writer.write("<b>Exception stack trace:</b><br/><br/>\n");
for (StackTraceElement ste : result.getException().getStackTrace()) {
if (AbstractRunner.class.getName().equals(ste.getClassName())) {
break;
}
writer.write(ste.getClassName() + "." + ste.getMethodName() + "(" + getSourceCodeLink(ste, revision) + ")<br/>\n");
}
if (result.getException() instanceof CmisBaseException) {
CmisBaseException cbe = (CmisBaseException) result.getException();
if (cbe.getErrorContent() != null) {
writer.write("<br/>\n<b>Error content:</b><br/><br/><pre>\n");
writer.write(escape(cbe.getErrorContent()) + "</pre>\n");
}
}
writer.write("</div>\n");
}
for (CmisTestResult child : result.getChildren()) {
printResult(child, writer);
}
writer.write("</div>\n");
}
use of org.apache.chemistry.opencmis.tck.CmisTestResult in project copper-cms by PogeyanOSS.
the class JsonReport method printTestResults.
private void printTestResults(CmisTest test, JSONArray jsonTests) throws IOException {
if (!test.isEnabled()) {
return;
}
JSONObject jsonTest = new JSONObject();
jsonTests.add(jsonTest);
jsonTest.put("name", test.getName());
jsonTest.put("time", test.getTime());
if (test.getResults() != null && !test.getResults().isEmpty()) {
JSONArray jsonResults = new JSONArray();
jsonTest.put("results", jsonResults);
for (CmisTestResult result : test.getResults()) {
printResult(result, jsonResults);
}
}
}
use of org.apache.chemistry.opencmis.tck.CmisTestResult in project copper-cms by PogeyanOSS.
the class JsonReport method printResult.
private void printResult(CmisTestResult result, JSONArray results) throws IOException {
JSONObject jsonResult = new JSONObject();
results.add(jsonResult);
jsonResult.put("status", result.getStatus().toString());
jsonResult.put("message", result.getMessage());
if (result.getStackTrace() != null && result.getStackTrace().length > 0) {
jsonResult.put("file", result.getStackTrace()[0].getFileName() + ":" + result.getStackTrace()[0].getLineNumber());
}
if (result.getStatus() == CmisTestResultStatus.UNEXPECTED_EXCEPTION && result.getException() != null) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
result.getException().printStackTrace(pw);
jsonResult.put("stacktrace", sw.toString());
if (result.getException() instanceof CmisBaseException) {
CmisBaseException cbe = (CmisBaseException) result.getException();
if (cbe.getErrorContent() != null) {
jsonResult.put("errorcontent", cbe.getErrorContent());
}
}
}
if (result.getException() != null) {
jsonResult.put("exception", result.getException().getMessage());
}
if (result.getRequest() != null) {
jsonResult.put("request", result.getRequest());
}
if (result.getRequest() != null) {
jsonResult.put("response", result.getResponse());
}
if (!result.getChildren().isEmpty()) {
JSONArray nextLevel = new JSONArray();
jsonResult.put("results", nextLevel);
for (CmisTestResult child : result.getChildren()) {
printResult(child, nextLevel);
}
}
}
Aggregations