chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dcaru...@apache.org
Subject svn commit: r805426 [9/9] - in /incubator/chemistry/trunk/chemistry: ./ chemistry-tck-atompub/ chemistry-tck-atompub/src/ chemistry-tck-atompub/src/main/ chemistry-tck-atompub/src/main/java/ chemistry-tck-atompub/src/main/java/org/ chemistry-tck-atompu...
Date Tue, 18 Aug 2009 14:27:59 GMT
Added: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/QueryTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/QueryTest.java?rev=805426&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/QueryTest.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/QueryTest.java Tue Aug 18 14:27:55 2009
@@ -0,0 +1,259 @@
+/*
+ * Licensed 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.
+ *
+ * Authors:
+ *     David Caruana, Alfresco
+ *     Gabriele Columbro, Alfresco
+ */
+package org.apache.chemistry.tck.atompub.test.spec;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.abdera.i18n.iri.IRI;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.chemistry.abdera.ext.CMISAllowableActions;
+import org.apache.chemistry.abdera.ext.CMISCapabilities;
+import org.apache.chemistry.abdera.ext.CMISConstants;
+import org.apache.chemistry.abdera.ext.CMISObject;
+import org.apache.chemistry.tck.atompub.TCKTest;
+import org.apache.chemistry.tck.atompub.http.PostRequest;
+import org.apache.chemistry.tck.atompub.http.Request;
+import org.apache.chemistry.tck.atompub.http.Response;
+import org.junit.Assert;
+
+
+/**
+ * CMIS Query Tests
+ */
+public class QueryTest extends TCKTest {
+    
+    private Entry folder;
+    private CMISObject folderObject;
+    private Entry document1;
+    private CMISObject document1Object;
+    private Entry document2;
+    private CMISObject document2Object;
+    private Entry document3;
+    private CMISObject document3Object;
+
+    @Override
+    public void setUp() {
+        super.setUp();
+
+        try {
+            folder = fixture.getTestCaseFolder();
+            folderObject = folder.getExtension(CMISConstants.OBJECT);
+            // create documents to query
+            document1 = fixture.createTestDocument("apple1");
+            document1Object = document1.getExtension(CMISConstants.OBJECT);
+            String doc2name = "name" + System.currentTimeMillis();
+            document2 = fixture.createTestDocument(doc2name);
+            document2Object = document2.getExtension(CMISConstants.OBJECT);
+            document3 = fixture.createTestDocument("banana1");
+            document3Object = document3.getExtension(CMISConstants.OBJECT);
+        } catch (Exception e) {
+            // TODO: appropriate exception handling
+            throw new RuntimeException(e);
+        }
+    }
+
+    public void testQueryFolderMetaData() throws Exception {
+        CMISCapabilities capabilities = client.getCapabilities();
+        String capability = capabilities.getQuery();
+        if (!(capability.equals("metadataonly") && capability.equals("bothseperate") && capability.equals("bothcombined"))) {
+            skipTest("Query capability: " + capability);
+            return;
+        }
+
+        IRI queryHREF = client.getQueryCollection(client.getWorkspace());
+        String queryDoc = templates.load("query.cmisquery.xml");
+
+        // meta data only query against folder
+        // TODO: use property query name
+        String query = 
+                "SELECT * FROM cmis:folder " +
+                "WHERE cmis:ObjectId = '" + folderObject.getObjectId().getStringValue() + "'";
+        String queryReq = queryDoc.replace("${STATEMENT}", query);
+        queryReq = queryReq.replace("${SKIPCOUNT}", "0");
+        queryReq = queryReq.replace("${MAXITEMS}", "5");
+
+        Request postReq = new PostRequest(queryHREF.toString(), queryReq,  CMISConstants.MIMETYPE_CMIS_QUERY);
+        Response queryRes = client.executeRequest(postReq, 200);
+        Assert.assertNotNull(queryRes);
+        Feed queryFeed = model.parseFeed(new StringReader(queryRes.getContentAsString()), null);
+        Assert.assertNotNull(queryFeed);
+        Assert.assertEquals(1, queryFeed.getEntries().size());
+        Assert.assertNotNull(queryFeed.getEntry(folder.getId().toString()));
+        CMISObject result1 = queryFeed.getEntry(folder.getId().toString()).getExtension(CMISConstants.OBJECT);
+        Assert.assertEquals(folderObject.getName().getStringValue(), result1.getName().getStringValue());
+        Assert.assertEquals(folderObject.getObjectId().getStringValue(), result1.getObjectId().getStringValue());
+        Assert.assertEquals(folderObject.getObjectTypeId().getStringValue(), result1.getObjectTypeId().getStringValue());
+    }
+
+    public void testQueryDocumentMetaData() throws Exception {
+        CMISCapabilities capabilities = client.getCapabilities();
+        String capability = capabilities.getQuery();
+        if (!(capability.equals("metadataonly") && capability.equals("bothseperate") && capability
+                .equals("bothcombined"))) {
+            skipTest("Query capability: " + capability);
+            return;
+        }
+
+        IRI queryHREF = client.getQueryCollection(client.getWorkspace());
+        String queryDoc = templates.load("query.cmisquery.xml");
+
+        // meta data only query against document
+        // TODO: use property query name
+        String query =
+                "SELECT * FROM cmis:document " +
+                "WHERE IN_FOLDER('" + folderObject.getObjectId().getStringValue() + "') " + 
+                "AND cmis:Name = 'apple1'";
+        String queryReq = queryDoc.replace("${STATEMENT}", query);
+        queryReq = queryReq.replace("${SKIPCOUNT}", "0");
+        queryReq = queryReq.replace("${MAXITEMS}", "5");
+
+        Request postReq = new PostRequest(queryHREF.toString(), queryReq, CMISConstants.MIMETYPE_CMIS_QUERY);
+        Response queryRes = client.executeRequest(postReq, 200);
+        Assert.assertNotNull(queryRes);
+        Feed queryFeed = model.parseFeed(new StringReader(queryRes.getContentAsString()), null);
+        Assert.assertNotNull(queryFeed);
+        Assert.assertEquals(1, queryFeed.getEntries().size());
+        Assert.assertNotNull(queryFeed.getEntry(document1.getId().toString()));
+        CMISObject result1 = queryFeed.getEntry(document1.getId().toString()).getExtension(CMISConstants.OBJECT);
+        Assert.assertEquals(document1Object.getName().getStringValue(), result1.getName().getStringValue());
+        Assert.assertEquals(document1Object.getObjectId().getStringValue(), result1.getObjectId().getStringValue());
+        Assert.assertEquals(document1Object.getObjectTypeId().getStringValue(), result1.getObjectTypeId().getStringValue());
+    }
+
+    public void testQueryDocumentFullText() throws Exception {
+        CMISCapabilities capabilities = client.getCapabilities();
+        String capability = capabilities.getQuery();
+        if (!(capability.equals("fulltextonly") && capability.equals("bothseperate") && capability.equals("bothcombined"))) {
+            skipTest("Query capability: " + capability);
+            return;
+        }
+
+        IRI queryHREF = client.getQueryCollection(client.getWorkspace());
+        String queryDoc = templates.load("query.cmisquery.xml");
+
+        // full text only query
+        // TODO: use property query name
+        String fullText = document2Object.getName().getStringValue();
+        String query = 
+                "SELECT cmis:ObjectId, cmis:ObjectTypeId, cmis:Name FROM cmis:document " + 
+                "WHERE CONTAINS('" + fullText + "')";
+        String queryReq = queryDoc.replace("${STATEMENT}", query);
+        queryReq = queryReq.replace("${SKIPCOUNT}", "0");
+        queryReq = queryReq.replace("${MAXITEMS}", "5");
+
+        Request postReq = new PostRequest(queryHREF.toString(), queryReq, CMISConstants.MIMETYPE_CMIS_QUERY);
+        Response queryRes = client.executeRequest(postReq, 200);
+        Assert.assertNotNull(queryRes);
+        Feed queryFeed = model.parseFeed(new StringReader(queryRes.getContentAsString()), null);
+        Assert.assertNotNull(queryFeed);
+        Assert.assertEquals(1, queryFeed.getEntries().size());
+        Assert.assertNotNull(queryFeed.getEntry(document2.getId().toString()));
+        CMISObject result1 = queryFeed.getEntry(document2.getId().toString()).getExtension(CMISConstants.OBJECT);
+        Assert.assertEquals(document2Object.getName().getStringValue(), result1.getName().getStringValue());
+        Assert.assertEquals(document2Object.getObjectId().getStringValue(), result1.getObjectId().getStringValue());
+        Assert.assertEquals(document2Object.getObjectTypeId().getStringValue(), result1.getObjectTypeId().getStringValue());
+    }
+
+    public void testQueryDocumentMetaDataAndFullText() throws Exception {
+        CMISCapabilities capabilities = client.getCapabilities();
+        String capability = capabilities.getQuery();
+        if (!capability.equals("bothcombined")) {
+            skipTest("Query capability: " + capability);
+            return;
+        }
+
+        IRI queryHREF = client.getQueryCollection(client.getWorkspace());
+        String queryDoc = templates.load("query.cmisquery.xml");
+
+        // combined meta data and full text
+        // TODO: use property query name
+        String query = 
+                "SELECT cmis:ObjectId, cmis:ObjectTypeId, cmis:Name FROM cmis:document " + 
+                "WHERE IN_FOLDER('" + folderObject.getObjectId().getStringValue() + "') " +
+                "AND cmis:Name = 'apple1' " +
+                "AND CONTAINS('apple1')";
+        String queryReq = queryDoc.replace("${STATEMENT}", query);
+        queryReq = queryReq.replace("${SKIPCOUNT}", "0");
+        queryReq = queryReq.replace("${MAXITEMS}", "5");
+
+        Request postReq = new PostRequest(queryHREF.toString(), queryReq, CMISConstants.MIMETYPE_CMIS_QUERY);
+        Response queryRes = client.executeRequest(postReq, 200);
+        Assert.assertNotNull(queryRes);
+        Feed queryFeed = model.parseFeed(new StringReader(queryRes.getContentAsString()), null);
+        Assert.assertNotNull(queryFeed);
+        Assert.assertEquals(1, queryFeed.getEntries().size());
+        Assert.assertNotNull(queryFeed.getEntry(document1.getId().toString()));
+        CMISObject result1 = queryFeed.getEntry(document1.getId().toString()).getExtension(CMISConstants.OBJECT);
+        Assert.assertEquals(document1Object.getName().getStringValue(), result1.getName().getStringValue());
+        Assert.assertEquals(document1Object.getObjectId().getStringValue(), result1.getObjectId().getStringValue());
+        Assert.assertEquals(document1Object.getObjectTypeId().getStringValue(), result1.getObjectTypeId().getStringValue());
+    }
+
+    public void testQueryAllowableActions() throws Exception {
+        CMISCapabilities capabilities = client.getCapabilities();
+        String capability = capabilities.getQuery();
+        if (capability.equals("none")) {
+            skipTest("Query capability: " + capability);
+            return;
+        }
+
+        // retrieve query collection
+        IRI queryHREF = client.getQueryCollection(client.getWorkspace());
+        String queryDoc = templates.load("queryallowableactions.cmisquery.xml");
+
+        // construct structured query
+        String query = 
+                "SELECT * FROM cmis:document " + 
+                "WHERE IN_FOLDER('" + folderObject.getObjectId().getStringValue() + "') ";
+        String queryReq = queryDoc.replace("${STATEMENT}", query);
+        queryReq = queryReq.replace("${INCLUDEALLOWABLEACTIONS}", "true");
+        queryReq = queryReq.replace("${SKIPCOUNT}", "0");
+        queryReq = queryReq.replace("${MAXITEMS}", "5");
+
+        // issue structured query
+        Request postReq = new PostRequest(queryHREF.toString(), queryReq, CMISConstants.MIMETYPE_CMIS_QUERY);
+        Response queryRes = client.executeRequest(postReq, 200);
+        Assert.assertNotNull(queryRes);
+        Feed queryFeed = model.parseFeed(new StringReader(queryRes.getContentAsString()), null);
+        Assert.assertNotNull(queryFeed);
+        Assert.assertEquals(3, queryFeed.getEntries().size());
+
+        for (Entry child : queryFeed.getEntries()) {
+            // extract allowable actions from child
+            CMISObject childObject = child.getExtension(CMISConstants.OBJECT);
+            Assert.assertNotNull(childObject);
+            CMISAllowableActions childAllowableActions = childObject.getExtension(CMISConstants.ALLOWABLE_ACTIONS);
+            Assert.assertNotNull(childAllowableActions);
+
+            // retrieve allowable actions from link
+            Map<String, String> args = new HashMap<String, String>();
+            args.put("includeAllowableActions", "true");
+            Entry entry = client.getEntry(child.getSelfLink().getHref(), args);
+            CMISObject entryObject = entry.getExtension(CMISConstants.OBJECT);
+            Assert.assertNotNull(entryObject);
+            CMISAllowableActions entryAllowableActions = entryObject.getExtension(CMISConstants.ALLOWABLE_ACTIONS);
+
+            // compare the two
+            AllowableActionsTest.compareAllowableActions(childAllowableActions, entryAllowableActions);
+        }
+    }
+
+}

