chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1494175 - in /chemistry/opencmis/trunk: chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/ chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/a...
Date Tue, 18 Jun 2013 15:28:33 GMT
Author: fmui
Date: Tue Jun 18 15:28:32 2013
New Revision: 1494175

URL: http://svn.apache.org/r1494175
Log:
TCK: versioning tests improvements (breaks the TCK run during the build until a bug is fixed
in the InMemory repository)

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/ObjectFactoryImpl.java
    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/types/SecondaryTypesTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/versioning/CheckedOutTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/versioning/VersioningSmokeTest.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/ObjectFactoryImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/ObjectFactoryImpl.java?rev=1494175&r1=1494174&r2=1494175&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/ObjectFactoryImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/ObjectFactoryImpl.java
Tue Jun 18 15:28:32 2013
@@ -349,7 +349,7 @@ public class ObjectFactoryImpl implement
                 if (!(secondaryType instanceof SecondaryType)) {
                     throw new IllegalArgumentException(
                             "Secondary types property contains a type that is not a secondary
type: "
-                                    + secondaryType.getId());
+                                    + secondaryTypeId);
                 }
 
                 allSecondaryTypes.add((SecondaryType) secondaryType);

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=1494175&r1=1494174&r2=1494175&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
Tue Jun 18 15:28:32 2013
@@ -2041,6 +2041,15 @@ public abstract class AbstractSessionTes
 
             f = createResult(FAILURE, "Query name contains invalid character: ')'");
             addResult(results, assertIsTrue(queryName.indexOf(')') < 0, null, f));
+
+            f = createResult(FAILURE, "Query name contains invalid character: '\\t'");
+            addResult(results, assertIsTrue(queryName.indexOf('\t') < 0, null, f));
+
+            f = createResult(FAILURE, "Query name contains invalid character: '\\n'");
+            addResult(results, assertIsTrue(queryName.indexOf('\n') < 0, null, f));
+            
+            f = createResult(FAILURE, "Query name contains invalid character: '\\r'");
+            addResult(results, assertIsTrue(queryName.indexOf('\r') < 0, null, f));
         }
 
         CmisTestResultImpl result = createResult(getWorst(results), message);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/SecondaryTypesTest.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/types/SecondaryTypesTest.java?rev=1494175&r1=1494174&r2=1494175&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/SecondaryTypesTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/SecondaryTypesTest.java
Tue Jun 18 15:28:32 2013
@@ -36,7 +36,9 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.client.api.SecondaryType;
 import org.apache.chemistry.opencmis.client.api.Session;
 import org.apache.chemistry.opencmis.commons.PropertyIds;
+import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
+import org.apache.chemistry.opencmis.commons.enums.Action;
 import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
 import org.apache.chemistry.opencmis.commons.enums.Updatability;
 import org.apache.chemistry.opencmis.tck.CmisTestResult;
