diff --git a/config/alfresco/public-rest-context.xml b/config/alfresco/public-rest-context.xml index f31a6617ac..2f9d7041b6 100644 --- a/config/alfresco/public-rest-context.xml +++ b/config/alfresco/public-rest-context.xml @@ -1,985 +1,976 @@ - - - - - true - alfresco/templates/publicapi - - - - - - - - - - - - - - - - - - - webscript.default - - - - - - - - - - - - - - - - - - - Public Api - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - alfresco.messages.rest-framework-messages - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.comments.comment-created - org.alfresco.comments.comment-updated - org.alfresco.comments.comment-deleted - - - - - - - - - org.alfresco.documentlibrary.files-added - org.alfresco.documentlibrary.files-updated - org.alfresco.documentlibrary.files-deleted - org.alfresco.documentlibrary.file-added - org.alfresco.documentlibrary.file-created - org.alfresco.documentlibrary.file-deleted - org.alfresco.documentlibrary.file-liked - org.alfresco.documentlibrary.inline-edit - org.alfresco.documentlibrary.folder-liked - org.alfresco.documentlibrary.folder-added - org.alfresco.documentlibrary.folder-deleted - org.alfresco.documentlibrary.folders-added - org.alfresco.documentlibrary.folders-deleted - - - - - - - - - org.alfresco.site.user-joined - org.alfresco.site.user-left - org.alfresco.site.user-role-changed - org.alfresco.site.group-added - org.alfresco.site.group-removed - org.alfresco.site.group-role-changed - - - - - - - - - org.alfresco.discussions.reply-created - - - - - - - - - org.alfresco.subscriptions.followed - org.alfresco.subscriptions.subscribed - - - - - - - - - org.alfresco.wiki.page-created - org.alfresco.wiki.page-edited - org.alfresco.wiki.page-renamed - org.alfresco.wiki.page-deleted - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.rest.api.Activities - - - - - - - - - - - - - - - - - - - - - - - - {http://www.alfresco.org/model/content/1.0}folder - {http://www.alfresco.org/model/content/1.0}content - {http://www.alfresco.org/model/cmis/custom}* - - - - - {http://www.alfresco.org/model/forum/1.0}forums - {http://www.alfresco.org/model/forum/1.0}forum - {http://www.alfresco.org/model/forum/1.0}topic - {http://www.alfresco.org/model/forum/1.0}post - {http://www.alfresco.org/model/content/1.0}category - - - - - - - - - org.alfresco.rest.api.Comments - - - - - - - - - - - - - - - - - - - - - {http://www.alfresco.org/model/content/1.0}folder - {http://www.alfresco.org/model/content/1.0}content - {http://www.alfresco.org/model/cmis/custom}* - - - - - {http://www.alfresco.org/model/forum/1.0}forums - {http://www.alfresco.org/model/forum/1.0}forum - {http://www.alfresco.org/model/forum/1.0}topic - {http://www.alfresco.org/model/forum/1.0}post - {http://www.alfresco.org/model/content/1.0}category - - - - - - - - - org.alfresco.rest.api.NodeRatings - - - - - - - - - - - - - - - - - - - - org.alfresco.rest.api.Nodes - - - - - - - - - - - - - - - - - - - - - - org.alfresco.rest.api.Favourites - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.rest.api.SiteMembershipRequests - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.rest.api.People - - - - - - - - - - - - - - - - - - - org.alfresco.rest.api.Preferences - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.rest.api.Sites - - - - - - - - - - - - - - - - - - - - {http://www.alfresco.org/model/content/1.0}folder - {http://www.alfresco.org/model/content/1.0}content - {http://www.alfresco.org/model/cmis/custom}* - - - - - {http://www.alfresco.org/model/forum/1.0}forums - {http://www.alfresco.org/model/forum/1.0}forum - {http://www.alfresco.org/model/forum/1.0}topic - {http://www.alfresco.org/model/forum/1.0}post - {http://www.alfresco.org/model/content/1.0}category - - - - - - - - - org.alfresco.rest.api.Tags - - - - - - - - - - - - - - - - - - - org.alfresco.rest.api.Networks - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.rest.workflow.api.Deployments - - - - - - - - - - - - - - - - - - - - org.alfresco.rest.workflow.api.ProcessDefinitions - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.rest.workflow.api.Processes - - - - - - - - - - - - - - - - - - - org.alfresco.rest.workflow.api.Tasks - - - - - - - - - - - - - - - - org.alfresco.rest.workflow.api.Activities - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + true + alfresco/templates/publicapi + + + + + + + + + + + + + + + + + + + webscript.default + + + + + + + + + + + + + + + + + + + Public Api + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + alfresco.messages.rest-framework-messages + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.comments.comment-created + org.alfresco.comments.comment-updated + org.alfresco.comments.comment-deleted + + + + + + + + + org.alfresco.documentlibrary.files-added + org.alfresco.documentlibrary.files-updated + org.alfresco.documentlibrary.files-deleted + org.alfresco.documentlibrary.file-added + org.alfresco.documentlibrary.file-created + org.alfresco.documentlibrary.file-deleted + org.alfresco.documentlibrary.file-liked + org.alfresco.documentlibrary.inline-edit + org.alfresco.documentlibrary.folder-liked + org.alfresco.documentlibrary.folder-added + org.alfresco.documentlibrary.folder-deleted + org.alfresco.documentlibrary.folders-added + org.alfresco.documentlibrary.folders-deleted + + + + + + + + + org.alfresco.site.user-joined + org.alfresco.site.user-left + org.alfresco.site.user-role-changed + org.alfresco.site.group-added + org.alfresco.site.group-removed + org.alfresco.site.group-role-changed + + + + + + + + + org.alfresco.discussions.reply-created + + + + + + + + + org.alfresco.subscriptions.followed + org.alfresco.subscriptions.subscribed + + + + + + + + + org.alfresco.wiki.page-created + org.alfresco.wiki.page-edited + org.alfresco.wiki.page-renamed + org.alfresco.wiki.page-deleted + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.rest.api.Activities + + + + + + + + + + + + + + + + + + + + + + + + {http://www.alfresco.org/model/content/1.0}folder + {http://www.alfresco.org/model/content/1.0}content + {http://www.alfresco.org/model/cmis/custom}* + + + + + {http://www.alfresco.org/model/forum/1.0}forums + {http://www.alfresco.org/model/forum/1.0}forum + {http://www.alfresco.org/model/forum/1.0}topic + {http://www.alfresco.org/model/forum/1.0}post + {http://www.alfresco.org/model/content/1.0}category + + + + + + + + + org.alfresco.rest.api.Comments + + + + + + + + + + + + + + + + + + + + + {http://www.alfresco.org/model/content/1.0}folder + {http://www.alfresco.org/model/content/1.0}content + {http://www.alfresco.org/model/cmis/custom}* + + + + + {http://www.alfresco.org/model/forum/1.0}forums + {http://www.alfresco.org/model/forum/1.0}forum + {http://www.alfresco.org/model/forum/1.0}topic + {http://www.alfresco.org/model/forum/1.0}post + {http://www.alfresco.org/model/content/1.0}category + + + + + + + + + org.alfresco.rest.api.NodeRatings + + + + + + + + + + + + + + + + + + + + org.alfresco.rest.api.Nodes + + + + + + + + + + + + + + + + + + + + + + org.alfresco.rest.api.Favourites + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.rest.api.SiteMembershipRequests + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.rest.api.People + + + + + + + + + + + + + + + + + + + org.alfresco.rest.api.Preferences + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.rest.api.Sites + + + + + + + + + + + + + + + + + + + + {http://www.alfresco.org/model/content/1.0}folder + {http://www.alfresco.org/model/content/1.0}content + {http://www.alfresco.org/model/cmis/custom}* + + + + + {http://www.alfresco.org/model/forum/1.0}forums + {http://www.alfresco.org/model/forum/1.0}forum + {http://www.alfresco.org/model/forum/1.0}topic + {http://www.alfresco.org/model/forum/1.0}post + {http://www.alfresco.org/model/content/1.0}category + + + + + + + + + org.alfresco.rest.api.Tags + + + + + + + + + + + + + + + + + + + org.alfresco.rest.api.Networks + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.rest.workflow.api.Deployments + + + + + + + + + + + + + + + + + + + + org.alfresco.rest.workflow.api.ProcessDefinitions + + + + + + + + + + + + + + + + + + + + + + + + + org.alfresco.rest.workflow.api.Processes + + + + + + + + + + + + + + + + + + + org.alfresco.rest.workflow.api.Tasks + + + + + + + + + + + + + + + + org.alfresco.rest.workflow.api.Activities + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index 4646385e3f..0209178938 100644 --- a/pom.xml +++ b/pom.xml @@ -114,7 +114,7 @@ org.alfresco.cmis.client alfresco-opencmis-extension - 0.6 + 0.7 junit diff --git a/source/java/org/alfresco/opencmis/CMISServletDispatcher.java b/source/java/org/alfresco/opencmis/CMISServletDispatcher.java index 41d8d14be8..f35f2c6709 100644 --- a/source/java/org/alfresco/opencmis/CMISServletDispatcher.java +++ b/source/java/org/alfresco/opencmis/CMISServletDispatcher.java @@ -193,6 +193,7 @@ public abstract class CMISServletDispatcher implements CMISDispatcher CMISServletConfig() { parameterNames.add(CmisAtomPubServlet.PARAM_CALL_CONTEXT_HANDLER); + parameterNames.add(CmisAtomPubServlet.PARAM_CMIS_VERSION); } @Override diff --git a/source/java/org/alfresco/rest/api/PublicApiTenantWebScriptServletRuntime.java b/source/java/org/alfresco/rest/api/PublicApiTenantWebScriptServletRuntime.java index 657cdcf6e4..55c7838d5d 100644 --- a/source/java/org/alfresco/rest/api/PublicApiTenantWebScriptServletRuntime.java +++ b/source/java/org/alfresco/rest/api/PublicApiTenantWebScriptServletRuntime.java @@ -67,7 +67,7 @@ public class PublicApiTenantWebScriptServletRuntime extends TenantWebScriptServl } else { - if(!pathInfo.toLowerCase().equals("/cmis")) + if(!pathInfo.substring(0, 5).toLowerCase().equals("/cmis")) { // remove tenant int idx = pathInfo.indexOf('/', 1); diff --git a/source/test-java/org/alfresco/rest/api/tests/AbstractEnterpriseOpenCMISTCKTest.java b/source/test-java/org/alfresco/rest/api/tests/AbstractEnterpriseOpenCMISTCKTest.java index 9b03318fc8..890cdae9e7 100644 --- a/source/test-java/org/alfresco/rest/api/tests/AbstractEnterpriseOpenCMISTCKTest.java +++ b/source/test-java/org/alfresco/rest/api/tests/AbstractEnterpriseOpenCMISTCKTest.java @@ -18,34 +18,7 @@ */ package org.alfresco.rest.api.tests; -import java.util.Map; - import org.alfresco.opencmis.OpenCMISClientContext; -import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTestGroup; -import org.apache.chemistry.opencmis.tck.impl.JUnitHelper; -import org.apache.chemistry.opencmis.tck.tests.basics.BasicsTestGroup; -import org.apache.chemistry.opencmis.tck.tests.control.ControlTestGroup; -import org.apache.chemistry.opencmis.tck.tests.crud.BulkUpdatePropertiesTest; -import org.apache.chemistry.opencmis.tck.tests.crud.ContentRangesTest; -import org.apache.chemistry.opencmis.tck.tests.crud.CopyTest; -import org.apache.chemistry.opencmis.tck.tests.crud.CreateAndDeleteDocumentTest; -import org.apache.chemistry.opencmis.tck.tests.crud.CreateAndDeleteFolderTest; -import org.apache.chemistry.opencmis.tck.tests.crud.CreateAndDeleteItemTest; -import org.apache.chemistry.opencmis.tck.tests.crud.CreateAndDeleteRelationshipTest; -import org.apache.chemistry.opencmis.tck.tests.crud.CreateBigDocument; -import org.apache.chemistry.opencmis.tck.tests.crud.CreateDocumentWithoutContent; -import org.apache.chemistry.opencmis.tck.tests.crud.DeleteTreeTest; -import org.apache.chemistry.opencmis.tck.tests.crud.MoveTest; -import org.apache.chemistry.opencmis.tck.tests.crud.NameCharsetTest; -import org.apache.chemistry.opencmis.tck.tests.crud.SetAndDeleteContentTest; -import org.apache.chemistry.opencmis.tck.tests.filing.FilingTestGroup; -import org.apache.chemistry.opencmis.tck.tests.query.ContentChangesSmokeTest; -import org.apache.chemistry.opencmis.tck.tests.query.QueryLikeTest; -import org.apache.chemistry.opencmis.tck.tests.query.QuerySmokeTest; -import org.apache.chemistry.opencmis.tck.tests.versioning.CheckedOutTest; -import org.apache.chemistry.opencmis.tck.tests.versioning.VersionDeleteTest; -import org.apache.chemistry.opencmis.tck.tests.versioning.VersioningSmokeTest; -import org.junit.Test; /** * Base class for Chemistry OpenCMIS TCK tests. @@ -56,120 +29,10 @@ import org.junit.Test; public abstract class AbstractEnterpriseOpenCMISTCKTest extends EnterpriseTestApi { protected static OpenCMISClientContext clientContext; - - @Test - public void testCMISTCKBasics() throws Exception - { - BasicsTestGroup basicsTestGroup = new BasicsTestGroup(); - JUnitHelper.run(basicsTestGroup); - } -// @Test - public void testCMISTCKCRUD() throws Exception - { - OverrideCRUDTestGroup crudTestGroup = new OverrideCRUDTestGroup(); - JUnitHelper.run(crudTestGroup); - } - -// @Test - public void testCMISTCKVersioning() throws Exception - { - OverrideVersioningTestGroup versioningTestGroup = new OverrideVersioningTestGroup(); - JUnitHelper.run(versioningTestGroup); - } - -// @Test - public void testCMISTCKFiling() throws Exception - { - FilingTestGroup filingTestGroup = new FilingTestGroup(); - JUnitHelper.run(filingTestGroup); - } - - @Test - public void testCMISTCKControl() throws Exception - { - ControlTestGroup controlTestGroup = new ControlTestGroup(); - JUnitHelper.run(controlTestGroup); - } - - @Test - public void testCMISTCKQuery() throws Exception - { - OverrideQueryTestGroup queryTestGroup = new OverrideQueryTestGroup(); - JUnitHelper.run(queryTestGroup); - } - - class OverrideCRUDTestGroup extends AbstractSessionTestGroup - { - @Override - public void init(Map parameters) throws Exception - { - super.init(parameters); - - setName("CRUD Test Group"); - setDescription("Create, Read, Update, and Delete tests."); - - addTest(new CreateAndDeleteFolderTest()); - addTest(new CreateAndDeleteDocumentTest()); - addTest(new CreateBigDocument()); - addTest(new CreateDocumentWithoutContent()); - addTest(new NameCharsetTest()); - addTest(new CreateAndDeleteRelationshipTest()); - addTest(new CreateAndDeleteItemTest()); - // changes to enable auto versioning have broken this test. Perhaps revert those changes and force the client - // to apply the autoVersioning aspect manually? -// addTest(new UpdateSmokeTest()); - addTest(new BulkUpdatePropertiesTest()); - addTest(new SetAndDeleteContentTest()); - addTest(new ContentRangesTest()); - addTest(new CopyTest()); - addTest(new MoveTest()); - addTest(new DeleteTreeTest()); - } - } - - class OverrideVersioningTestGroup extends AbstractSessionTestGroup - { - @Override - public void init(Map parameters) throws Exception - { - super.init(parameters); - - setName("Versioning Test Group"); - setDescription("Versioning tests."); - - addTest(new VersioningSmokeTest()); - addTest(new VersionDeleteTest()); - // Our versioning and checkout/checkin services don't play nice with the CMIS specification. - // Specifically, creating a document with VersioningState CHECKEDOUT creates a node and a working copy - // node, whereas the CMIS specification requires a document created in this state just have a working - // copy until it is checked in. - // Disable until we figure out a way to resolve it. -// addTest(new VersioningStateCreateTest()); - addTest(new CheckedOutTest()); - } - } - - /** - * Override to OpenCMIS QueryTestGroup to allow me to disable failing tests. - * - * @author steveglover - * - */ - class OverrideQueryTestGroup extends AbstractSessionTestGroup - { - @Override - public void init(Map parameters) throws Exception { - super.init(parameters); - - setName("Query Test Group"); - setDescription("Query and content changes tests."); - - addTest(new QuerySmokeTest()); - // QueryRootFolderTest is currently failing - disable for now - //addTest(new QueryRootFolderTest()); - addTest(new QueryLikeTest()); - addTest(new ContentChangesSmokeTest()); - } - } + @Override + protected TestFixture getTestFixture() throws Exception + { + return TCKEnterpriseTestFixture.getInstance(); + } } diff --git a/source/test-java/org/alfresco/rest/api/tests/ApiTest.java b/source/test-java/org/alfresco/rest/api/tests/ApiTest.java index b80e0c7f43..c3af365f00 100644 --- a/source/test-java/org/alfresco/rest/api/tests/ApiTest.java +++ b/source/test-java/org/alfresco/rest/api/tests/ApiTest.java @@ -27,10 +27,7 @@ import org.junit.runners.Suite; TestPersonSites.class, TestSiteMembershipRequests.class, TestFavourites.class, - TestPublicApi128.class, -// TestEnterpriseAtomPubTCK.class, - TestPublicApiAtomPubTCK.class, - TestPublicApiBrowserTCK.class + TestPublicApi128.class }) public class ApiTest { diff --git a/source/test-java/org/alfresco/rest/api/tests/EnterprisePublicApiTestFixture.java b/source/test-java/org/alfresco/rest/api/tests/EnterprisePublicApiTestFixture.java index 0c00537e53..c07c5c8529 100644 --- a/source/test-java/org/alfresco/rest/api/tests/EnterprisePublicApiTestFixture.java +++ b/source/test-java/org/alfresco/rest/api/tests/EnterprisePublicApiTestFixture.java @@ -11,7 +11,9 @@ public class EnterprisePublicApiTestFixture extends EnterpriseTestFixture "classpath:alfresco/web-scripts-application-context-test.xml", "rest-api-test-context.xml" }; - + + public final static String[] CLASS_LOCATIONS = new String[] {"classpath*:/publicapi/lucene"}; + private static EnterprisePublicApiTestFixture instance; /* diff --git a/source/test-java/org/alfresco/rest/api/tests/RepoService.java b/source/test-java/org/alfresco/rest/api/tests/RepoService.java index 44f80403c8..7d46c3c0f4 100644 --- a/source/test-java/org/alfresco/rest/api/tests/RepoService.java +++ b/source/test-java/org/alfresco/rest/api/tests/RepoService.java @@ -1255,8 +1255,7 @@ public class RepoService public TestPerson createUser() { - int numPeople = people.size(); - String username = "user" + (numPeople + 1); + String username = "user" + System.currentTimeMillis(); PersonInfo personInfo = new PersonInfo("FirstName", "LastName", username, "password", null, "skype", "location", "telephone", "mob", "instant", "google"); TestPerson person = createUser(personInfo); diff --git a/source/test-java/org/alfresco/rest/api/tests/TCKEnterpriseTestFixture.java b/source/test-java/org/alfresco/rest/api/tests/TCKEnterpriseTestFixture.java index 2b0a2b30a2..68b6ee9bcf 100644 --- a/source/test-java/org/alfresco/rest/api/tests/TCKEnterpriseTestFixture.java +++ b/source/test-java/org/alfresco/rest/api/tests/TCKEnterpriseTestFixture.java @@ -11,7 +11,9 @@ public class TCKEnterpriseTestFixture extends EnterpriseTestFixture "classpath:alfresco/web-scripts-application-context-test.xml", "rest-api-test-context.xml" }; - + + public final static String[] CLASS_LOCATIONS = new String[] {"classpath*:/publicapi/solr"}; + private static TCKEnterpriseTestFixture instance; /* @@ -35,7 +37,7 @@ public class TCKEnterpriseTestFixture extends EnterpriseTestFixture @Override protected JettyComponent makeJettyComponent() { - JettyComponent jettyComponent = new CMISTCKJettyComponent(port, contextPath, servletName, configLocations, classLocations); + JettyComponent jettyComponent = new EnterpriseJettyComponent(port, contextPath, configLocations, classLocations); return jettyComponent; } diff --git a/source/test-java/org/alfresco/rest/api/tests/TestCMIS.java b/source/test-java/org/alfresco/rest/api/tests/TestCMIS.java index a5b00c22fa..0bb30ef1ba 100644 --- a/source/test-java/org/alfresco/rest/api/tests/TestCMIS.java +++ b/source/test-java/org/alfresco/rest/api/tests/TestCMIS.java @@ -2,13 +2,14 @@ package org.alfresco.rest.api.tests; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.io.StringWriter; +import java.util.AbstractList; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -19,6 +20,7 @@ import java.util.Set; import org.alfresco.cmis.client.AlfrescoDocument; import org.alfresco.cmis.client.AlfrescoFolder; +import org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl; import org.alfresco.model.ContentModel; import org.alfresco.model.WCMModel; import org.alfresco.opencmis.CMISDispatcherRegistry.Binding; @@ -70,6 +72,7 @@ import org.apache.chemistry.opencmis.client.api.ObjectId; import org.apache.chemistry.opencmis.client.api.OperationContext; import org.apache.chemistry.opencmis.client.api.Relationship; import org.apache.chemistry.opencmis.client.api.Repository; +import org.apache.chemistry.opencmis.client.api.SecondaryType; import org.apache.chemistry.opencmis.client.api.Tree; import org.apache.chemistry.opencmis.client.runtime.OperationContextImpl; import org.apache.chemistry.opencmis.commons.PropertyIds; @@ -101,6 +104,35 @@ public class TestCMIS extends EnterpriseTestApi this.cmisTypeExclusions = (QNameFilter)ctx.getBean("cmisTypeExclusions"); } + private void checkSecondaryTypes(Document doc, Set expectedSecondaryTypes, Set expectedMissingSecondaryTypes) + { + final List secondaryTypesList = doc.getSecondaryTypes(); + assertNotNull(secondaryTypesList); + List secondaryTypes = new AbstractList() + { + @Override + public String get(int index) + { + SecondaryType type = secondaryTypesList.get(index); + return type.getId(); + } + + @Override + public int size() + { + return secondaryTypesList.size(); + } + }; + if(expectedSecondaryTypes != null) + { + assertTrue("Missing secondary types: " + secondaryTypes, secondaryTypes.containsAll(expectedSecondaryTypes)); + } + if(expectedMissingSecondaryTypes != null) + { + assertTrue("Expected missing secondary types but at least one is still present: " + secondaryTypes, !secondaryTypes.containsAll(expectedMissingSecondaryTypes)); + } + } + private String getBareObjectId(String objectId) { int idx = objectId.indexOf(";"); @@ -153,7 +185,7 @@ public class TestCMIS extends EnterpriseTestApi }, personId, network1.getId()); publicApiClient.setRequestContext(new RequestContext(network1.getId(), personId)); - CmisSession cmisSession = publicApiClient.createPublicApiCMISSession(Binding.atom, "1.0"); + CmisSession cmisSession = publicApiClient.createPublicApiCMISSession(Binding.atom, "1.0", AlfrescoObjectFactoryImpl.class.getName()); Nodes nodesProxy = publicApiClient.nodes(); Comments commentsProxy = publicApiClient.comments(); @@ -536,7 +568,7 @@ public class TestCMIS extends EnterpriseTestApi Sites sitesProxy = publicApiClient.sites(); Comments commentsProxy = publicApiClient.comments(); publicApiClient.setRequestContext(new RequestContext(network1.getId(), person)); - CmisSession cmisSession = publicApiClient.createPublicApiCMISSession(Binding.atom, "1.0"); + CmisSession cmisSession = publicApiClient.createPublicApiCMISSession(Binding.atom, "1.0", AlfrescoObjectFactoryImpl.class.getName()); ListResponse sites = sitesProxy.getPersonSites(person, null); assertTrue(sites.getList().size() > 0); @@ -687,7 +719,7 @@ public class TestCMIS extends EnterpriseTestApi OperationContext cmisOperationCtxOverride = new OperationContextImpl(); cmisOperationCtxOverride.setIncludeRelationships(IncludeRelationships.BOTH); publicApiClient.setRequestContext(new RequestContext(network1.getId(), person2Id, cmisOperationCtxOverride)); - CmisSession cmisSession = publicApiClient.createPublicApiCMISSession(Binding.atom, "1.0"); + CmisSession cmisSession = publicApiClient.createPublicApiCMISSession(Binding.atom, "1.0", AlfrescoObjectFactoryImpl.class.getName()); CmisObject o1 = cmisSession.getObject(nodes.get(0).getId()); List relationships = o1.getRelationships(); @@ -837,7 +869,7 @@ public class TestCMIS extends EnterpriseTestApi publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1Id)); - cmisSession = publicApiClient.createPublicApiCMISSession(Binding.atom, "1.0"); + cmisSession = publicApiClient.createPublicApiCMISSession(Binding.atom, "1.0", AlfrescoObjectFactoryImpl.class.getName()); // test CMIS accepts NodeRefs and guids as input // objectIds returned from public api CMIS are always the guid @@ -942,11 +974,13 @@ public class TestCMIS extends EnterpriseTestApi final NodeRef doc3NodeRef = documents.get(2); publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1Id)); - CmisSession atomCmisSession10 = publicApiClient.createPublicApiCMISSession(Binding.atom, "1.0"); + CmisSession atomCmisSession10 = publicApiClient.createPublicApiCMISSession(Binding.atom, "1.0", AlfrescoObjectFactoryImpl.class.getName()); CmisSession atomCmisSession11 = publicApiClient.createPublicApiCMISSession(Binding.atom, "1.1"); CmisSession browserCmisSession11 = publicApiClient.createPublicApiCMISSession(Binding.browser, "1.1"); // Test that adding aspects works for both 1.0 and 1.1 + + // 1.0 { AlfrescoDocument doc = (AlfrescoDocument)atomCmisSession10.getObject(doc1NodeRef.getId()); @@ -956,7 +990,8 @@ public class TestCMIS extends EnterpriseTestApi @Override public Void doWork() throws Exception { - assertTrue(repoService.getAspects(doc1NodeRef).contains(ContentModel.ASPECT_TITLED)); + Set aspects = repoService.getAspects(doc1NodeRef); + assertTrue("Missing aspect in current set " + aspects, aspects.contains(ContentModel.ASPECT_TITLED)); return null; } @@ -968,66 +1003,173 @@ public class TestCMIS extends EnterpriseTestApi @Override public Void doWork() throws Exception { - assertFalse(repoService.getAspects(doc1NodeRef).contains(ContentModel.ASPECT_TITLED)); + Set aspects = repoService.getAspects(doc1NodeRef); + assertFalse("Unexpected aspect in current set " + aspects, aspects.contains(ContentModel.ASPECT_TITLED)); return null; } }, person1Id, network1.getId()); } + // 1.1 atom (secondary types) { - AlfrescoDocument doc = (AlfrescoDocument)atomCmisSession11.getObject(doc2NodeRef.getId()); + final Document doc = (Document)atomCmisSession11.getObject(doc2NodeRef.getId()); + + final List secondaryTypesList = doc.getSecondaryTypes(); + final List secondaryTypes = new ArrayList(); + for(SecondaryType secondaryType : secondaryTypesList) + { + secondaryTypes.add(secondaryType.getId()); + } + + secondaryTypes.add("P:sys:temporary"); + secondaryTypes.add("P:cm:titled"); + Map properties = new HashMap(); + { + // create a document with 2 secondary types + properties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, secondaryTypes); + } + Document doc1 = (Document)doc.updateProperties(properties); + checkSecondaryTypes(doc1, new HashSet(Arrays.asList(new String[] {"P:sys:temporary", "P:cm:titled"})), null); - doc = (AlfrescoDocument)doc.addAspect("S:cm:titled"); TenantUtil.runAsUserTenant(new TenantRunAsWork() { @Override public Void doWork() throws Exception { - assertTrue(repoService.getAspects(doc2NodeRef).contains(ContentModel.ASPECT_TITLED)); - + Set aspects = repoService.getAspects(doc2NodeRef); + assertTrue("Missing aspects in current set " + aspects, aspects.contains(ContentModel.ASPECT_TITLED)); + assertTrue("Missing aspects in current set " + aspects, aspects.contains(ContentModel.ASPECT_TEMPORARY)); + return null; } }, person1Id, network1.getId()); - - doc.removeAspect("S:cm:titled"); - TenantUtil.runAsUserTenant(new TenantRunAsWork() + + secondaryTypes.add("P:cm:author"); + properties = new HashMap(); { - @Override - public Void doWork() throws Exception - { - assertFalse(repoService.getAspects(doc1NodeRef).contains(ContentModel.ASPECT_TITLED)); - - return null; - } - }, person1Id, network1.getId()); + // create a document with 2 secondary types + properties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, secondaryTypes); + } + Document doc2 = (Document)doc1.updateProperties(properties); + checkSecondaryTypes(doc2, new HashSet(Arrays.asList(new String[] {"P:sys:temporary", "P:cm:titled", "P:cm:author"})), null); + TenantUtil.runAsUserTenant(new TenantRunAsWork() + { + @Override + public Void doWork() throws Exception + { + Set aspects = repoService.getAspects(doc2NodeRef); + String title = (String)repoService.getProperty(doc2NodeRef, ContentModel.PROP_TITLE); + assertTrue("Missing aspects in current set " + aspects, aspects.contains(ContentModel.ASPECT_AUTHOR)); + assertTrue("Missing aspects in current set " + aspects, aspects.contains(ContentModel.ASPECT_TEMPORARY)); + assertTrue("Missing aspects in current set " + aspects, aspects.contains(ContentModel.ASPECT_TITLED)); + assertEquals(null, title); + + return null; + } + }, person1Id, network1.getId()); + + // remove a secondary type + secondaryTypes.remove("P:cm:titled"); + properties = new HashMap(); + { + properties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, secondaryTypes); + } + Document doc3 = (Document)doc2.updateProperties(properties); + checkSecondaryTypes(doc3, new HashSet(Arrays.asList(new String[] {"P:sys:temporary", "P:cm:author"})), + new HashSet(Arrays.asList(new String[] {"P:cm:titled"}))); + TenantUtil.runAsUserTenant(new TenantRunAsWork() + { + @Override + public Void doWork() throws Exception + { + Set aspects = repoService.getAspects(doc2NodeRef); + String title = (String)repoService.getProperty(doc2NodeRef, ContentModel.PROP_TITLE); + assertTrue("Missing aspects in current set " + aspects, aspects.contains(ContentModel.ASPECT_AUTHOR)); + assertTrue("Missing aspects in current set " + aspects, aspects.contains(ContentModel.ASPECT_TEMPORARY)); + assertFalse("Unexpected aspect in current set " + aspects, aspects.contains(ContentModel.ASPECT_TITLED)); + assertEquals(null, title); + + return null; + } + }, person1Id, network1.getId()); } + // 1.1 browser (secondary types) { - AlfrescoDocument doc = (AlfrescoDocument)browserCmisSession11.getObject(doc3NodeRef.getId()); + Document doc = (Document)browserCmisSession11.getObject(doc3NodeRef.getId()); + final List secondaryTypesList = doc.getSecondaryTypes(); + final List secondaryTypes = new ArrayList(); + for(SecondaryType secondaryType : secondaryTypesList) + { + secondaryTypes.add(secondaryType.getId()); + } - doc = (AlfrescoDocument)doc.addAspect("S:cm:titled"); + secondaryTypes.add("P:sys:temporary"); + secondaryTypes.add("P:cm:titled"); + Map properties = new HashMap(); + { + // create a document with 2 secondary types + properties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, secondaryTypes); + } + Document doc1 = (Document)doc.updateProperties(properties); + checkSecondaryTypes(doc1, new HashSet(Arrays.asList(new String[] {"P:sys:temporary", "P:cm:titled"})), null); + + TenantUtil.runAsUserTenant(new TenantRunAsWork() + { + @Override + public Void doWork() throws Exception + { + Set aspects = repoService.getAspects(doc3NodeRef); + assertTrue("Missing aspects in current set " + aspects, aspects.contains(ContentModel.ASPECT_TITLED)); + assertTrue("Missing aspects in current set " + aspects, aspects.contains(ContentModel.ASPECT_TEMPORARY)); + return null; + } + }, person1Id, network1.getId()); + + secondaryTypes.add("P:cm:author"); + properties = new HashMap(); + { + // create a document with 2 secondary types + properties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, secondaryTypes); + } + Document doc2 = (Document)doc1.updateProperties(properties); + checkSecondaryTypes(doc2, new HashSet(Arrays.asList(new String[] {"P:sys:temporary", "P:cm:titled", "P:cm:author"})), null); + TenantUtil.runAsUserTenant(new TenantRunAsWork() + { + @Override + public Void doWork() throws Exception + { + Set aspects = repoService.getAspects(doc3NodeRef); + assertTrue("Missing aspects in current set " + aspects, aspects.contains(ContentModel.ASPECT_TITLED)); + assertTrue("Missing aspects in current set " + aspects, aspects.contains(ContentModel.ASPECT_TEMPORARY)); + assertTrue("Missing aspects in current set " + aspects, aspects.contains(ContentModel.ASPECT_AUTHOR)); + + return null; + } + }, person1Id, network1.getId()); + + secondaryTypes.remove("P:cm:titled"); + properties = new HashMap(); + { + // create a document with 2 secondary types + properties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, secondaryTypes); + } + Document doc3 = (Document)doc2.updateProperties(properties); + checkSecondaryTypes(doc3, new HashSet(Arrays.asList(new String[] {"P:sys:temporary", "P:cm:author"})), + new HashSet(Arrays.asList(new String[] {"P:cm:titled"}))); TenantUtil.runAsUserTenant(new TenantRunAsWork() { - @Override - public Void doWork() throws Exception - { - assertTrue(repoService.getAspects(doc3NodeRef).contains(ContentModel.ASPECT_TITLED)); - - return null; - } - }, person1Id, network1.getId()); + @Override + public Void doWork() throws Exception + { + Set aspects = repoService.getAspects(doc3NodeRef); + assertTrue("Missing aspects in current set " + aspects, aspects.contains(ContentModel.ASPECT_AUTHOR)); + assertTrue("Missing aspects in current set " + aspects, aspects.contains(ContentModel.ASPECT_TEMPORARY)); + assertFalse("Unexpected aspect in current set " + aspects, aspects.contains(ContentModel.ASPECT_TITLED)); - doc.removeAspect("S:cm:titled"); - TenantUtil.runAsUserTenant(new TenantRunAsWork() - { - @Override - public Void doWork() throws Exception - { - assertFalse(repoService.getAspects(doc1NodeRef).contains(ContentModel.ASPECT_TITLED)); - - return null; - } + return null; + } }, person1Id, network1.getId()); } } @@ -1062,7 +1204,7 @@ public class TestCMIS extends EnterpriseTestApi // and that we can't get to it through CMIS publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1Id)); - CmisSession cmisSession = publicApiClient.createPublicApiCMISSession(Binding.atom, "1.0"); + CmisSession cmisSession = publicApiClient.createPublicApiCMISSession(Binding.atom, "1.0", AlfrescoObjectFactoryImpl.class.getName()); try { cmisSession.getTypeDefinition("D:testCMIS:type1"); @@ -1106,7 +1248,7 @@ public class TestCMIS extends EnterpriseTestApi // Create a document... publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1Id)); - CmisSession cmisSession = publicApiClient.createPublicApiCMISSession(Binding.atom, "1.0"); + CmisSession cmisSession = publicApiClient.createPublicApiCMISSession(Binding.atom, "1.0", AlfrescoObjectFactoryImpl.class.getName()); AlfrescoFolder docLibrary = (AlfrescoFolder)cmisSession.getObjectByPath("/Sites/" + siteName + "/documentLibrary"); Map properties = new HashMap(); { @@ -1180,7 +1322,7 @@ public class TestCMIS extends EnterpriseTestApi // Create a document... publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1Id)); - CmisSession cmisSession = publicApiClient.createPublicApiCMISSession(Binding.atom, "1.0"); + CmisSession cmisSession = publicApiClient.createPublicApiCMISSession(Binding.atom, "1.0", AlfrescoObjectFactoryImpl.class.getName()); AlfrescoFolder docLibrary = (AlfrescoFolder)cmisSession.getObjectByPath("/Sites/" + siteName + "/documentLibrary"); Map properties = new HashMap(); { diff --git a/source/test-java/org/alfresco/rest/api/tests/TestEnterpriseAtomPubTCK.java b/source/test-java/org/alfresco/rest/api/tests/TestEnterpriseAtomPubTCK.java index 8de87a6171..b223533ffc 100644 --- a/source/test-java/org/alfresco/rest/api/tests/TestEnterpriseAtomPubTCK.java +++ b/source/test-java/org/alfresco/rest/api/tests/TestEnterpriseAtomPubTCK.java @@ -37,10 +37,21 @@ import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.transaction.TransactionService; import org.apache.chemistry.opencmis.commons.enums.BindingType; +import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTestGroup; +import org.apache.chemistry.opencmis.tck.impl.JUnitHelper; import org.apache.chemistry.opencmis.tck.impl.TestParameters; +import org.apache.chemistry.opencmis.tck.tests.basics.BasicsTestGroup; +import org.apache.chemistry.opencmis.tck.tests.control.ControlTestGroup; +import org.apache.chemistry.opencmis.tck.tests.crud.CRUDTestGroup; +import org.apache.chemistry.opencmis.tck.tests.filing.FilingTestGroup; +import org.apache.chemistry.opencmis.tck.tests.query.QueryTestGroup; +import org.apache.chemistry.opencmis.tck.tests.versioning.VersionDeleteTest; +import org.apache.chemistry.opencmis.tck.tests.versioning.VersioningSmokeTest; +import org.apache.chemistry.opencmis.tck.tests.versioning.VersioningStateCreateTest; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.Before; +import org.junit.Test; /** * OpenCMIS TCK unit tests. @@ -48,7 +59,7 @@ import org.junit.Before; * @author steveglover * */ -public class TestEnterpriseAtomPubTCK extends AbstractEnterpriseOpenCMISTCKTest +public class TestEnterpriseAtomPubTCK extends AbstractEnterpriseOpenCMIS10TCKTest { private static final String CMIS_URL = "http://{0}:{1}/{2}/cmisatom"; protected static final Log logger = LogFactory.getLog(TestEnterpriseAtomPubTCK.class); @@ -104,4 +115,64 @@ public class TestEnterpriseAtomPubTCK extends AbstractEnterpriseOpenCMISTCKTest clientContext = new OpenCMISClientContext(BindingType.ATOMPUB, MessageFormat.format(CMIS_URL, "localhost", String.valueOf(port), "alfresco"), "admin", "admin", cmisParameters); } + + @Test + public void testCMISTCKBasics() throws Exception + { + BasicsTestGroup basicsTestGroup = new BasicsTestGroup(); + JUnitHelper.run(basicsTestGroup); + } + + @Test + public void testCMISTCKCRUD() throws Exception + { + CRUDTestGroup crudTestGroup = new CRUDTestGroup(); + JUnitHelper.run(crudTestGroup); + } + + @Test + public void testCMISTCKVersioning() throws Exception + { + OverrideVersioningTestGroup versioningTestGroup = new OverrideVersioningTestGroup(); + JUnitHelper.run(versioningTestGroup); + } + + @Test + public void testCMISTCKFiling() throws Exception + { + FilingTestGroup filingTestGroup = new FilingTestGroup(); + JUnitHelper.run(filingTestGroup); + } + + @Test + public void testCMISTCKControl() throws Exception + { + ControlTestGroup controlTestGroup = new ControlTestGroup(); + JUnitHelper.run(controlTestGroup); + } + + @Test + public void testCMISTCKQuery() throws Exception + { + QueryTestGroup queryTestGroup = new QueryTestGroup(); + JUnitHelper.run(queryTestGroup); + } + + private class OverrideVersioningTestGroup extends AbstractSessionTestGroup + { + @Override + public void init(Map parameters) throws Exception + { + super.init(parameters); + + setName("Versioning Test Group"); + setDescription("Versioning tests."); + + addTest(new VersioningSmokeTest()); + addTest(new VersionDeleteTest()); + addTest(new VersioningStateCreateTest()); + // relies on Solr being available +// addTest(new CheckedOutTest()); + } + } } diff --git a/source/test-java/org/alfresco/rest/api/tests/TestFixture.java b/source/test-java/org/alfresco/rest/api/tests/TestFixture.java index f56cb76ae9..63cb02796d 100644 --- a/source/test-java/org/alfresco/rest/api/tests/TestFixture.java +++ b/source/test-java/org/alfresco/rest/api/tests/TestFixture.java @@ -8,7 +8,6 @@ import org.springframework.context.ApplicationContext; public interface TestFixture { - public final static String[] CLASS_LOCATIONS = new String[] {"classpath*:/publicapi/"}; public final static int PORT = 8081; public final static String CONTEXT_PATH = "/alfresco"; public final static String PUBLIC_API_SERVLET_NAME = "api"; diff --git a/source/test-java/org/alfresco/rest/api/tests/TestPublicApiAtomPub10TCK.java b/source/test-java/org/alfresco/rest/api/tests/TestPublicApiAtomPub10TCK.java new file mode 100644 index 0000000000..308ef17cca --- /dev/null +++ b/source/test-java/org/alfresco/rest/api/tests/TestPublicApiAtomPub10TCK.java @@ -0,0 +1,138 @@ +package org.alfresco.rest.api.tests; + +import java.text.MessageFormat; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.opencmis.OpenCMISClientContext; +import org.alfresco.rest.api.tests.RepoService.TestNetwork; +import org.apache.chemistry.opencmis.commons.enums.BindingType; +import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTestGroup; +import org.apache.chemistry.opencmis.tck.impl.JUnitHelper; +import org.apache.chemistry.opencmis.tck.impl.TestParameters; +import org.apache.chemistry.opencmis.tck.tests.basics.BasicsTestGroup; +import org.apache.chemistry.opencmis.tck.tests.control.ControlTestGroup; +import org.apache.chemistry.opencmis.tck.tests.crud.CRUDTestGroup; +import org.apache.chemistry.opencmis.tck.tests.filing.FilingTestGroup; +import org.apache.chemistry.opencmis.tck.tests.query.ContentChangesSmokeTest; +import org.apache.chemistry.opencmis.tck.tests.query.QueryForObject; +import org.apache.chemistry.opencmis.tck.tests.query.QueryLikeTest; +import org.apache.chemistry.opencmis.tck.tests.query.QueryRootFolderTest; +import org.apache.chemistry.opencmis.tck.tests.versioning.VersionDeleteTest; +import org.apache.chemistry.opencmis.tck.tests.versioning.VersioningSmokeTest; +import org.apache.chemistry.opencmis.tck.tests.versioning.VersioningStateCreateTest; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.Test; + +/** + * OpenCMIS TCK unit tests. + * + * @author steveglover + * + */ +public class TestPublicApiAtomPub10TCK extends AbstractEnterpriseOpenCMIS10TCKTest +{ + private static final String CMIS_URL = "http://{0}:{1}/{2}/api/{3}/{4}/cmis/versions/1.0/atom"; + protected static final Log logger = LogFactory.getLog(TestPublicApiAtomPub10TCK.class); + + @Before + public void before() throws Exception + { + int port = getTestFixture().getJettyComponent().getPort(); + TestNetwork network = getTestFixture().getRandomNetwork(); + Map cmisParameters = new HashMap(); + cmisParameters.put(TestParameters.DEFAULT_RELATIONSHIP_TYPE, "R:cm:replaces"); + clientContext = new OpenCMISClientContext(BindingType.ATOMPUB, + MessageFormat.format(CMIS_URL, "localhost", String.valueOf(port), "alfresco", network.getId(), "public"), + "admin@" + network.getId(), "admin", cmisParameters); + + } + + @AfterClass + public static void shutdown() throws Exception + { + } + + @Test + public void testCMISTCKBasics() throws Exception + { + BasicsTestGroup basicsTestGroup = new BasicsTestGroup(); + JUnitHelper.run(basicsTestGroup); + } + + @Test + public void testCMISTCKCRUD() throws Exception + { + CRUDTestGroup crudTestGroup = new CRUDTestGroup(); + JUnitHelper.run(crudTestGroup); + } + + @Test + public void testCMISTCKVersioning() throws Exception + { + OverrideVersioningTestGroup versioningTestGroup = new OverrideVersioningTestGroup(); + JUnitHelper.run(versioningTestGroup); + } + + @Test + public void testCMISTCKFiling() throws Exception + { + FilingTestGroup filingTestGroup = new FilingTestGroup(); + JUnitHelper.run(filingTestGroup); + } + + @Test + public void testCMISTCKControl() throws Exception + { + ControlTestGroup controlTestGroup = new ControlTestGroup(); + JUnitHelper.run(controlTestGroup); + } + + @Test + public void testCMISTCKQuery() throws Exception + { + OverrideQueryTestGroup queryTestGroup = new OverrideQueryTestGroup(); + JUnitHelper.run(queryTestGroup); + } + + private class OverrideVersioningTestGroup extends AbstractSessionTestGroup + { + @Override + public void init(Map parameters) throws Exception + { + super.init(parameters); + + setName("Versioning Test Group"); + setDescription("Versioning tests."); + + addTest(new VersioningSmokeTest()); + addTest(new VersionDeleteTest()); + addTest(new VersioningStateCreateTest()); + // relies on Solr being available +// addTest(new CheckedOutTest()); + } + } + + private class OverrideQueryTestGroup extends AbstractSessionTestGroup + { + @Override + public void init(Map parameters) throws Exception + { + super.init(parameters); + + setName("Query Test Group"); + setDescription("Query and content changes tests."); + + // this is failing because of an MT issue (the thread is a specific tenant but the DB metadata query is searching + // against the workspace://SpacesStore) +// addTest(new QuerySmokeTest()); + addTest(new QueryRootFolderTest()); + addTest(new QueryForObject()); + addTest(new QueryLikeTest()); + addTest(new ContentChangesSmokeTest()); + } + } +} \ No newline at end of file diff --git a/source/test-java/org/alfresco/rest/api/tests/TestPublicApiAtomPubTCK.java b/source/test-java/org/alfresco/rest/api/tests/TestPublicApiAtomPubTCK.java deleted file mode 100644 index 034e3c73dd..0000000000 --- a/source/test-java/org/alfresco/rest/api/tests/TestPublicApiAtomPubTCK.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.alfresco.rest.api.tests; - -import java.text.MessageFormat; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.opencmis.OpenCMISClientContext; -import org.alfresco.rest.api.tests.RepoService.TestNetwork; -import org.apache.chemistry.opencmis.commons.enums.BindingType; -import org.apache.chemistry.opencmis.tck.impl.TestParameters; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.AfterClass; -import org.junit.Before; - -/** - * OpenCMIS TCK unit tests. - * - * @author steveglover - * - */ -public class TestPublicApiAtomPubTCK extends AbstractEnterpriseOpenCMISTCKTest -{ - private static final String CMIS_URL = "http://{0}:{1}/{2}/api/{3}/{4}/cmis/versions/1.0/atom"; - protected static final Log logger = LogFactory.getLog(TestPublicApiAtomPubTCK.class); - - @Before - public void before() throws Exception - { - int port = getTestFixture().getJettyComponent().getPort(); - TestNetwork network = getTestFixture().getRandomNetwork(); - Map cmisParameters = new HashMap(); - cmisParameters.put(TestParameters.DEFAULT_RELATIONSHIP_TYPE, "R:cm:replaces"); - clientContext = new OpenCMISClientContext(BindingType.ATOMPUB, - MessageFormat.format(CMIS_URL, "localhost", String.valueOf(port), "alfresco", network.getId(), "public"), - "admin@" + network.getId(), "admin", cmisParameters); - - } - - @AfterClass - public static void shutdown() throws Exception - { - } -} \ No newline at end of file diff --git a/source/test-java/org/alfresco/rest/api/tests/TestPublicApiBrowserTCK.java b/source/test-java/org/alfresco/rest/api/tests/TestPublicApiBrowser11TCK.java similarity index 84% rename from source/test-java/org/alfresco/rest/api/tests/TestPublicApiBrowserTCK.java rename to source/test-java/org/alfresco/rest/api/tests/TestPublicApiBrowser11TCK.java index 4c52d3959d..e998cc7dc7 100644 --- a/source/test-java/org/alfresco/rest/api/tests/TestPublicApiBrowserTCK.java +++ b/source/test-java/org/alfresco/rest/api/tests/TestPublicApiBrowser11TCK.java @@ -18,10 +18,10 @@ import org.junit.Before; * @author steveglover * */ -public class TestPublicApiBrowserTCK extends AbstractEnterpriseOpenCMISTCKTest +public class TestPublicApiBrowser11TCK extends AbstractEnterpriseOpenCMIS11TCKTest { - private static final String CMIS_URL = "http://{0}:{1}/{2}/api/{3}/{4}/cmis/versions/1.0/browser"; - protected static final Log logger = LogFactory.getLog(TestPublicApiBrowserTCK.class); + private static final String CMIS_URL = "http://{0}:{1}/{2}/api/{3}/{4}/cmis/versions/1.1/browser"; + protected static final Log logger = LogFactory.getLog(TestPublicApiBrowser11TCK.class); @Before public void before() throws Exception @@ -30,6 +30,7 @@ public class TestPublicApiBrowserTCK extends AbstractEnterpriseOpenCMISTCKTest TestNetwork network = getTestFixture().getRandomNetwork(); Map cmisParameters = new HashMap(); cmisParameters.put(TestParameters.DEFAULT_RELATIONSHIP_TYPE, "R:cm:replaces"); + cmisParameters.put(TestParameters.DEFAULT_SECONDARY_TYPE, "P:cm:author"); clientContext = new OpenCMISClientContext(BindingType.BROWSER, MessageFormat.format(CMIS_URL, "localhost", String.valueOf(port), "alfresco", network.getId(), "public"), "admin@" + network.getId(), "admin", cmisParameters); diff --git a/source/test-java/org/alfresco/rest/api/tests/client/PublicApiClient.java b/source/test-java/org/alfresco/rest/api/tests/client/PublicApiClient.java index 1b9eb01fed..20cf3fdc29 100644 --- a/source/test-java/org/alfresco/rest/api/tests/client/PublicApiClient.java +++ b/source/test-java/org/alfresco/rest/api/tests/client/PublicApiClient.java @@ -166,6 +166,11 @@ public class PublicApiClient } public CmisSession createPublicApiCMISSession(Binding binding, String version) + { + return createPublicApiCMISSession(binding, version, null); + } + + public CmisSession createPublicApiCMISSession(Binding binding, String version, String objectFactoryName) { CmisSession cmisSession = null; @@ -205,11 +210,14 @@ public class PublicApiClient { parameters.put(SessionParameter.REPOSITORY_ID, networkId); } - parameters.put(SessionParameter.OBJECT_FACTORY_CLASS, AlfrescoObjectFactoryImpl.class.getName()); - + if(objectFactoryName != null) + { + parameters.put(SessionParameter.OBJECT_FACTORY_CLASS, objectFactoryName); + } + // create session Session session = factory.createSession(parameters); - + cmisSession = new CmisSession(session); } diff --git a/source/test-resources/publicapi/alfresco-global.properties b/source/test-resources/publicapi/lucene/alfresco-global.properties similarity index 52% rename from source/test-resources/publicapi/alfresco-global.properties rename to source/test-resources/publicapi/lucene/alfresco-global.properties index 083738e1e7..fed7f6a376 100644 --- a/source/test-resources/publicapi/alfresco-global.properties +++ b/source/test-resources/publicapi/lucene/alfresco-global.properties @@ -1,2 +1,2 @@ index.subsystem.name=lucene -index.recovery.mode=AUTO +index.recovery.mode=FULL \ No newline at end of file diff --git a/source/test-resources/publicapi/alfresco-global_de.properties b/source/test-resources/publicapi/lucene/alfresco-global_de.properties similarity index 100% rename from source/test-resources/publicapi/alfresco-global_de.properties rename to source/test-resources/publicapi/lucene/alfresco-global_de.properties diff --git a/source/test-resources/publicapi/alfresco-global_es.properties b/source/test-resources/publicapi/lucene/alfresco-global_es.properties similarity index 100% rename from source/test-resources/publicapi/alfresco-global_es.properties rename to source/test-resources/publicapi/lucene/alfresco-global_es.properties diff --git a/source/test-resources/publicapi/alfresco-global_fr.properties b/source/test-resources/publicapi/lucene/alfresco-global_fr.properties similarity index 100% rename from source/test-resources/publicapi/alfresco-global_fr.properties rename to source/test-resources/publicapi/lucene/alfresco-global_fr.properties diff --git a/source/test-resources/publicapi/alfresco-global_it.properties b/source/test-resources/publicapi/lucene/alfresco-global_it.properties similarity index 100% rename from source/test-resources/publicapi/alfresco-global_it.properties rename to source/test-resources/publicapi/lucene/alfresco-global_it.properties diff --git a/source/test-resources/publicapi/alfresco-global_ja.properties b/source/test-resources/publicapi/lucene/alfresco-global_ja.properties similarity index 100% rename from source/test-resources/publicapi/alfresco-global_ja.properties rename to source/test-resources/publicapi/lucene/alfresco-global_ja.properties diff --git a/source/test-resources/publicapi/solr/alfresco-global.properties b/source/test-resources/publicapi/solr/alfresco-global.properties new file mode 100644 index 0000000000..ccce9a5233 --- /dev/null +++ b/source/test-resources/publicapi/solr/alfresco-global.properties @@ -0,0 +1 @@ +index.subsystem.name=solr \ No newline at end of file diff --git a/source/test-resources/rest-api-test-context.xml b/source/test-resources/rest-api-test-context.xml index b04893fdd5..08840c4a92 100644 --- a/source/test-resources/rest-api-test-context.xml +++ b/source/test-resources/rest-api-test-context.xml @@ -12,7 +12,7 @@ - + \ No newline at end of file