Propchange: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/QueryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/RepositoryServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/RepositoryServiceTest.java?rev=805426&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/RepositoryServiceTest.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/RepositoryServiceTest.java Tue Aug 18 14:27:55 2009
@@ -0,0 +1,42 @@
+/*
+ * Licensed 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.
+ *
+ * Authors:
+ *     David Caruana, Alfresco
+ *     Gabriele Columbro, Alfresco
+ */
+package org.apache.chemistry.tck.atompub.test.spec;
+
+import org.apache.abdera.i18n.iri.IRI;
+import org.apache.abdera.model.Service;
+import org.apache.chemistry.tck.atompub.TCKTest;
+import org.apache.chemistry.tck.atompub.http.GetRequest;
+import org.junit.Assert;
+
+
+/**
+ * CMIS Repository Service Document Tests
+ */
+public class RepositoryServiceTest extends TCKTest {
+    
+    public void testRepository() throws Exception {
+        Service service = client.getRepository();
+        Assert.assertNotNull(service);
+    }
+
+    public void testGetRootCollection() throws Exception {
+        IRI rootHREF = client.getRootCollection(client.getWorkspace());
+        client.executeRequest(new GetRequest(rootHREF.toString()), 200, client.getAtomValidator());
+    }
+
+}

Propchange: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/RepositoryServiceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/TypeDefinitionTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/TypeDefinitionTest.java?rev=805426&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/TypeDefinitionTest.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/TypeDefinitionTest.java Tue Aug 18 14:27:55 2009
@@ -0,0 +1,99 @@
+/*
+ * Licensed 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.
+ *
+ * Authors:
+ *     David Caruana, Alfresco
+ *     Gabriele Columbro, Alfresco
+ */
+package org.apache.chemistry.tck.atompub.test.spec;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.abdera.i18n.iri.IRI;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.model.Link;
+import org.apache.chemistry.abdera.ext.CMISConstants;
+import org.apache.chemistry.tck.atompub.TCKTest;
+import org.apache.chemistry.tck.atompub.http.GetRequest;
+import org.apache.chemistry.tck.atompub.http.Response;
+import org.junit.Assert;
+
+
+/**
+ * Type Definition Tests
+ * 
+ */
+public class TypeDefinitionTest extends TCKTest {
+
+    public void testGetTypeDefinitionsAll() throws Exception {
+        IRI typesHREF = client.getTypesChildrenCollection(client.getWorkspace());
+        Feed types = client.getFeed(typesHREF);
+        Assert.assertNotNull(types);
+        Feed typesWithProps = client.getFeed(typesHREF);
+        Assert.assertNotNull(typesWithProps);
+        for (Entry type : types.getEntries()) {
+            Entry retrievedType = client.getEntry(type.getSelfLink().getHref());
+            Assert.assertEquals(type.getId(), retrievedType.getId());
+            Assert.assertEquals(type.getTitle(), retrievedType.getTitle());
+            // TODO: type specific properties - extension to abdera
+        }
+    }
+
+    public void testGetTypeDefinitionHierarchy() throws Exception {
+        IRI typesHREF = client.getTypesChildrenCollection(client.getWorkspace());
+        Map<String, String> args = new HashMap<String, String>();
+        args.put("type", "folder");
+        args.put("includePropertyDefinitions", "true");
+        args.put("maxItems", "5");
+        while (typesHREF != null) {
+            Feed types = client.getFeed(typesHREF, args);
+
+            for (Entry type : types.getEntries()) {
+                Entry retrievedType = client.getEntry(type.getSelfLink().getHref());
+                Assert.assertEquals(type.getId(), retrievedType.getId());
+                Assert.assertEquals(type.getTitle(), retrievedType.getTitle());
+                // TODO: type specific properties - extension to Abdera
+            }
+
+            // next page
+            Link nextLink = types.getLink("next");
+            typesHREF = (nextLink != null) ? nextLink.getHref() : null;
+            args.remove("maxItems");
+        }
+        ;
+    }
+
+    public void testGetTypeDefinition() throws Exception {
+        // create document
+        Entry document = fixture.createTestDocument("testGetEntryTypeDefinitionDoc");
+        Assert.assertNotNull(document);
+        // create folder
+        Entry folder = fixture.createTestFolder("testGetEntryTypeDefinitionFolder");
+        Assert.assertNotNull(folder);
+
+        // retrieve children
+        Entry testFolder = fixture.getTestCaseFolder();
+        Link childrenLink = client.getChildrenLink(testFolder);
+        Feed children = client.getFeed(childrenLink.getHref());
+        for (Entry entry : children.getEntries()) {
+            // get type definition
+            Link typeLink = entry.getLink(CMISConstants.REL_DESCRIBED_BY);
+            Assert.assertNotNull(typeLink);
+            Entry type = client.getEntry(typeLink.getHref());
+            Assert.assertNotNull(type);
+            // TODO: test correct type for entry & properties of type
+        }
+    }
+}

