Return-Path: X-Original-To: apmail-chemistry-commits-archive@www.apache.org Delivered-To: apmail-chemistry-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8C2D58217 for ; Wed, 24 Aug 2011 14:20:33 +0000 (UTC) Received: (qmail 70941 invoked by uid 500); 24 Aug 2011 14:20:33 -0000 Delivered-To: apmail-chemistry-commits-archive@chemistry.apache.org Received: (qmail 70877 invoked by uid 500); 24 Aug 2011 14:20:32 -0000 Mailing-List: contact commits-help@chemistry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@chemistry.apache.org Delivered-To: mailing list commits@chemistry.apache.org Received: (qmail 70753 invoked by uid 99); 24 Aug 2011 14:20:32 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Aug 2011 14:20:32 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Aug 2011 14:20:20 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id CD9E023888FD; Wed, 24 Aug 2011 14:19:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1161109 - in /chemistry/opencmis/trunk: chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/ chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencm... Date: Wed, 24 Aug 2011 14:19:57 -0000 To: commits@chemistry.apache.org From: fmui@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110824141957.CD9E023888FD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: fmui Date: Wed Aug 24 14:19:56 2011 New Revision: 1161109 URL: http://svn.apache.org/viewvc?rev=1161109&view=rev Log: added more TCK tests Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CopyTest.java (with props) chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/DeleteTreeTest.java (with props) chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/MoveTest.java (with props) chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/SetAndDeleteContentTest.java (with props) chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/ContentChangesSmokeTest.java (with props) Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CRUDTestGroup.java chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteDocumentTest.java chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteFolderTest.java chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QuerySmokeTest.java chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QueryTestGroup.java chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java?rev=1161109&r1=1161108&r2=1161109&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java Wed Aug 24 14:19:56 2011 @@ -24,8 +24,12 @@ import static org.apache.chemistry.openc import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.UNEXPECTED_EXCEPTION; import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.WARNING; +import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; +import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; import java.math.BigInteger; import java.util.ArrayList; import java.util.GregorianCalendar; @@ -166,6 +170,32 @@ public abstract class AbstractSessionTes return propertiesk; } + protected String getStringFromContentStream(ContentStream contentStream) throws IOException { + if (contentStream == null || contentStream.getStream() == null) { + return null; + } + + StringBuilder sb = new StringBuilder(); + Reader reader = new InputStreamReader(contentStream.getStream(), "UTF-8"); + + try { + final char[] buffer = new char[64 * 1024]; + int b; + while (true) { + b = reader.read(buffer, 0, buffer.length); + if (b > 0) { + sb.append(buffer, 0, b); + } else if (b == -1) { + break; + } + } + } finally { + reader.close(); + } + + return sb.toString(); + } + // --- handy create and delete methods --- /** @@ -257,6 +287,20 @@ public abstract class AbstractSessionTes } /** + * Counts the children in a folder. + */ + protected int countFolderChildren(Folder folder) { + int count = 0; + + for (@SuppressWarnings("unused") + CmisObject object : folder.getChildren()) { + count++; + } + + return count; + } + + /** * Creates a document. */ protected Document createDocument(Session session, Folder parent, String name, String content) { @@ -272,6 +316,10 @@ public abstract class AbstractSessionTes * Creates a document. */ protected Document createDocument(Session session, Folder parent, String name, String objectTypeId, String content) { + if (content == null) { + content = ""; + } + Map properties = new HashMap(); properties.put(PropertyIds.NAME, name); properties.put(PropertyIds.OBJECT_TYPE_ID, objectTypeId); @@ -312,6 +360,17 @@ public abstract class AbstractSessionTes addResult(checkObject(session, result, propertiesToCheck, "New document object spec compliance")); + // check content + try { + String fetchedContent = getStringFromContentStream(result.getContentStream()); + if (!content.equals(fetchedContent)) { + addResult(createResult(FAILURE, + "Content of newly created document doesn't match the orign content!")); + } + } catch (IOException e) { + addResult(createResult(UNEXPECTED_EXCEPTION, + "Content of newly created document couldn't be read! Exception: " + e.getMessage(), e, true)); + } } catch (CmisBaseException e) { addResult(createResult(UNEXPECTED_EXCEPTION, "Newly created document is invalid! Exception: " + e.getMessage(), e, true)); @@ -782,7 +841,7 @@ public abstract class AbstractSessionTes ContentStream contentStream = doc.getContentStream(); if (contentStream == null) { - if (hasContentProperties) { + if (hasContentProperties && doc.getContentStreamLength() > 0) { addResult(results, createResult(FAILURE, "Content properties have values but the document has no content!")); } @@ -809,10 +868,33 @@ public abstract class AbstractSessionTes } // MIME type check + String docMimeType = doc.getContentStreamMimeType(); + if (docMimeType != null) { + int x = docMimeType.indexOf(';'); + if (x > -1) { + docMimeType = docMimeType.substring(0, x); + } + docMimeType = docMimeType.trim(); + } + + String contentMimeType = contentStream.getMimeType(); + if (contentMimeType != null) { + int x = contentMimeType.indexOf(';'); + if (x > -1) { + contentMimeType = contentMimeType.substring(0, x); + } + contentMimeType = contentMimeType.trim(); + } + f = createResult(FAILURE, "Content MIME types don't match!"); - addResult(results, assertEquals(doc.getContentStreamMimeType(), contentStream.getMimeType(), null, f)); + addResult(results, assertEquals(docMimeType, contentMimeType, null, f)); if (contentStream.getMimeType() != null) { + if (contentMimeType.equals(docMimeType)) { + f = createResult(WARNING, "Content MIME types don't match!"); + addResult(results, assertEquals(doc.getContentStreamMimeType(), contentStream.getMimeType(), null, f)); + } + f = createResult(FAILURE, "Content MIME types is invalid: " + contentStream.getMimeType()); addResult( results, @@ -2073,6 +2155,111 @@ public abstract class AbstractSessionTes } } + protected CmisTestResult assertEquals(ContentStream expected, ContentStream actual, CmisTestResult success, + CmisTestResult failure) { + + List results = new ArrayList(); + + CmisTestResult f; + + if ((expected == null) && (actual == null)) { + return success; + } + + if (expected == null) { + f = createResult(FAILURE, "Expected stream is null, but actual stream is not!"); + addResultChild(failure, f); + + try { + actual.getStream().close(); + } catch (Exception e) { + } + + return failure; + } + + if (actual == null) { + f = createResult(FAILURE, "Actual object is null, but expected object is not!"); + addResultChild(failure, f); + + try { + expected.getStream().close(); + } catch (Exception e) { + } + + return failure; + } + + f = createResult(WARNING, "Filenames don't match!"); + addResult(results, assertEquals(expected.getFileName(), actual.getFileName(), null, f)); + + f = createResult(FAILURE, "MIME types don't match!"); + addResult(results, assertEquals(expected.getMimeType(), actual.getMimeType(), null, f)); + + f = createResult(WARNING, "Lengths don't match!"); + addResult(results, assertEquals(expected.getBigLength(), actual.getBigLength(), null, f)); + + boolean match = true; + + BufferedInputStream as = new BufferedInputStream(actual.getStream()); + BufferedInputStream es = new BufferedInputStream(expected.getStream()); + + try { + int ab = 0; + int eb = 0; + + while (true) { + if (ab > -1) { + ab = as.read(); + } + + if (eb > -1) { + eb = es.read(); + } + + if (ab == -1 && eb == -1) { + break; + } + + if (ab != eb) { + match = false; + } + } + } catch (Exception e) { + f = createResult(UNEXPECTED_EXCEPTION, e.getMessage(), e, false); + addResultChild(failure, f); + } + + if (!match) { + f = createResult(FAILURE, "Content streams don't match!"); + addResultChild(failure, f); + } + + try { + actual.getStream().close(); + } catch (Exception e) { + } + + try { + expected.getStream().close(); + } catch (Exception e) { + } + + if (getWorst(results).getLevel() <= OK.getLevel()) { + for (CmisTestResult result : results) { + addResultChild(success, result); + } + + return success; + } else { + for (CmisTestResult result : results) { + addResultChild(failure, result); + } + + return failure; + } + } + // --- helpers --- protected void addResult(List results, CmisTestResult result) { Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CRUDTestGroup.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CRUDTestGroup.java?rev=1161109&r1=1161108&r2=1161109&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CRUDTestGroup.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CRUDTestGroup.java Wed Aug 24 14:19:56 2011 @@ -35,5 +35,9 @@ public class CRUDTestGroup extends Abstr addTest(new CreateAndDeleteFolderTest()); addTest(new CreateAndDeleteDocumentTest()); + addTest(new SetAndDeleteContentTest()); + addTest(new CopyTest()); + addTest(new MoveTest()); + addTest(new DeleteTreeTest()); } } Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CopyTest.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CopyTest.java?rev=1161109&view=auto ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CopyTest.java (added) +++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CopyTest.java Wed Aug 24 14:19:56 2011 @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.chemistry.opencmis.tck.tests.crud; + +import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.FAILURE; +import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.SKIPPED; + +import java.util.Map; + +import org.apache.chemistry.opencmis.client.api.Document; +import org.apache.chemistry.opencmis.client.api.Folder; +import org.apache.chemistry.opencmis.client.api.Session; +import org.apache.chemistry.opencmis.commons.enums.BindingType; +import org.apache.chemistry.opencmis.tck.CmisTestResult; +import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest; + +/** + * Copy test. + */ +public class CopyTest extends AbstractSessionTest { + + @Override + public void init(Map parameters) { + super.init(parameters); + setName("Copy Test"); + setDescription("Creates two folders and a document and copies the document from one folder to the other. " + + " If the AtomPub binding is used, this test is skipped."); + } + + @Override + public void run(Session session) { + if (getBinding() == BindingType.ATOMPUB) { + addResult(createResult(SKIPPED, + "AtomPub binding does not support createDocumentFromSource(). Test Skipped!")); + return; + } + + CmisTestResult f; + + try { + // create folders + Folder testFolder = createTestFolder(session); + Folder folder1 = createFolder(session, testFolder, "copyfolder1"); + Folder folder2 = createFolder(session, testFolder, "copyfolder2"); + + // create document + Document doc1 = createDocument(session, folder1, "copytestdoc.txt", "copy test"); + + // copy + Document doc2 = doc1.copy(folder2, null, null, null, null, null, SELECT_ALL_NO_CACHE_OC); + + if (doc2 == null) { + addResult(createResult(FAILURE, "Copied document is null!")); + } else { + addResult(checkObject(session, doc2, getAllProperties(doc2), + "Copied document check. Id: + " + doc2.getName())); + + f = createResult(FAILURE, "Content streams don't match!"); + addResult(assertEquals(doc1.getContentStream(), doc2.getContentStream(), null, f)); + } + + int count1 = countFolderChildren(folder1); + f = createResult(FAILURE, "Source folder should have exactly one child but has " + count1 + " children!"); + addResult(assertEquals(1, count1, null, f)); + + int count2 = countFolderChildren(folder2); + f = createResult(FAILURE, "Target folder should have exactly one child but has " + count2 + " children!"); + addResult(assertEquals(1, count2, null, f)); + } finally { + // clean up + deleteTestFolder(); + } + } +} Propchange: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CopyTest.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteDocumentTest.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteDocumentTest.java?rev=1161109&r1=1161108&r2=1161109&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteDocumentTest.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteDocumentTest.java Wed Aug 24 14:19:56 2011 @@ -30,7 +30,6 @@ import org.apache.chemistry.opencmis.cli import org.apache.chemistry.opencmis.client.api.Folder; import org.apache.chemistry.opencmis.client.api.ItemIterable; import org.apache.chemistry.opencmis.client.api.Session; -import org.apache.chemistry.opencmis.commons.PropertyIds; import org.apache.chemistry.opencmis.commons.data.ContentStream; import org.apache.chemistry.opencmis.tck.CmisTestResult; import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest; @@ -53,71 +52,70 @@ public class CreateAndDeleteDocumentTest public void run(Session session) { CmisTestResult f; + int numOfDocuments = 20; + // create a test folder Folder testFolder = createTestFolder(session); - int numOfDocuments = 20; - Map documents = new HashMap(); - String[] propertiesToCheck = new String[] { PropertyIds.OBJECT_ID, PropertyIds.BASE_TYPE_ID, - PropertyIds.OBJECT_TYPE_ID }; - - // create documents - for (int i = 0; i < numOfDocuments; i++) { - Document newDocument = createDocument(session, testFolder, "doc" + i, CONTENT); - addResult(checkObject(session, newDocument, propertiesToCheck, "New folder object spec compliance. Id: " - + newDocument.getId())); - documents.put(newDocument.getId(), newDocument); - } + try { + Map documents = new HashMap(); - // simple children test - addResult(checkChildren(session, testFolder, "Test folder children check")); + // create documents + for (int i = 0; i < numOfDocuments; i++) { + Document newDocument = createDocument(session, testFolder, "doc" + i, CONTENT); + documents.put(newDocument.getId(), newDocument); + } - // check if all documents are there - ItemIterable children = testFolder.getChildren(SELECT_ALL_NO_CACHE_OC); - List childrenIds = new ArrayList(); - for (CmisObject child : children) { - if (child != null) { - childrenIds.add(child.getId()); - Document document = documents.get(child.getId()); + // simple children test + addResult(checkChildren(session, testFolder, "Test folder children check")); - f = createResult(FAILURE, "Document and test folder child don't match! Id: " + child.getId()); - addResult(assertShallowEquals(document, child, null, f)); + // check if all documents are there + ItemIterable children = testFolder.getChildren(SELECT_ALL_NO_CACHE_OC); + List childrenIds = new ArrayList(); + for (CmisObject child : children) { + if (child != null) { + childrenIds.add(child.getId()); + Document document = documents.get(child.getId()); + + f = createResult(FAILURE, "Document and test folder child don't match! Id: " + child.getId()); + addResult(assertShallowEquals(document, child, null, f)); + } } - } - f = createResult(FAILURE, "Number of created folders does not match the number of existing folders!"); - addResult(assertEquals(numOfDocuments, childrenIds.size(), null, f)); + f = createResult(FAILURE, "Number of created folders does not match the number of existing folders!"); + addResult(assertEquals(numOfDocuments, childrenIds.size(), null, f)); - for (Document document : documents.values()) { - if (!childrenIds.contains(document.getId())) { - addResult(createResult(FAILURE, - "Created document not found in test folder children! Id: " + document.getId())); + for (Document document : documents.values()) { + if (!childrenIds.contains(document.getId())) { + addResult(createResult(FAILURE, "Created document not found in test folder children! Id: " + + document.getId())); + } } - } - // check content - for (Document document : documents.values()) { - ContentStream contentStream = document.getContentStream(); - if (contentStream == null) { - addResult(createResult(FAILURE, "Document has no content! Id: " + document.getId())); - continue; - } + // check content + for (Document document : documents.values()) { + ContentStream contentStream = document.getContentStream(); + if (contentStream == null) { + addResult(createResult(FAILURE, "Document has no content! Id: " + document.getId())); + continue; + } - // TODO: content checks - } + // TODO: content checks + } - // delete all documents - for (Document document : documents.values()) { - document.delete(true); - - f = createResult(FAILURE, - "Document should not exist anymore but it is still there! Id: " + document.getId()); - addResult(assertIsFalse(exists(document), null, f)); + // delete all documents + for (Document document : documents.values()) { + document.delete(true); + + f = createResult(FAILURE, + "Document should not exist anymore but it is still there! Id: " + document.getId()); + addResult(assertIsFalse(exists(document), null, f)); + } + } finally { + // delete the test folder + deleteTestFolder(); } - // delete the test folder - deleteTestFolder(); - addResult(createInfoResult("Tested the creation and deletion of " + numOfDocuments + " documents.")); } } Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteFolderTest.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteFolderTest.java?rev=1161109&r1=1161108&r2=1161109&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteFolderTest.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteFolderTest.java Wed Aug 24 14:19:56 2011 @@ -29,7 +29,6 @@ import org.apache.chemistry.opencmis.cli import org.apache.chemistry.opencmis.client.api.Folder; import org.apache.chemistry.opencmis.client.api.ItemIterable; import org.apache.chemistry.opencmis.client.api.Session; -import org.apache.chemistry.opencmis.commons.PropertyIds; import org.apache.chemistry.opencmis.tck.CmisTestResult; import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest; @@ -49,60 +48,60 @@ public class CreateAndDeleteFolderTest e public void run(Session session) { CmisTestResult f; + int numOfFolders = 20; + // create a test folder Folder testFolder = createTestFolder(session); - int numOfFolders = 20; - Map folders = new HashMap(); - String[] propertiesToCheck = new String[] { PropertyIds.OBJECT_ID, PropertyIds.BASE_TYPE_ID, - PropertyIds.OBJECT_TYPE_ID }; - - // create folders - for (int i = 0; i < numOfFolders; i++) { - Folder newFolder = createFolder(session, testFolder, "folder" + i); - addResult(checkObject(session, newFolder, propertiesToCheck, "New folder object spec compliance. Id: " - + newFolder.getId())); - folders.put(newFolder.getId(), newFolder); - } + try { + Map folders = new HashMap(); - // simple children test - addResult(checkChildren(session, testFolder, "Test folder children check")); + // create folders + for (int i = 0; i < numOfFolders; i++) { + Folder newFolder = createFolder(session, testFolder, "folder" + i); + folders.put(newFolder.getId(), newFolder); + } - // check if all folders are there - ItemIterable children = testFolder.getChildren(SELECT_ALL_NO_CACHE_OC); - List childrenIds = new ArrayList(); - for (CmisObject child : children) { - if (child != null) { - childrenIds.add(child.getId()); - Folder folder = folders.get(child.getId()); + // simple children test + addResult(checkChildren(session, testFolder, "Test folder children check")); - f = createResult(FAILURE, "Folder and test folder child don't match! Id: " + child.getId()); - addResult(assertShallowEquals(folder, child, null, f)); + // check if all folders are there + ItemIterable children = testFolder.getChildren(SELECT_ALL_NO_CACHE_OC); + List childrenIds = new ArrayList(); + for (CmisObject child : children) { + if (child != null) { + childrenIds.add(child.getId()); + Folder folder = folders.get(child.getId()); + + f = createResult(FAILURE, "Folder and test folder child don't match! Id: " + child.getId()); + addResult(assertShallowEquals(folder, child, null, f)); + } } - } - f = createResult(FAILURE, "Number of created folders does not match the number of existing folders!"); - addResult(assertEquals(numOfFolders, childrenIds.size(), null, f)); + f = createResult(FAILURE, "Number of created folders does not match the number of existing folders!"); + addResult(assertEquals(numOfFolders, childrenIds.size(), null, f)); - for (Folder folder : folders.values()) { - if (!childrenIds.contains(folder.getId())) { - addResult(createResult(FAILURE, - "Created folder not found in test folder children! Id: " + folder.getId())); + for (Folder folder : folders.values()) { + if (!childrenIds.contains(folder.getId())) { + addResult(createResult(FAILURE, + "Created folder not found in test folder children! Id: " + folder.getId())); + } } - } - - // delete all folders - for (Folder folder : folders.values()) { - // empty folders should be deleteable like this - folder.delete(true); - f = createResult(FAILURE, "Folder should not exist anymore but it is still there! Id: " + folder.getId()); - addResult(assertIsFalse(exists(folder), null, f)); + // delete all folders + for (Folder folder : folders.values()) { + // empty folders should be deleteable like this + folder.delete(true); + + f = createResult(FAILURE, + "Folder should not exist anymore but it is still there! Id: " + folder.getId()); + addResult(assertIsFalse(exists(folder), null, f)); + } + } finally { + // delete the test folder + deleteTestFolder(); } - // delete the test folder - deleteTestFolder(); - addResult(createInfoResult("Tested the creation and deletion of " + numOfFolders + " folders.")); } } Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/DeleteTreeTest.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/DeleteTreeTest.java?rev=1161109&view=auto ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/DeleteTreeTest.java (added) +++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/DeleteTreeTest.java Wed Aug 24 14:19:56 2011 @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.chemistry.opencmis.tck.tests.crud; + +import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.FAILURE; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.chemistry.opencmis.client.api.Document; +import org.apache.chemistry.opencmis.client.api.Folder; +import org.apache.chemistry.opencmis.client.api.Session; +import org.apache.chemistry.opencmis.commons.enums.UnfileObject; +import org.apache.chemistry.opencmis.tck.CmisTestResult; +import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest; + +/** + * Simple document test. + */ +public class DeleteTreeTest extends AbstractSessionTest { + + private static final String CONTENT = "TCK test content."; + + @Override + public void init(Map parameters) { + super.init(parameters); + setName("Delete Tree Test"); + setDescription("Creates a few documents in a folder, deletes the folder and checks if all documents are gone."); + } + + @Override + public void run(Session session) { + CmisTestResult f; + + int numOfDocuments = 20; + + // create a test folder + Folder testFolder = createTestFolder(session); + + Map documents = new HashMap(); + + // create documents + for (int i = 0; i < numOfDocuments; i++) { + Document newDocument = createDocument(session, testFolder, "doc" + i, CONTENT); + documents.put(newDocument.getId(), newDocument); + } + + // delete tree + List failedIds = testFolder.deleteTree(true, UnfileObject.DELETE, true); + + // check failed ids + if (failedIds != null && failedIds.size() > 0) { + f = createResult(FAILURE, "deleteTree() could not delete " + failedIds.size() + " out of " + numOfDocuments + + " objects in the folder!"); + addResult(assertEquals(0, failedIds.size(), null, f)); + } + + // check documents + for (Document doc : documents.values()) { + f = createResult(FAILURE, "Document still exists but should have been deleted. Id: " + doc.getId()); + addResult(assertIsFalse(exists(doc), null, f)); + } + + // check folder + f = createResult(FAILURE, "Folder still exists but should have been deleted. Id: " + testFolder.getId()); + addResult(assertIsFalse(exists(testFolder), null, f)); + + if (exists(testFolder)) { + // try to clean up + try { + deleteObject(testFolder); + } catch (Exception e) { + } + } + } +} Propchange: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/DeleteTreeTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/MoveTest.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/MoveTest.java?rev=1161109&view=auto ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/MoveTest.java (added) +++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/MoveTest.java Wed Aug 24 14:19:56 2011 @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.chemistry.opencmis.tck.tests.crud; + +import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.FAILURE; + +import java.util.Map; + +import org.apache.chemistry.opencmis.client.api.Document; +import org.apache.chemistry.opencmis.client.api.Folder; +import org.apache.chemistry.opencmis.client.api.Session; +import org.apache.chemistry.opencmis.tck.CmisTestResult; +import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest; + +/** + * Copy test. + */ +public class MoveTest extends AbstractSessionTest { + + @Override + public void init(Map parameters) { + super.init(parameters); + setName("Move Test"); + setDescription("Creates two folders and a document and moves the document from one folder to the other."); + } + + @Override + public void run(Session session) { + CmisTestResult f; + + try { + // create folders + Folder testFolder = createTestFolder(session); + Folder folder1 = createFolder(session, testFolder, "movefolder1"); + Folder folder2 = createFolder(session, testFolder, "movefolder2"); + + // create document + Document doc1 = createDocument(session, folder1, "movetestdoc.txt", "move test"); + + // move + Document doc2 = (Document) doc1.move(folder1, folder2, SELECT_ALL_NO_CACHE_OC); + + if (doc2 == null) { + addResult(createResult(FAILURE, "Moved document is null!")); + } else { + addResult(checkObject(session, doc2, getAllProperties(doc2), + "Moved document check. Id: + " + doc2.getName())); + } + + int count1 = countFolderChildren(folder1); + f = createResult(FAILURE, "Source folder should be empty after move but has " + count1 + " children!"); + addResult(assertEquals(0, count1, null, f)); + + int count2 = countFolderChildren(folder2); + f = createResult(FAILURE, "Target folder should have exactly one child but has " + count2 + " children!"); + addResult(assertEquals(1, count2, null, f)); + } finally { + // clean up + deleteTestFolder(); + } + } +} Propchange: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/MoveTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/SetAndDeleteContentTest.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/SetAndDeleteContentTest.java?rev=1161109&view=auto ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/SetAndDeleteContentTest.java (added) +++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/SetAndDeleteContentTest.java Wed Aug 24 14:19:56 2011 @@ -0,0 +1,139 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.chemistry.opencmis.tck.tests.crud; + +import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.FAILURE; +import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.SKIPPED; +import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.UNEXPECTED_EXCEPTION; +import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.WARNING; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.math.BigInteger; +import java.util.Map; + +import org.apache.chemistry.opencmis.client.api.Document; +import org.apache.chemistry.opencmis.client.api.Folder; +import org.apache.chemistry.opencmis.client.api.Session; +import org.apache.chemistry.opencmis.commons.data.ContentStream; +import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition; +import org.apache.chemistry.opencmis.commons.enums.CapabilityContentStreamUpdates; +import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException; +import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl; +import org.apache.chemistry.opencmis.tck.CmisTestResult; +import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest; + +/** + * Copy test. + */ +public class SetAndDeleteContentTest extends AbstractSessionTest { + + private static final String CONTENT1 = "one"; + private static final String CONTENT2 = "two"; + + @Override + public void init(Map parameters) { + super.init(parameters); + setName("Set and Delete content Test"); + setDescription("Creates a new document and tries to set and delete its content."); + } + + @Override + public void run(Session session) { + CmisTestResult f; + + if (getContentStreamUpdatesCapbility(session) == CapabilityContentStreamUpdates.NONE) { + addResult(createInfoResult("Stream updates are not supported. Test skipped!")); + return; + } + + try { + // create folder and document + Folder testFolder = createTestFolder(session); + Document doc = createDocument(session, testFolder, "contenttest.txt", CONTENT1); + Document workDoc = doc; + + // test if check out is required and possible + boolean checkedout = false; + if (getContentStreamUpdatesCapbility(session) == CapabilityContentStreamUpdates.PWCONLY) { + DocumentTypeDefinition docType = (DocumentTypeDefinition) doc.getType(); + + if (!docType.isVersionable()) { + addResult(createResult(SKIPPED, + "Content stream operations only work if PWCs and the the test type is not versionable. Test skipped!")); + doc.delete(true); + return; + } + + workDoc = (Document) session.getObject(doc.checkOut(), SELECT_ALL_NO_CACHE_OC); + checkedout = true; + } + + // delete content stream + try { + workDoc.deleteContentStream(true); + + f = createResult(FAILURE, "Document still has content after deleteContentStream() has been called!"); + addResult(assertNull(workDoc.getContentStream(), null, f)); + } catch (CmisNotSupportedException e) { + addResult(createResult(WARNING, "deleteContentStream() is not supported!")); + } + + // set a new content stream + byte[] contentBytes = new byte[0]; + try { + contentBytes = CONTENT2.getBytes("UTF-8"); + } catch (Exception e) { + } + + ContentStream contentStream = new ContentStreamImpl(workDoc.getName(), + BigInteger.valueOf(contentBytes.length), "text/plain", new ByteArrayInputStream(contentBytes)); + + workDoc.setContentStream(contentStream, true, true); + + // test new content + try { + String content = getStringFromContentStream(workDoc.getContentStream()); + f = createResult(FAILURE, "Document content doesn't match the content set by setContentStream()!"); + addResult(assertEquals(CONTENT2, content, null, f)); + } catch (IOException e) { + addResult(createResult(UNEXPECTED_EXCEPTION, + "Document content couldn't be read! Exception: " + e.getMessage(), e, true)); + } + + // cancel a possible check out + if (checkedout) { + workDoc.cancelCheckOut(); + } + + // remove the document + deleteObject(doc); + } finally { + deleteTestFolder(); + } + } + + private CapabilityContentStreamUpdates getContentStreamUpdatesCapbility(Session session) { + if (session.getRepositoryInfo().getCapabilities() == null) { + return null; + } + + return session.getRepositoryInfo().getCapabilities().getContentStreamUpdatesCapability(); + } +} Propchange: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/SetAndDeleteContentTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/ContentChangesSmokeTest.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/ContentChangesSmokeTest.java?rev=1161109&view=auto ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/ContentChangesSmokeTest.java (added) +++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/ContentChangesSmokeTest.java Wed Aug 24 14:19:56 2011 @@ -0,0 +1,101 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.chemistry.opencmis.tck.tests.query; + +import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.FAILURE; +import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.SKIPPED; + +import java.util.Map; + +import org.apache.chemistry.opencmis.client.api.ChangeEvent; +import org.apache.chemistry.opencmis.client.api.ChangeEvents; +import org.apache.chemistry.opencmis.client.api.CmisObject; +import org.apache.chemistry.opencmis.client.api.Session; +import org.apache.chemistry.opencmis.commons.data.RepositoryInfo; +import org.apache.chemistry.opencmis.commons.enums.CapabilityChanges; +import org.apache.chemistry.opencmis.commons.enums.ChangeType; +import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException; +import org.apache.chemistry.opencmis.tck.CmisTestResult; +import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest; + +/** + * Content Changes smoke test. + */ +public class ContentChangesSmokeTest extends AbstractSessionTest { + + @Override + public void init(Map parameters) { + super.init(parameters); + setName("Content Changes Smoke Test"); + setDescription("Calls getContentChanges(). It does not check if the results are correct!"); + } + + @Override + public void run(Session session) { + CmisTestResult f; + + if (supportsContentChanges(session)) { + ChangeEvents events = session.getContentChanges(null, true, 1000, SELECT_ALL_NO_CACHE_OC); + + f = createResult(FAILURE, "Change events are null!"); + addResult(assertNotNull(events, null, f)); + + if (events != null && events.getChangeEvents() != null) { + f = createResult(FAILURE, "Change log token is null!"); + addResult(assertNotNull(events.getLatestChangeLogToken(), null, f)); + + for (ChangeEvent event : events.getChangeEvents()) { + f = createResult(FAILURE, "Object Id is not set!"); + addResult(assertStringNotEmpty(event.getObjectId(), null, f)); + + f = createResult(FAILURE, "Change Type is not set! Id: " + event.getObjectId()); + addResult(assertNotNull(event.getChangeType(), null, f)); + + f = createResult(FAILURE, "Change Time is not set! Id: " + event.getObjectId()); + addResult(assertNotNull(event.getChangeTime(), null, f)); + + if (event.getChangeType() != ChangeType.DELETED && event.getObjectId() != null) { + try { + CmisObject object = session.getObject(event.getObjectId(), SELECT_ALL_NO_CACHE_OC); + addResult(checkObject(session, object, getAllProperties(object), "Object check. Id: " + + event.getObjectId())); + } catch (CmisObjectNotFoundException e) { + addResult(createResult( + FAILURE, + "Change event does reference an object that doesn't exist. Id: " + + event.getObjectId(), e, false)); + } + } + } + } + } else { + addResult(createResult(SKIPPED, "Content Changes not supported. Test Skipped!")); + } + } + + protected boolean supportsContentChanges(Session session) { + RepositoryInfo repository = session.getRepositoryInfo(); + + if (repository.getCapabilities().getChangesCapability() == null) { + return false; + } + + return repository.getCapabilities().getChangesCapability() != CapabilityChanges.NONE; + } +} Propchange: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/ContentChangesSmokeTest.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QuerySmokeTest.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QuerySmokeTest.java?rev=1161109&r1=1161108&r2=1161109&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QuerySmokeTest.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QuerySmokeTest.java Wed Aug 24 14:19:56 2011 @@ -20,20 +20,23 @@ package org.apache.chemistry.opencmis.tc import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.FAILURE; import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.OK; +import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.SKIPPED; import java.util.ArrayList; import java.util.List; import java.util.Map; +import org.apache.chemistry.opencmis.client.api.CmisObject; import org.apache.chemistry.opencmis.client.api.ItemIterable; +import org.apache.chemistry.opencmis.client.api.ObjectType; import org.apache.chemistry.opencmis.client.api.QueryResult; import org.apache.chemistry.opencmis.client.api.Session; import org.apache.chemistry.opencmis.commons.PropertyIds; import org.apache.chemistry.opencmis.commons.data.PropertyData; import org.apache.chemistry.opencmis.commons.data.RepositoryInfo; import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition; -import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition; import org.apache.chemistry.opencmis.commons.enums.CapabilityQuery; +import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException; import org.apache.chemistry.opencmis.tck.CmisTestResult; import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest; import org.apache.chemistry.opencmis.tck.impl.CmisTestResultImpl; @@ -47,18 +50,37 @@ public class QuerySmokeTest extends Abst public void init(Map parameters) { super.init(parameters); setName("Query Smoke Test"); - setDescription("Performs a simple query and checks if the format of the results is correct. It does not check if the result are complete!"); + setDescription("Performs a simple query and checks if the format of the results is correct. It does not check if the results are complete!"); } @Override public void run(Session session) { CmisTestResult f; - String testType = "cmis:document"; - String statement = "SELECT * FROM " + testType; - int pageSize = 100; - if (supportsQuery(session)) { + String testType = "cmis:document"; + String statement = "SELECT * FROM " + testType; + + ObjectType type = session.getTypeDefinition(testType); + + f = createResult(FAILURE, "Test type definition '" + testType + "'not found!"); + addResult(assertNotNull(type, null, f)); + if (type == null) { + return; + } + + PropertyDefinition objectIdPropDef = type.getPropertyDefinitions().get(PropertyIds.OBJECT_ID); + + f = createResult(FAILURE, "Object Id property definition does not exist!"); + addResult(assertNotNull(objectIdPropDef, null, f)); + + String objectIdQueryName = null; + if (objectIdPropDef != null) { + objectIdQueryName = objectIdPropDef.getQueryName(); + } + + int pageSize = 100; + ItemIterable resultSet = session.query(statement, false); if (resultSet == null) { @@ -70,8 +92,20 @@ public class QuerySmokeTest extends Abst if (qr == null) { addResult(createResult(FAILURE, "Query result is null! (OpenCMIS issue???)")); } else { - addResult(checkQueryResult(session, qr, testType, "Query result: " + i)); + addResult(checkQueryResult(session, qr, type, "Query result: " + i)); + + if (objectIdQueryName != null) { + String objectId = (String) qr.getPropertyByQueryName(objectIdQueryName).getFirstValue(); + try { + CmisObject object = session.getObject(objectId, SELECT_ALL_NO_CACHE_OC); + addResult(checkObject(session, object, getAllProperties(object), + "Query hit check. Id: " + objectId)); + } catch (CmisObjectNotFoundException e) { + addResult(createResult(FAILURE, + "Query hit references an object that doesn't exist. Id: " + objectId, e, false)); + } + } // TODO: check more } i++; @@ -85,11 +119,11 @@ public class QuerySmokeTest extends Abst + ")")); } } else { - addResult(createInfoResult("Query not supported!")); + addResult(createResult(SKIPPED, "Query not supported. Test Skipped!")); } } - protected CmisTestResult checkQueryResult(Session session, QueryResult qr, String typeId, String message) { + protected CmisTestResult checkQueryResult(Session session, QueryResult qr, ObjectType type, String message) { List results = new ArrayList(); CmisTestResult f; @@ -97,8 +131,6 @@ public class QuerySmokeTest extends Abst if (qr.getProperties().isEmpty()) { addResult(results, createResult(FAILURE, "Query result is empty!")); } else { - TypeDefinition type = session.getTypeDefinition(typeId); - for (PropertyDefinition propDef : type.getPropertyDefinitions().values()) { if (propDef.getQueryName() == null) { continue; Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QueryTestGroup.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QueryTestGroup.java?rev=1161109&r1=1161108&r2=1161109&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QueryTestGroup.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QueryTestGroup.java Wed Aug 24 14:19:56 2011 @@ -31,8 +31,9 @@ public class QueryTestGroup extends Abst super.init(parameters); setName("Query Test Group"); - setDescription("Query tests."); + setDescription("Query and content changes tests."); addTest(new QuerySmokeTest()); + addTest(new ContentChangesSmokeTest()); } } Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java?rev=1161109&r1=1161108&r2=1161109&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java Wed Aug 24 14:19:56 2011 @@ -135,7 +135,6 @@ public class TckDialog { ((DefaultTreeModel) groupTree.getModel()).reload(); groupTree.setRootVisible(false); - groupTree.setPreferredSize(new Dimension(300, 200)); groupTree.setCellRenderer(new TestTreeNodeRender()); groupTree.setCellEditor(new TestTreeNodeEditor()); groupTree.setEditable(true); @@ -182,6 +181,7 @@ public class TckDialog { // config panel final JPanel configPanel = new JPanel(); configPanel.setLayout(new BoxLayout(configPanel, BoxLayout.PAGE_AXIS)); + configPanel.setPreferredSize(new Dimension(getWidth() / 2, 500)); configPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); final JComboBox folderComboBox = addComboBox(configPanel, "Test folder type:", @@ -202,10 +202,11 @@ public class TckDialog { add(configPanel); - final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(groupTree), - configPanel); - splitPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - add(splitPane, BorderLayout.CENTER); + final JPanel mainPanel = new JPanel(new BorderLayout()); + mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + mainPanel.add(new JScrollPane(groupTree), BorderLayout.CENTER); + mainPanel.add(configPanel, BorderLayout.LINE_END); + add(mainPanel, BorderLayout.CENTER); final JButton runButton = new JButton("Run TCK"); runButton.setDefaultCapable(true);