@@ -93,14 +95,22 @@ public class SecondaryTypesTest extends 
 
     private void createDocumentAndAttachSecondaryType(Session session, Folder testFolder,
ObjectType secondaryTestType) {
         Document doc = createDocument(session, testFolder, "createandattach.txt", "Secondary
Type Test");
+        Document workDoc = doc;
 
         try {
+            // test if check out is required
+            boolean checkedout = false;
+            if (needsCheckOut(doc)) {
+                workDoc = (Document) session.getObject(doc.checkOut(), SELECT_ALL_NO_CACHE_OC);
+                checkedout = true;
+            }
+
             // -- attach secondary type
             List<String> secondaryTypes = new ArrayList<String>();
 
             // copy already attached secondary types, if there are any
-            if (doc.getSecondaryTypes() != null) {
-                for (SecondaryType secType : doc.getSecondaryTypes()) {
+            if (workDoc.getSecondaryTypes() != null) {
+                for (SecondaryType secType : workDoc.getSecondaryTypes()) {
                     secondaryTypes.add(secType.getId());
                 }
             }
@@ -112,7 +122,7 @@ public class SecondaryTypesTest extends 
             properties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, secondaryTypes);
 
             // attach secondary type
-            ObjectId newId = doc.updateProperties(properties);
+            ObjectId newId = workDoc.updateProperties(properties);
             Document newDoc = (Document) session.getObject(newId, SELECT_ALL_NO_CACHE_OC);
 
             // check if the secondary type is there
@@ -123,6 +133,10 @@ public class SecondaryTypesTest extends 
                 detachSecondaryType(session, newDoc, secondaryTestType);
             }
 
+            // cancel a possible check out
+            if (checkedout) {
+                workDoc.cancelCheckOut();
+            }
         } finally {
             deleteObject(doc);
         }
@@ -137,7 +151,7 @@ public class SecondaryTypesTest extends 
             boolean found = checkSecondaryType(doc, secondaryTestType);
 
             // detach secondary type
-            if (found) {
+            if (found && !needsCheckOut(doc)) {
                 detachSecondaryType(session, doc, secondaryTestType);
             }
         } finally {
@@ -145,6 +159,16 @@ public class SecondaryTypesTest extends 
         }
     }
 
+    private boolean needsCheckOut(Document doc) {
+        DocumentTypeDefinition type = (DocumentTypeDefinition) doc.getType();
+        PropertyDefinition<?> secTypeIdsPropDef = type.getPropertyDefinitions().get(
+                PropertyIds.SECONDARY_OBJECT_TYPE_IDS);
+
+        return secTypeIdsPropDef.getUpdatability() == Updatability.WHENCHECKEDOUT
+                || (!doc.getAllowableActions().getAllowableActions().contains(Action.CAN_UPDATE_PROPERTIES)
&& Boolean.TRUE
+                        .equals(type.isVersionable()));
+    }
+
     private boolean checkSecondaryType(Document doc, ObjectType secondaryTestType) {
         CmisTestResult f;
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/versioning/CheckedOutTest.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/versioning/CheckedOutTest.java?rev=1494175&r1=1494174&r2=1494175&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/versioning/CheckedOutTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/versioning/CheckedOutTest.java
Tue Jun 18 15:28:32 2013
@@ -29,6 +29,7 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.client.api.ObjectId;
 import org.apache.chemistry.opencmis.client.api.Session;
 import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
 import org.apache.chemistry.opencmis.tck.CmisTestResult;
 import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
 
@@ -111,11 +112,20 @@ public class CheckedOutTest extends Abst
             addResult(checkObject(session, pwc, propertiesToCheck, "PWC check: " + (pwc ==
null ? "?" : pwc.getId())));
 
             if (pwc != null) {
-                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));
+                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) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/versioning/VersioningSmokeTest.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/versioning/VersioningSmokeTest.java?rev=1494175&r1=1494174&r2=1494175&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/versioning/VersioningSmokeTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/versioning/VersioningSmokeTest.java
Tue Jun 18 15:28:32 2013
@@ -174,20 +174,47 @@ public class VersioningSmokeTest extends
     private CmisTestResult checkVersionSeries(Session session, List<Document> versions,
String[] properties,
             String message) {
         List<CmisTestResult> results = new ArrayList<CmisTestResult>();
+        CmisTestResult f;
 
+        // make sure there is only one latest version
+        // and zero or one latest major version
         int countLatest = 0;
+        int countLatestMajor = 0;
+        String latestId = null;
         for (Document version : versions) {
             addResult(results, checkObject(session, version, properties, "Version object
check: " + version.getId()));
 
             if (Boolean.TRUE.equals(version.isLatestVersion())) {
                 countLatest++;
+                latestId = version.getId();
+            }
+
+            if (Boolean.TRUE.equals(version.isLatestMajorVersion())) {
+                countLatestMajor++;
             }
         }
 
-        CmisTestResult f = createResult(FAILURE, "A version series should have one latest
version, but it has "
-                + countLatest + "!");
+        f = createResult(FAILURE, "The version series must have exactly one latest version,
but it has " + countLatest
+                + "!");
         addResult(results, assertEquals(1, countLatest, null, f));
 
+        f = createResult(FAILURE, "The version series must have zero or one latest major
version, but it has "
+                + countLatestMajor + "!");
+        addResult(results, assertIsTrue(countLatestMajor < 2, null, f));
+
+        // check getObjectOfLatestVersion()
+        if (countLatest == 1) {
+            Document latestVersion = versions.get(0).getObjectOfLatestVersion(false);
+            addResult(
+                    results,
+                    checkObject(session, latestVersion, properties,
+                            "Latest version object check: " + latestVersion.getId()));
+
+            f = createResult(FAILURE,
+                    "The version that is flagged as latest version is not returned by getObjectOfLatestVersion()!");
+            addResult(results, assertEquals(latestId, latestVersion.getId(), null, f));
+        }
+
         CmisTestResultImpl result = createResult(getWorst(results), message);
         result.getChildren().addAll(results);
 



Mime
View raw message