Propchange: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/TypeDefinitionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/UpdateTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/UpdateTest.java?rev=805426&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/UpdateTest.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/UpdateTest.java Tue Aug 18 14:27:55 2009
@@ -0,0 +1,122 @@
+/*
+ * Licensed 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.
+ *
+ * Authors:
+ *     David Caruana, Alfresco
+ *     Gabriele Columbro, Alfresco
+ */
+package org.apache.chemistry.tck.atompub.test.spec;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import org.apache.abdera.model.Entry;
+import org.apache.chemistry.abdera.ext.CMISConstants;
+import org.apache.chemistry.tck.atompub.TCKTest;
+import org.apache.chemistry.tck.atompub.http.GetRequest;
+import org.apache.chemistry.tck.atompub.http.PatchRequest;
+import org.apache.chemistry.tck.atompub.http.PutRequest;
+import org.apache.chemistry.tck.atompub.http.Request;
+import org.apache.chemistry.tck.atompub.http.Response;
+import org.junit.Assert;
+
+
+/**
+ * CMIS Update Tests
+ */
+public class UpdateTest extends TCKTest {
+    
+    public void testUpdatePatch() throws Exception {
+        // retrieve test folder for update
+        Entry document = fixture.createTestDocument("testUpdatePatch");
+        String mimetype = (document.getContentMimeType() != null) ? document.getContentMimeType().toString() : null;
+        if (mimetype != null) {
+            Assert.assertEquals("text/html", mimetype);
+        }
+
+        // TODO: check for content update allowable action
+        // if update allowed, perform update, else update and check for
+        // appropriate error
+
+        // update
+        String updateFile = templates.load("updatedocument.atomentry.xml");
+        // FIXME: Add a decent UID generation policy
+        // String guid = GUID.generate();
+        String guid = System.currentTimeMillis() + "";
+        updateFile = updateFile.replace("${NAME}", guid);
+        Request patchReq = new PatchRequest(document.getSelfLink().getHref().toString(), updateFile, CMISConstants.MIMETYPE_ENTRY);
+        Response res = client.executeRequest(patchReq, 200, client.getAtomValidator());
+        Assert.assertNotNull(res);
+        Entry updated = model.parseEntry(new StringReader(res.getContentAsString()), null);
+
+        // ensure update occurred
+        Assert.assertEquals(document.getId(), updated.getId());
+        Assert.assertEquals(document.getPublished(), updated.getPublished());
+        Assert.assertEquals("Updated Title " + guid, updated.getTitle());
+        // TODO: why is this testing for text/plain? it should be test/html
+        Assert.assertEquals("text/plain", updated.getContentMimeType().toString());
+        Response contentRes = client.executeRequest(new GetRequest(updated.getContentSrc().toString()), 200);
+        Assert.assertEquals("updated content " + guid, contentRes.getContentAsString());
+    }
+
+    public void testUpdatePut() throws Exception {
+        // retrieve test folder for update
+        Entry document = fixture.createTestDocument("testUpdatePut");
+        String mimetype = (document.getContentMimeType() != null) ? document.getContentMimeType().toString() : null;
+        if (mimetype != null) {
+            Assert.assertEquals("text/html", mimetype);
+        }
+
+        // TODO: check for content update allowable action
+        // if update allowed, perform update, else update and check for
+        // appropriate error
+
+        // update
+        String updateFile = templates.load("updatedocument.atomentry.xml");
+        // FIXME: Add a decent UID generation policy
+        // String guid = GUID.generate();
+        String guid = System.currentTimeMillis() + "";
+        updateFile = updateFile.replace("${NAME}", guid);
+        Request putReq = new PutRequest(document.getSelfLink().getHref().toString(), updateFile, CMISConstants.MIMETYPE_ENTRY);
+        Response res = client.executeRequest(putReq, 200, client.getAtomValidator());
+        Assert.assertNotNull(res);
+        Entry updated = model.parseEntry(new StringReader(res.getContentAsString()), null);
+
+        // ensure update occurred
+        Assert.assertEquals(document.getId(), updated.getId());
+        Assert.assertEquals(document.getPublished(), updated.getPublished());
+        Assert.assertEquals("Updated Title " + guid, updated.getTitle());
+        // TODO: why is this testing for text/plain? it should be test/html
+        Assert.assertEquals("text/plain", updated.getContentMimeType().toString());
+        Response contentRes = client.executeRequest(new GetRequest(updated.getContentSrc().toString()), 200);
+        Assert.assertEquals("updated content " + guid, contentRes.getContentAsString());
+    }
+
+    public void testUpdatePutAtomEntry() throws Exception {
+        // retrieve test folder for update
+        Entry document = fixture.createTestDocument("testUpdatePutAtomEntry");
+        // edit title
+        String updatedTitle = "Iñtërnâtiônàlizætiøn - 2";
+        document.setTitle(updatedTitle);
+        StringWriter writer = new StringWriter();
+        document.writeTo(writer);
+
+        // put document
+        Request putReq = new PutRequest(document.getSelfLink().getHref().toString(), writer.toString(), CMISConstants.MIMETYPE_ENTRY);
+        Response res = client.executeRequest(putReq, 200, client.getAtomValidator());
+        Assert.assertNotNull(res);
+        Entry updated = model.parseEntry(new StringReader(res.getContentAsString()), null);
+        Assert.assertEquals(updatedTitle, updated.getTitle());
+    }
+
+}

