chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1364357 - /chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/UpdateSmokeTest.java
Date Sun, 22 Jul 2012 16:57:07 GMT
Author: fmui
Date: Sun Jul 22 16:57:06 2012
New Revision: 1364357

URL: http://svn.apache.org/viewvc?rev=1364357&view=rev
Log:
enhanced TCK tests

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/UpdateSmokeTest.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/UpdateSmokeTest.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/UpdateSmokeTest.java?rev=1364357&r1=1364356&r2=1364357&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/UpdateSmokeTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/UpdateSmokeTest.java
Sun Jul 22 16:57:06 2012
@@ -41,8 +41,10 @@ import org.apache.chemistry.opencmis.tck
  */
 public class UpdateSmokeTest extends AbstractSessionTest {
 
-    private static final String NAME1 = "updatetest1.txt";
-    private static final String NAME2 = "updatetest2.txt";
+    private static final String DOC_NAME1 = "updatetest1.txt";
+    private static final String DOC_NAME2 = "updatetest2.txt";
+    private static final String FOLDER_NAME1 = "updatetest1";
+    private static final String FOLDER_NAME2 = "updatetest2";
 
     @Override
     public void init(Map<String, String> parameters) {
@@ -56,66 +58,102 @@ public class UpdateSmokeTest extends Abs
         CmisTestResult f;
 
         try {
-            // create folders
+            // create test folder
             Folder testFolder = createTestFolder(session);
 
-            // create document
-            Document doc1 = createDocument(session, testFolder, NAME1, "rename me!");
-            Document workDoc = doc1;
-
-            f = createResult(FAILURE, "Document name doesn't match with given name!");
-            addResult(assertEquals(NAME1, doc1.getName(), null, f));
-
-            // test if check out is required
-            boolean checkedout = false;
-            DocumentTypeDefinition type = (DocumentTypeDefinition) doc1.getType();
-            PropertyDefinition<?> namePropDef = type.getPropertyDefinitions().get(PropertyIds.NAME);
-            if (namePropDef.getUpdatability() == Updatability.WHENCHECKEDOUT
-                    || (!doc1.getAllowableActions().getAllowableActions().contains(Action.CAN_UPDATE_PROPERTIES)
&& Boolean.TRUE
-                            .equals(type.isVersionable()))) {
-                workDoc = (Document) session.getObject(doc1.checkOut(), SELECT_ALL_NO_CACHE_OC);
-                checkedout = true;
-            }
+            // document test
+            updateDocument(session, testFolder);
 
-            // update
-            Map<String, Object> properties = new HashMap<String, Object>();
-            properties.put(PropertyIds.NAME, NAME2);
-
-            ObjectId newId = workDoc.updateProperties(properties, false);
-            Document doc2 = (Document) session.getObject(newId, SELECT_ALL_NO_CACHE_OC);
-
-            addResult(checkObject(session, doc2, getAllProperties(doc2), "Updated document
compliance"));
-
-            f = createResult(FAILURE, "Document name doesn't match updated value!");
-            addResult(assertEquals(NAME2, doc2.getName(), null, f));
-
-            // update nothing
-            try {
-                properties = new HashMap<String, Object>();
-                doc2.updateProperties(properties, false);
-            } catch (Exception e) {
-                addResult(createResult(WARNING,
-                        "updateProperties without property changes returned an error: " +
e.getMessage(), e, false));
-            }
+            // folder test
+            updateFolder(session, testFolder);
+        } finally {
+            // clean up
+            deleteTestFolder();
+        }
+    }
 
-            // delete
-            if (!workDoc.getId().equals(doc2.getId())) {
-                deleteObject(doc2);
-            }
+    private void updateDocument(Session session, Folder testFolder) {
+        CmisTestResult f;
 
-            // cancel a possible check out
-            if (checkedout) {
-                workDoc.cancelCheckOut();
-            }
+        // create document
+        Document doc1 = createDocument(session, testFolder, DOC_NAME1, "rename me!");
+        Document workDoc = doc1;
+
+        f = createResult(FAILURE, "Document name doesn't match the given name!");
+        addResult(assertEquals(DOC_NAME1, doc1.getName(), null, f));
+
+        // test if check out is required
+        boolean checkedout = false;
+        DocumentTypeDefinition type = (DocumentTypeDefinition) doc1.getType();
+        PropertyDefinition<?> namePropDef = type.getPropertyDefinitions().get(PropertyIds.NAME);
+        if (namePropDef.getUpdatability() == Updatability.WHENCHECKEDOUT
+                || (!doc1.getAllowableActions().getAllowableActions().contains(Action.CAN_UPDATE_PROPERTIES)
&& Boolean.TRUE
+                        .equals(type.isVersionable()))) {
+            workDoc = (Document) session.getObject(doc1.checkOut(), SELECT_ALL_NO_CACHE_OC);
+            checkedout = true;
+        }
+
+        // update
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(PropertyIds.NAME, DOC_NAME2);
+
+        ObjectId newId = workDoc.updateProperties(properties, false);
+        Document doc2 = (Document) session.getObject(newId, SELECT_ALL_NO_CACHE_OC);
+
+        addResult(checkObject(session, doc2, getAllProperties(doc2), "Updated document compliance"));
+
+        f = createResult(FAILURE, "Document name doesn't match updated value!");
+        addResult(assertEquals(DOC_NAME2, doc2.getName(), null, f));
+
+        // update nothing
+        try {
+            properties = new HashMap<String, Object>();
+            doc2.updateProperties(properties, false);
+        } catch (Exception e) {
+            addResult(createResult(WARNING,
+                    "updateProperties without property changes returned an error: " + e.getMessage(),
e, false));
+        }
 
-            if (!doc1.getId().equals(doc2.getId())) {
-                if (exists(doc1)) {
-                    deleteObject(doc1);
-                }
+        // delete
+        if (!workDoc.getId().equals(doc2.getId())) {
+            deleteObject(doc2);
+        }
+
+        // cancel a possible check out
+        if (checkedout) {
+            workDoc.cancelCheckOut();
+        }
+
+        if (!doc1.getId().equals(doc2.getId())) {
+            if (exists(doc1)) {
+                deleteObject(doc1);
             }
-        } finally {
-            // clean up
-            deleteTestFolder();
         }
     }
+
+    private void updateFolder(Session session, Folder testFolder) {
+        CmisTestResult f;
+
+        Folder folder = createFolder(session, testFolder, FOLDER_NAME1);
+
+        f = createResult(FAILURE, "Folder name doesn't match the given name!");
+        addResult(assertEquals(FOLDER_NAME1, folder.getName(), null, f));
+
+        // update
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(PropertyIds.NAME, FOLDER_NAME2);
+
+        ObjectId newId = folder.updateProperties(properties, false);
+
+        f = createResult(WARNING, "Folder id changed after name update! The folder id should
never change!");
+        addResult(assertEquals(folder.getId(), newId.getId(), null, f));
+
+        // get the new folder object and check the new name
+        folder.refresh();
+
+        f = createResult(FAILURE, "Folder name doesn't match updated value!");
+        addResult(assertEquals(FOLDER_NAME2, folder.getName(), null, f));
+
+        deleteObject(folder);
+    }
 }



Mime
View raw message