Propchange: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/UpdateTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/VersionsTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/VersionsTest.java?rev=805426&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/VersionsTest.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/VersionsTest.java Tue Aug 18 14:27:55 2009
@@ -0,0 +1,380 @@
+/*
+ * Licensed 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.
+ *
+ * Authors:
+ *     David Caruana, Alfresco
+ *     Gabriele Columbro, Alfresco
+ */
+package org.apache.chemistry.tck.atompub.test.spec;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.abdera.i18n.iri.IRI;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.model.Link;
+import org.apache.chemistry.abdera.ext.CMISConstants;
+import org.apache.chemistry.abdera.ext.CMISObject;
+import org.apache.chemistry.tck.atompub.TCKTest;
+import org.apache.chemistry.tck.atompub.http.DeleteRequest;
+import org.apache.chemistry.tck.atompub.http.GetRequest;
+import org.apache.chemistry.tck.atompub.http.PatchRequest;
+import org.apache.chemistry.tck.atompub.http.PostRequest;
+import org.apache.chemistry.tck.atompub.http.PutRequest;
+import org.apache.chemistry.tck.atompub.http.Request;
+import org.apache.chemistry.tck.atompub.http.Response;
+import org.junit.Assert;
+
+
+/**
+ * CMIS Versions Tests
+ */
+public class VersionsTest extends TCKTest {
+    
+    @Override
+    public void tearDown() throws Exception {
+        // cancel any outstanding checkouts
+        Entry testFolder = fixture.getTestCaseFolder();
+        CMISObject object = testFolder.getExtension(CMISConstants.OBJECT);
+        String scopeId = object.getObjectId().getStringValue();
+        Map<String, String> args = new HashMap<String, String>();
+        args.put("folderId", scopeId);
+        IRI checkedoutHREF = client.getCheckedOutCollection(client.getWorkspace());
+        Feed checkedout = client.getFeed(new IRI(checkedoutHREF.toString()), args);
+        Assert.assertNotNull(checkedout);
+
+        for (Entry pwc : checkedout.getEntries()) {
+            client.executeRequest(new DeleteRequest(pwc.getSelfLink().getHref().toString()), 204);
+        }
+
+        super.tearDown();
+    }
+    
+    public void testGetCheckedOut() throws Exception {
+        // retrieve test folder for checkouts
+        Entry testFolder = fixture.getTestCaseFolder();
+        CMISObject object = testFolder.getExtension(CMISConstants.OBJECT);
+        String scopeId = object.getObjectId().getStringValue();
+        Assert.assertNotNull(scopeId);
+
+        // retrieve checkouts within scope of test checkout folder
+        IRI checkedoutHREF = client.getCheckedOutCollection(client.getWorkspace());
+        Map<String, String> args = new HashMap<String, String>();
+        args.put("folderId", scopeId);
+        Feed checkedout = client.getFeed(new IRI(checkedoutHREF.toString()), args);
+        Assert.assertNotNull(checkedout);
+        Assert.assertEquals(0, checkedout.getEntries().size());
+    }
+
+    public void testCheckout() throws Exception {
+        // create document for checkout
+        Entry document = fixture.createTestDocument("testCheckout");
+        CMISObject docObject = document.getExtension(CMISConstants.OBJECT);
+        Request documentReq = new GetRequest(document.getSelfLink().getHref().toString());
+        Response documentRes = client.executeRequest(documentReq, 200, client.getAtomValidator());
+        Assert.assertNotNull(documentRes);
+        String documentXML = documentRes.getContentAsString();
+        Assert.assertNotNull(documentXML);
+
+        // checkout
+        IRI checkedoutHREF = client.getCheckedOutCollection(client.getWorkspace());
+        Request checkoutReq = new PostRequest(checkedoutHREF.toString(), documentXML, CMISConstants.MIMETYPE_ENTRY);
+        Response pwcRes = client.executeRequest(checkoutReq, 201, client.getAtomValidator());
+        Assert.assertNotNull(pwcRes);
+        String pwcXml = pwcRes.getContentAsString();
+        Assert.assertNotNull(pwcXml);
+        Entry pwc = model.parseEntry(new StringReader(pwcXml), null);
+        Assert.assertNotNull(pwc);
+        CMISObject pwcObject = pwc.getExtension(CMISConstants.OBJECT);
+        Assert.assertNotNull(pwcObject);
+        Assert.assertTrue(pwcObject.isVersionSeriesCheckedOut().getBooleanValue());
+        Assert.assertEquals(docObject.getObjectId().getStringValue(), pwcObject.getVersionSeriesId().getStringValue());
+        Assert.assertEquals(pwcObject.getObjectId().getStringValue(), pwcObject.getVersionSeriesCheckedOutId().getStringValue());
+        Assert.assertNotNull(pwcObject.getVersionSeriesCheckedOutBy().getStringValue());
+
+        // retrieve pwc directly
+        Response pwcGetRes = client.executeRequest(new GetRequest(pwc.getSelfLink().getHref().toString()), 200);
+        Assert.assertNotNull(pwcGetRes);
+        String pwcGetXml = pwcRes.getContentAsString();
+        Entry pwcGet = model.parseEntry(new StringReader(pwcGetXml), null);
+        Assert.assertNotNull(pwcGet);
+        CMISObject pwcGetObject = pwc.getExtension(CMISConstants.OBJECT);
+        Assert.assertNotNull(pwcGetObject);
+        Assert.assertTrue(pwcGetObject.isVersionSeriesCheckedOut().getBooleanValue());
+        Assert.assertEquals(docObject.getObjectId().getStringValue(), pwcGetObject.getVersionSeriesId().getStringValue());
+        Assert.assertEquals(pwcGetObject.getObjectId().getStringValue(), pwcGetObject.getVersionSeriesCheckedOutId().getStringValue());
+        Assert.assertNotNull(pwcGetObject.getVersionSeriesCheckedOutBy().getStringValue());
+
+        // test getCheckedOut is updated
+        Entry testFolder = fixture.getTestCaseFolder();
+        CMISObject object = testFolder.getExtension(CMISConstants.OBJECT);
+        String scopeId = object.getObjectId().getStringValue();
+        Map<String, String> args = new HashMap<String, String>();
+        args.put("folderId", scopeId);
+        Feed checkedout = client.getFeed(new IRI(checkedoutHREF.toString()), args);
+        Assert.assertNotNull(checkedout);
+        Assert.assertEquals(1, checkedout.getEntries().size());
+    }
+
+    public void testCancelCheckout() throws Exception {
+        // create document for checkout
+        Entry document = fixture.createTestDocument("testCancelCheckout");
+        Request documentReq = new GetRequest(document.getSelfLink().getHref().toString());
+        Response documentRes = client.executeRequest(documentReq, 200, client.getAtomValidator());
+        Assert.assertNotNull(documentRes);
+        String xml = documentRes.getContentAsString();
+        Assert.assertNotNull(xml);
+
+        // checkout
+        IRI checkedoutHREF = client.getCheckedOutCollection(client.getWorkspace());
+        Request checkoutReq = new PostRequest(checkedoutHREF.toString(), xml, CMISConstants.MIMETYPE_ENTRY);
+        Response pwcRes = client.executeRequest(checkoutReq, 201, client.getAtomValidator());
+        Assert.assertNotNull(pwcRes);
+        String pwcXml = pwcRes.getContentAsString();
+
+        // test getCheckedOut is updated
+        Entry testFolder = fixture.getTestCaseFolder();
+        CMISObject object = testFolder.getExtension(CMISConstants.OBJECT);
+        String scopeId = object.getObjectId().getStringValue();
+        Map<String, String> args = new HashMap<String, String>();
+        args.put("folderId", scopeId);
+        Feed checkedout = client.getFeed(new IRI(checkedoutHREF.toString()), args);
+        Assert.assertNotNull(checkedout);
+        Assert.assertEquals(1, checkedout.getEntries().size());
+
+        // cancel checkout
+        Entry pwc = model.parseEntry(new StringReader(pwcXml), null);
+        Assert.assertNotNull(pwc);
+        Response cancelRes = client.executeRequest(new DeleteRequest(pwc.getSelfLink().getHref().toString()), 204);
+        Assert.assertNotNull(cancelRes);
+
+        // test getCheckedOut is updated
+        Feed checkedout2 = client.getFeed(new IRI(checkedoutHREF.toString()), args);
+        Assert.assertNotNull(checkedout2);
+        Assert.assertEquals(0, checkedout2.getEntries().size());
+    }
+
+    public void testCheckIn() throws Exception {
+        // create document for checkout
+        Entry document = fixture.createTestDocument("testCheckin");
+        Request documentReq = new GetRequest(document.getSelfLink().getHref().toString());
+        Response documentRes = client.executeRequest(documentReq, 200, client.getAtomValidator());
+        Assert.assertNotNull(documentRes);
+        String xml = documentRes.getContentAsString();
+        Assert.assertNotNull(xml);
+
+        // checkout
+        IRI checkedoutHREF = client.getCheckedOutCollection(client.getWorkspace());
+        Request checkoutReq = new PostRequest(checkedoutHREF.toString(), xml, CMISConstants.MIMETYPE_ENTRY);
+        Response pwcRes = client.executeRequest(checkoutReq, 201, client.getAtomValidator());
+        Assert.assertNotNull(pwcRes);
+        Entry pwc = model.parseEntry(new StringReader(pwcRes.getContentAsString()), null);
+        Assert.assertNotNull(pwc);
+
+        // test getCheckedOut is updated
+        Entry testFolder = fixture.getTestCaseFolder();
+        CMISObject object = testFolder.getExtension(CMISConstants.OBJECT);
+        String scopeId = object.getObjectId().getStringValue();
+        Map<String, String> args = new HashMap<String, String>();
+        args.put("folderId", scopeId);
+        Feed checkedout = client.getFeed(new IRI(checkedoutHREF.toString()), args);
+        Assert.assertNotNull(checkedout);
+        Assert.assertEquals(1, checkedout.getEntries().size());
+
+        // test version properties of checked-out item
+        // test checked-in version properties
+        Entry checkedoutdoc = client.getEntry(document.getSelfLink().getHref());
+        CMISObject checkedoutdocObject = checkedoutdoc.getExtension(CMISConstants.OBJECT);
+        Assert.assertNotNull(checkedoutdocObject);
+        Assert.assertTrue(checkedoutdocObject.isVersionSeriesCheckedOut().getBooleanValue());
+        // Assert.assertEquals(checkedoutdocObject.getObjectId().getStringValue(),
+        // checkedoutdocObject.getVersionSeriesId().getStringValue());
+        Assert.assertNotNull(checkedoutdocObject.getVersionSeriesCheckedOutId().getStringValue());
+        Assert.assertNotNull(checkedoutdocObject.getVersionSeriesCheckedOutBy().getStringValue());
+
+        // test update of private working copy
+        String updateFile = templates.load("updatedocument.atomentry.xml");
+        // FIXME: Add a decent UID generation policy
+        // String guid = GUID.generate();
+        String guid = System.currentTimeMillis() + "";
+        updateFile = updateFile.replace("${NAME}", guid);
+        Request updateReq = new PatchRequest(pwc.getEditLink().getHref().toString(), updateFile, CMISConstants.MIMETYPE_ENTRY);
+        Response pwcUpdatedres = client.executeRequest(updateReq, 200, client.getAtomValidator());
+        Assert.assertNotNull(pwcUpdatedres);
+        Entry updated = model.parseEntry(new StringReader(pwcUpdatedres.getContentAsString()), null);
+        // ensure update occurred
+        Assert.assertEquals(pwc.getId(), updated.getId());
+        Assert.assertEquals(pwc.getPublished(), updated.getPublished());
+        Assert.assertEquals("Updated Title " + guid, updated.getTitle());
+        Assert.assertEquals("text/plain", updated.getContentMimeType().toString());
+        Response pwcContentRes = client.executeRequest(new GetRequest(pwc.getContentSrc().toString()), 200);
+        Assert.assertEquals("updated content " + guid, pwcContentRes.getContentAsString());
+
+        // checkin
+        String checkinFile = templates.load("checkindocument.atomentry.xml");
+        String checkinUrl = pwc.getSelfLink().getHref().toString();
+        Map<String, String> args2 = new HashMap<String, String>();
+        args2.put("checkinComment", guid);
+        args2.put("checkin", "true");
+        Request checkinReq = new PatchRequest(checkinUrl, checkinFile, CMISConstants.MIMETYPE_ENTRY).setArgs(args2);
+        Response checkinRes = client.executeRequest(checkinReq, 200, client.getAtomValidator());
+        Assert.assertNotNull(checkinRes);
+        String checkinResXML = checkinRes.getContentAsString();
+
+        // test getCheckedOut is updated
+        Feed checkedout2 = client.getFeed(new IRI(checkedoutHREF.toString()), args);
+        Assert.assertNotNull(checkedout2);
+        Assert.assertEquals(0, checkedout2.getEntries().size());
+
+        // test checked-in doc has new updates
+        Entry checkedIn = model.parseEntry(new StringReader(checkinResXML), null);
+        Entry updatedDoc = client.getEntry(checkedIn.getSelfLink().getHref());
+        // TODO: issue with updating name on PWC and it not reflecting on
+        // checked-in document
+        // Assert.assertEquals("Updated Title " + guid, updatedDoc.getTitle());
+        Assert.assertEquals("text/plain", updatedDoc.getContentMimeType().toString());
+        Response updatedContentRes = client.executeRequest(new GetRequest(updatedDoc.getContentSrc().toString()), 200);
+        Assert.assertEquals("updated content " + guid, updatedContentRes.getContentAsString());
+
+        // test checked-in version properties
+        CMISObject updatedObject = updatedDoc.getExtension(CMISConstants.OBJECT);
+        Assert.assertNotNull(updatedObject);
+        Assert.assertFalse(updatedObject.isVersionSeriesCheckedOut().getBooleanValue());
+        // Assert.assertEquals(updatedObject.getObjectId().getStringValue(),
+        // updatedObject.getVersionSeriesId().getStringValue());
+        Assert.assertNull(updatedObject.getVersionSeriesCheckedOutId().getStringValue());
+        Assert.assertNull(updatedObject.getVersionSeriesCheckedOutBy().getStringValue());
+        Assert.assertEquals(guid, updatedObject.getCheckinComment().getStringValue());
+    }
+
+    public void testUpdateOnCheckIn() throws Exception {
+        // create document for checkout
+        Entry document = fixture.createTestDocument("testUpdateOnCheckIn");
+        Request documentReq = new GetRequest(document.getSelfLink().getHref().toString());
+        Response documentRes = client.executeRequest(documentReq, 200, client.getAtomValidator());
+        Assert.assertNotNull(documentRes);
+        String xml = documentRes.getContentAsString();
+        Assert.assertNotNull(xml);
+
+        // checkout
+        IRI checkedoutHREF = client.getCheckedOutCollection(client.getWorkspace());
+        Request checkoutReq = new PostRequest(checkedoutHREF.toString(), xml, CMISConstants.MIMETYPE_ENTRY);
+        Response pwcRes = client.executeRequest(checkoutReq, 201, client.getAtomValidator());
+        Assert.assertNotNull(pwcRes);
+        Entry pwc = model.parseEntry(new StringReader(pwcRes.getContentAsString()), null);
+        Assert.assertNotNull(pwc);
+
+        // test getCheckedOut is updated
+        Entry testFolder = fixture.getTestCaseFolder();
+        CMISObject object = testFolder.getExtension(CMISConstants.OBJECT);
+        String scopeId = object.getObjectId().getStringValue();
+        Map<String, String> args = new HashMap<String, String>();
+        args.put("folderId", scopeId);
+        Feed checkedout = client.getFeed(new IRI(checkedoutHREF.toString()), args);
+        Assert.assertNotNull(checkedout);
+        Assert.assertEquals(1, checkedout.getEntries().size());
+
+        // checkin (with update)
+        String checkinFile = templates.load("checkinandupdatedocument.atomentry.xml");
+        // FIXME: Add a decent UID generation policy
+        // String guid = GUID.generate();
+        String guid = System.currentTimeMillis() + "";
+        checkinFile = checkinFile.replace("${NAME}", guid);
+        String checkinUrl = pwc.getSelfLink().getHref().toString();
+        Map<String, String> args2 = new HashMap<String, String>();
+        args2.put("checkinComment", guid);
+        args2.put("checkin", "true");
+        Request checkinReq = new PatchRequest(checkinUrl, checkinFile, CMISConstants.MIMETYPE_ENTRY).setArgs(args2);
+        Response checkinRes = client.executeRequest(checkinReq, 200, client.getAtomValidator());
+        Assert.assertNotNull(checkinRes);
+        String checkinResXML = checkinRes.getContentAsString();
+
+        // test getCheckedOut is updated
+        Feed checkedout2 = client.getFeed(new IRI(checkedoutHREF.toString()), args);
+        Assert.assertNotNull(checkedout2);
+        Assert.assertEquals(0, checkedout2.getEntries().size());
+
+        // test checked-in doc has new updates
+        Entry checkedIn = model.parseEntry(new StringReader(checkinResXML), null);
+        Entry updatedDoc = client.getEntry(checkedIn.getSelfLink().getHref());
+        // TODO: issue with updating name on PWC and it not reflecting on
+        // checked-in document
+        // Assert.assertEquals("Updated Title " + guid, updatedDoc.getTitle());
+        Assert.assertEquals("text/plain", updatedDoc.getContentMimeType().toString());
+        Response updatedContentRes = client.executeRequest(new GetRequest(updatedDoc.getContentSrc().toString()), 200);
+        Assert.assertEquals("updated content " + guid, updatedContentRes.getContentAsString());
+    }
+
+    public void testGetAllVersions() throws Exception {
+        int NUMBER_OF_VERSIONS = 3;
+
+        // create document for checkout
+        Entry document = fixture.createTestDocument("testGetAllVersions");
+        Request documentReq = new GetRequest(document.getSelfLink().getHref().toString());
+        Response documentRes = client.executeRequest(documentReq, 200, client.getAtomValidator());
+        Assert.assertNotNull(documentRes);
+        String xml = documentRes.getContentAsString();
+        Assert.assertNotNull(xml);
+
+        IRI checkedoutHREF = client.getCheckedOutCollection(client.getWorkspace());
+        for (int i = 0; i < NUMBER_OF_VERSIONS; i++) {
+            // checkout
+            Request checkoutReq = new PostRequest(checkedoutHREF.toString(), xml, CMISConstants.MIMETYPE_ENTRY);
+            Response pwcRes = client.executeRequest(checkoutReq, 201, client.getAtomValidator());
+            Assert.assertNotNull(pwcRes);
+            Entry pwc = model.parseEntry(new StringReader(pwcRes.getContentAsString()), null);
+            Assert.assertNotNull(pwc);
+
+            // checkin
+            String checkinFile = templates.load("checkinandupdatedocument.atomentry.xml");
+            checkinFile = checkinFile.replace("${NAME}", "checkin " + i);
+            String checkinUrl = pwc.getSelfLink().getHref().toString();
+            Map<String, String> args2 = new HashMap<String, String>();
+            args2.put("checkinComment", "checkin" + i);
+            args2.put("checkin", "true");
+            Request checkinReq = new PutRequest(checkinUrl, checkinFile, CMISConstants.MIMETYPE_ENTRY).setArgs(args2);
+            Response checkinRes = client.executeRequest(checkinReq, 200, client.getAtomValidator());
+            Assert.assertNotNull(checkinRes);
+
+            // use result of checkin (i.e. document returned), for next checkout
+            xml = checkinRes.getContentAsString();
+            Assert.assertNotNull(xml);
+        }
+
+        // get all versions
+        Link allVersionsLink = document.getLink(CMISConstants.REL_VERSION_HISTORY);
+        Assert.assertNotNull(allVersionsLink);
+        Feed allVersions = client.getFeed(allVersionsLink.getHref());
+        Assert.assertNotNull(allVersions);
+        Assert.assertEquals(NUMBER_OF_VERSIONS + 1 /** initial version */
+        , allVersions.getEntries().size());
+        for (int i = 0; i < NUMBER_OF_VERSIONS; i++) {
+            Link versionLink = allVersions.getEntries().get(i).getSelfLink();
+            Assert.assertNotNull(versionLink);
+            Entry version = client.getEntry(versionLink.getHref());
+            Assert.assertNotNull(version);
+            // TODO: issue with updating name on PWC and it not reflecting on
+            // checked-in document
+            // Assert.assertEquals("Update Title checkin " + i,
+            // version.getTitle());
+            Response versionContentRes = client.executeRequest(new GetRequest(version.getContentSrc().toString()), 200);
+            Assert.assertEquals("updated content checkin " + (NUMBER_OF_VERSIONS - 1 - i), versionContentRes.getContentAsString());
+            CMISObject versionObject = version.getExtension(CMISConstants.OBJECT);
+            Assert.assertNotNull(versionObject);
+            Assert.assertEquals("checkin" + +(NUMBER_OF_VERSIONS - 1 - i), versionObject.getCheckinComment().getStringValue());
+        }
+    }
+
+}

Propchange: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/VersionsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/log4j.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/log4j.xml?rev=805426&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/log4j.xml (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/log4j.xml Tue Aug 18 14:27:55 2009
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+  <appender name="console" class="org.apache.log4j.ConsoleAppender">
+    <param name="Target" value="System.out" />
+    <layout class="org.apache.log4j.PatternLayout">
+      <param name="ConversionPattern" value="%-5p %c{1} - %m%n" />
+    </layout>
+  </appender>
+
+  <logger name="org.apache.commons.httpclient.HttpMethodBase">
+    <level value="error" />
+  </logger>
+
+  <logger name="org.apache.chemistry.tck.atompub.TCKLogger">
+    <level value="info" />
+  </logger>
+
+  <root>
+    <priority value="warn" />
+    <appender-ref ref="console" />
+  </root>
+
+</log4j:configuration>
\ No newline at end of file

Propchange: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/log4j.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/org/apache/chemistry/tck/atompub/templates/custom/createcustomdocument.atomentry.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/org/apache/chemistry/tck/atompub/templates/custom/createcustomdocument.atomentry.xml?rev=805426&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/org/apache/chemistry/tck/atompub/templates/custom/createcustomdocument.atomentry.xml (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/org/apache/chemistry/tck/atompub/templates/custom/createcustomdocument.atomentry.xml Tue Aug 18 14:27:55 2009
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200901" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200901">
+  <title>${NAME}</title>
+  <summary>${NAME} (summary)</summary>
+  <content type="text/html">${CONTENT}</content>
+  <cmisra:object>
+    <cmis:properties>
+      <cmis:propertyId pdid="cmis:ObjectTypeId">
+        <cmis:value>D/cmiscustom:document</cmis:value>
+      </cmis:propertyId>
+      <cmis:propertyString pdid="cmiscustom:docprop_string">
+        <cmis:value>custom string</cmis:value>
+      </cmis:propertyString>
+      <cmis:propertyBoolean pdid="cmiscustom:docprop_boolean_multi">
+        <cmis:value>true</cmis:value>
+        <cmis:value>false</cmis:value>
+      </cmis:propertyBoolean>
+    </cmis:properties>
+  </cmisra:object>
+</entry>

Propchange: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/org/apache/chemistry/tck/atompub/templates/custom/createcustomdocument.atomentry.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/org/apache/chemistry/tck/atompub/templates/custom/createcustomfolder.atomentry.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/org/apache/chemistry/tck/atompub/templates/custom/createcustomfolder.atomentry.xml?rev=805426&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/org/apache/chemistry/tck/atompub/templates/custom/createcustomfolder.atomentry.xml (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/org/apache/chemistry/tck/atompub/templates/custom/createcustomfolder.atomentry.xml Tue Aug 18 14:27:55 2009
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200901" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200901">
+  <title>${NAME}</title>
+  <summary>${NAME} (summary)</summary>
+  <cmisra:object>
+    <cmis:properties>
+      <cmis:propertyId pdid="cmis:ObjectTypeId">
+        <cmis:value>F/cmiscustom:folder</cmis:value>
+      </cmis:propertyId>
+      <cmis:propertyString pdid="cmiscustom:folderprop_string">
+        <cmis:value>custom string</cmis:value>
+      </cmis:propertyString>
+    </cmis:properties>
+  </cmisra:object>
+</entry>

Propchange: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/org/apache/chemistry/tck/atompub/templates/custom/createcustomfolder.atomentry.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/org/apache/chemistry/tck/atompub/templates/custom/updatecustomdocument.atomentry.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/org/apache/chemistry/tck/atompub/templates/custom/updatecustomdocument.atomentry.xml?rev=805426&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/org/apache/chemistry/tck/atompub/templates/custom/updatecustomdocument.atomentry.xml (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/org/apache/chemistry/tck/atompub/templates/custom/updatecustomdocument.atomentry.xml Tue Aug 18 14:27:55 2009
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200901" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200901">
+  <title>Updated Title ${NAME}</title>
+  <cmisra:object>
+    <cmis:properties>
+      <cmis:propertyString pdid="cmiscustom:docprop_string">
+        <cmis:value>custom ${NAME}</cmis:value>
+      </cmis:propertyString>
+      <cmis:propertyBoolean pdid="cmiscustom:docprop_boolean_multi">
+        <cmis:value>false</cmis:value>
+        <cmis:value>true</cmis:value>
+      </cmis:propertyBoolean>
+    </cmis:properties>
+  </cmisra:object>
+</entry>

Propchange: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/org/apache/chemistry/tck/atompub/templates/custom/updatecustomdocument.atomentry.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/chemistry/trunk/chemistry/pom.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/pom.xml?rev=805426&r1=805425&r2=805426&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/pom.xml (original)
+++ incubator/chemistry/trunk/chemistry/pom.xml Tue Aug 18 14:27:55 2009
@@ -39,6 +39,7 @@
     <module>chemistry-atompub-client</module>
     <module>chemistry-ws</module>
     <module>chemistry-jcr</module>
+    <module>chemistry-tck-atompub</module>
   </modules>
 
 </project>



Mime
View raw message