You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2012/02/25 14:43:34 UTC
svn commit: r1293600 [5/9] - in /chemistry/opencmis/branches/android: ./
chemistry-opencmis-client/chemistry-opencmis-client-bindings/
chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindi...
Modified: chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceMutabilityTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceMutabilityTest.java?rev=1293600&r1=1293599&r2=1293600&view=diff
==============================================================================
--- chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceMutabilityTest.java (original)
+++ chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceMutabilityTest.java Sat Feb 25 13:43:31 2012
@@ -1,373 +1,373 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.chemistry.opencmis.inmemory;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.chemistry.opencmis.commons.data.ContentStream;
-import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
-import org.apache.chemistry.opencmis.commons.data.Properties;
-import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
-import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
-import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
-import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
-import org.apache.chemistry.opencmis.commons.enums.Updatability;
-import org.apache.chemistry.opencmis.commons.enums.VersioningState;
-import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
-import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
-import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerDefinitionImpl;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
-import org.apache.chemistry.opencmis.commons.spi.Holder;
-import org.apache.chemistry.opencmis.inmemory.server.InMemoryObjectServiceImpl;
-import org.apache.chemistry.opencmis.inmemory.server.InMemoryRepositoryServiceImpl;
-import org.apache.chemistry.opencmis.inmemory.server.InMemoryServiceFactoryImpl;
-import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager;
-import org.apache.chemistry.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
-import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Temporary test class until CMIS 1.1 bindings are completed. Until then
- * we use a special setup procedure to directly connect to the repository
- * service implementation of InMemory.
- *
- * @author Jens
- */
-public class RepositoryServiceMutabilityTest extends AbstractServiceTest {
-
- private static final Log log = LogFactory.getLog(RepositoryServiceTest.class);
- private static final String REPOSITORY_ID = "UnitTestRepository";
- private static final String TYPE_ID_MUTABILITY = "BookTypeAddedLater";
- private static final String PROPERTY_ID_TITLE = "Title";
- private static final String PROPERTY_ID_NUMBER = "Number";
-
- private InMemoryRepositoryServiceImpl repSvc;
- private InMemoryObjectServiceImpl objSvc;
-
- @Override
- @Before
- public void setUp() {
- super.setTypeCreatorClass(UnitTestTypeSystemCreator.class.getName());
- super.setUp();
-
- Map<String, String> parameters = new HashMap<String, String>();
-
- // attach repository info to the session:
- parameters.put(ConfigConstants.TYPE_CREATOR_CLASS, getTypeCreatorClass());
- parameters.put(ConfigConstants.REPOSITORY_ID, REPOSITORY_ID);
-
- InMemoryServiceFactoryImpl factory = new InMemoryServiceFactoryImpl();
- factory.init(parameters);
- StoreManager storeManager = factory.getStoreManger();
- repSvc = new InMemoryRepositoryServiceImpl(storeManager);
- objSvc = new InMemoryObjectServiceImpl(storeManager);
- }
-
- @Override
- @After
- public void tearDown() {
- super.tearDown();
- }
-
- // This test is just added because this test class uses a different setup to connect to the
- // server as long as the server bindings do not support the type mutability extension of
- // CMIS 1.1. If this test fails then the setUp() fails!
- @Test
- public void testRepositoryInfo() {
- log.info("starting testRepositoryInfo() ...");
- List<RepositoryInfo> repositories = repSvc.getRepositoryInfos(fTestCallContext, null);
- assertNotNull(repositories);
- assertFalse(repositories.isEmpty());
-
- log.info("geRepositoryInfo(), found " + repositories.size() + " repository/repositories).");
-
- for (RepositoryInfo repository : repositories) {
- RepositoryInfo repository2 = repSvc.getRepositoryInfo(fTestCallContext, repository.getId(), null);
- assertNotNull(repository2);
- assertEquals(repository.getId(), repository2.getId());
- log.info("found repository" + repository2.getId());
- }
-
- log.info("... testRepositoryInfo() finished.");
- }
-
-
- @Test
- public void testTypeMutabilityCreation() throws Exception {
- log.info("");
- log.info("starting testTypeMutabilityCreation() ...");
- TypeDefinition typeDefRef = createTypeForAddingAtRuntime();
- String repositoryId = getRepositoryId();
- // add type.
- repSvc.createTypeDefinition(repositoryId, new Holder<TypeDefinition>(typeDefRef), null);
- TypeDefinition type = repSvc.getTypeDefinition(fTestCallContext, repositoryId, typeDefRef.getId(), null);
- assertEquals(typeDefRef.getId(), type.getId());
- assertEquals(typeDefRef.getDescription(), type.getDescription());
- assertEquals(typeDefRef.getDisplayName(), type.getDisplayName());
- assertEquals(typeDefRef.getLocalName(), type.getLocalName());
- assertEquals(typeDefRef.getLocalNamespace(), type.getLocalNamespace());
- RepositoryServiceTest.containsAllBasePropertyDefinitions(type);
- log.info("... testTypeMutabilityCreation() finished.");
- }
-
- @Test
- public void testTypeMutabilityCreateDuplicate() throws Exception {
- log.info("");
- log.info("starting testTypeMutabilityCreateDuplicate() ...");
- TypeDefinition typeDefRef = createTypeForAddingAtRuntime();
- String repositoryId = getRepositoryId();
- // add type.
- repSvc.createTypeDefinition(repositoryId, new Holder<TypeDefinition>(typeDefRef), null);
- // add type again should fail
- checkAddingType(repositoryId, typeDefRef, CmisInvalidArgumentException.class);
- // type should still exist then
- TypeDefinition type = repSvc.getTypeDefinition(fTestCallContext, repositoryId, typeDefRef.getId(), null);
- assertEquals(typeDefRef.getId(), type.getId());
- log.info("... testTypeMutabilityCreateDuplicate() finished.");
- }
-
-
- @Test
- public void testTypeMutabilityTypeNameConstraints() throws Exception {
- log.info("starting testTypeMutabilityTypeNameConstraints() ...");
-
- String repositoryId = getRepositoryId();
-
- // test illegal type id
- InMemoryDocumentTypeDefinition typeDefRef = createTypeForAddingAtRuntime();
- typeDefRef.setId(typeDefRef.getId() + "!!!");
- checkAddingType(repositoryId, typeDefRef, CmisInvalidArgumentException.class);
-
- // test illegal parent type id
- typeDefRef = createTypeForAddingAtRuntime();
- typeDefRef.setParentTypeId("NonExistingParentType");
- checkAddingType(repositoryId, typeDefRef, CmisInvalidArgumentException.class);
-
- // test null type id
- typeDefRef = createTypeForAddingAtRuntime();
- typeDefRef.setId(null);
- checkAddingType(repositoryId, typeDefRef, CmisInvalidArgumentException.class);
-
- // test null query name
- typeDefRef = createTypeForAddingAtRuntime();
- typeDefRef.setQueryName(null);
- checkAddingType(repositoryId, typeDefRef, CmisInvalidArgumentException.class);
-
- // test illegal query name
- typeDefRef = createTypeForAddingAtRuntime();
- typeDefRef.setQueryName(typeDefRef.getQueryName() + "!!!");
- checkAddingType(repositoryId, typeDefRef, CmisInvalidArgumentException.class);
-
- // test null local name
- typeDefRef = createTypeForAddingAtRuntime();
- typeDefRef.setLocalName(null);
- checkAddingType(repositoryId, typeDefRef, CmisInvalidArgumentException.class);
-
- // test illegal local name
- typeDefRef = createTypeForAddingAtRuntime();
- typeDefRef.setLocalName(typeDefRef.getLocalName() + "!!!");
- checkAddingType(repositoryId, typeDefRef, CmisInvalidArgumentException.class);
-
- log.info("... testTypeMutabilityTypeNameConstraints() finished.");
- }
-
- @Test
- public void testTypeMutabilityPropertyNameConstraints() throws Exception {
- log.info("starting testTypeMutabilityPropertyNameConstraints() ...");
-
- String repositoryId = getRepositoryId();
-
- // test null property id
- InMemoryDocumentTypeDefinition typeDef = createTypeForAddingAtRuntime();
- PropertyStringDefinitionImpl pd = getPropertyDefinitionImpl(typeDef);
- pd.setId(null);
- checkAddingType(repositoryId, typeDef, CmisInvalidArgumentException.class);
-
- // test illegal property id
- typeDef = createTypeForAddingAtRuntime();
- pd = getPropertyDefinitionImpl(typeDef);
- pd.setQueryName(pd.getQueryName() + "!!!");
- checkAddingType(repositoryId, typeDef, CmisInvalidArgumentException.class);
-
- // test null property query name
- typeDef = createTypeForAddingAtRuntime();
- pd = getPropertyDefinitionImpl(typeDef);
- pd.setQueryName(null);
- checkAddingType(repositoryId, typeDef, CmisInvalidArgumentException.class);
-
- // test illegal property query name
- typeDef = createTypeForAddingAtRuntime();
- pd = getPropertyDefinitionImpl(typeDef);
- pd.setQueryName(pd.getQueryName() + "!!!");
- checkAddingType(repositoryId, typeDef, CmisInvalidArgumentException.class);
-
- // test null property local name
- typeDef = createTypeForAddingAtRuntime();
- pd = getPropertyDefinitionImpl(typeDef);
- pd.setLocalName(null);
- checkAddingType(repositoryId, typeDef, CmisInvalidArgumentException.class);
-
- // test illegal property local name
- typeDef = createTypeForAddingAtRuntime();
- pd = getPropertyDefinitionImpl(typeDef);
- pd.setLocalName(typeDef.getLocalName() + "!!!");
- checkAddingType(repositoryId, typeDef, CmisInvalidArgumentException.class);
-
- log.info("... testTypeMutabilityPropertyNameConstraints() finished.");
- }
-
- private void checkAddingType(String repositoryId, TypeDefinition typeDef, Class<? extends Exception> clazz) {
- try {
- repSvc.createTypeDefinition(repositoryId, new Holder<TypeDefinition>(typeDef), null);
- fail("Illegal type should throw a " + clazz.getName());
- } catch (RuntimeException e) {
- assertTrue("Illegal type name threw wrong exception type (should be a " + clazz.getName() + ")",
- clazz.isInstance(e));
- }
- }
-
- @Test
- public void testTypeMutabilityUpdate() throws Exception {
- log.info("");
- log.info("starting testTypeMutabilityUpdate() ...");
- TypeDefinition typeDefRef = createTypeForAddingAtRuntime();
- String repositoryId = getRepositoryId();
- repSvc.createTypeDefinition(repositoryId, new Holder<TypeDefinition>(typeDefRef), null);
- // update type.
- try {
- repSvc.updateTypeDefinition(repositoryId, new Holder<TypeDefinition>(typeDefRef), null);
- fail("updating a type should throw exception.");
- } catch (Exception e) {
- assert(e instanceof CmisNotSupportedException);
- }
- log.info("... testTypeMutabilityUpdate() finished.");
- }
-
- @Test
- public void testTypeMutabilityDeletion() throws Exception {
- log.info("");
- log.info("starting testTypeMutabilityDeletion() ...");
- TypeDefinition typeDefRef = createTypeForAddingAtRuntime();
- String repositoryId = getRepositoryId();
- repSvc.createTypeDefinition(repositoryId, new Holder<TypeDefinition>(typeDefRef), null);
-
- String docId = createDoc("Book1", getRootFolderId(REPOSITORY_ID), TYPE_ID_MUTABILITY);
-
- // try deleting type, should fail, because in use.
- try {
- repSvc.deleteTypeDefinition(repositoryId, TYPE_ID_MUTABILITY, null);
- fail("deleting a type which is in use should throw exception.");
- } catch (Exception e) {
- assert(e instanceof CmisInvalidArgumentException);
- }
-
- objSvc.deleteObject(fTestCallContext, fRepositoryId, docId, true, null);
-
- try {
- repSvc.deleteTypeDefinition(repositoryId, TYPE_ID_MUTABILITY, null);
- } catch (Exception e) {
- fail("deleting a type which is in not in use should not throw exception! Exception is: " + e);
- }
-
- try {
- repSvc.getTypeDefinition(fTestCallContext, repositoryId, TYPE_ID_MUTABILITY, null);
- fail("getting a type after it was deleted should fail.");
- } catch (Exception e) {
- }
-
- try {
- repSvc.deleteTypeDefinition(repositoryId, BaseTypeId.CMIS_DOCUMENT.name(), null);
- fail("deleting a CMIS base type throw exception.");
- } catch (Exception e) {
- assert(e instanceof CmisInvalidArgumentException);
- }
- try {
- repSvc.deleteTypeDefinition(repositoryId, BaseTypeId.CMIS_FOLDER.name(), null);
- fail("deleting a CMIS base type throw exception.");
- } catch (Exception e) {
- assert(e instanceof CmisInvalidArgumentException);
- }
-
- log.info("... testTypeMutabilityDeletion() finished.");
- }
-
- private String getRepositoryId() {
- List<RepositoryInfo> repositories = repSvc.getRepositoryInfos(fTestCallContext, null);
- RepositoryInfo repository = repositories.get(0);
- assertNotNull(repository);
- return repository.getId();
- }
-
- private String getRootFolderId(String repositoryId) {
- RepositoryInfo repository = repSvc.getRepositoryInfo(fTestCallContext, repositoryId, null);
- assertNotNull(repository);
- return repository.getRootFolderId();
- }
-
- private PropertyStringDefinitionImpl getPropertyDefinitionImpl(TypeDefinition typeDef) {
- @SuppressWarnings("unchecked")
- PropertyStringDefinitionImpl pd = (PropertyStringDefinitionImpl) typeDef.getPropertyDefinitions().get(PROPERTY_ID_TITLE);
- return pd;
- }
-
- private InMemoryDocumentTypeDefinition createTypeForAddingAtRuntime() {
-
- InMemoryDocumentTypeDefinition cmisLaterType = new InMemoryDocumentTypeDefinition(TYPE_ID_MUTABILITY,
- "Type with two properties", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
- Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-
- PropertyIntegerDefinitionImpl prop1 = PropertyCreationHelper.createIntegerDefinition(PROPERTY_ID_NUMBER,
- "Sample Int Property", Updatability.READWRITE);
- propertyDefinitions.put(prop1.getId(), prop1);
-
- PropertyStringDefinitionImpl prop2 = PropertyCreationHelper.createStringDefinition(PROPERTY_ID_TITLE,
- "Sample String Property", Updatability.READWRITE);
- propertyDefinitions.put(prop2.getId(), prop2);
-
- cmisLaterType.addCustomPropertyDefinitions(propertyDefinitions);
-
- return cmisLaterType;
- }
-
- String createDoc(String name, String folderId, String typeId) {
- ContentStream contentStream = null;
- List<String> policies = null;
- ExtensionsData extension = null;
-
- Properties props = createDocumentProperties(name, typeId);
-
- String id = objSvc.createDocument(fTestCallContext, fRepositoryId, props, folderId, contentStream,
- VersioningState.NONE, policies, null, null, extension);
- return id;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.inmemory;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.commons.data.ContentStream;
+import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
+import org.apache.chemistry.opencmis.commons.data.Properties;
+import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
+import org.apache.chemistry.opencmis.commons.enums.Updatability;
+import org.apache.chemistry.opencmis.commons.enums.VersioningState;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.spi.Holder;
+import org.apache.chemistry.opencmis.inmemory.server.InMemoryObjectServiceImpl;
+import org.apache.chemistry.opencmis.inmemory.server.InMemoryRepositoryServiceImpl;
+import org.apache.chemistry.opencmis.inmemory.server.InMemoryServiceFactoryImpl;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager;
+import org.apache.chemistry.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
+import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Temporary test class until CMIS 1.1 bindings are completed. Until then
+ * we use a special setup procedure to directly connect to the repository
+ * service implementation of InMemory.
+ *
+ * @author Jens
+ */
+public class RepositoryServiceMutabilityTest extends AbstractServiceTest {
+
+ private static final Logger log = LoggerFactory.getLogger(RepositoryServiceTest.class);
+ private static final String REPOSITORY_ID = "UnitTestRepository";
+ private static final String TYPE_ID_MUTABILITY = "BookTypeAddedLater";
+ private static final String PROPERTY_ID_TITLE = "Title";
+ private static final String PROPERTY_ID_NUMBER = "Number";
+
+ private InMemoryRepositoryServiceImpl repSvc;
+ private InMemoryObjectServiceImpl objSvc;
+
+ @Override
+ @Before
+ public void setUp() {
+ super.setTypeCreatorClass(UnitTestTypeSystemCreator.class.getName());
+ super.setUp();
+
+ Map<String, String> parameters = new HashMap<String, String>();
+
+ // attach repository info to the session:
+ parameters.put(ConfigConstants.TYPE_CREATOR_CLASS, getTypeCreatorClass());
+ parameters.put(ConfigConstants.REPOSITORY_ID, REPOSITORY_ID);
+
+ InMemoryServiceFactoryImpl factory = new InMemoryServiceFactoryImpl();
+ factory.init(parameters);
+ StoreManager storeManager = factory.getStoreManger();
+ repSvc = new InMemoryRepositoryServiceImpl(storeManager);
+ objSvc = new InMemoryObjectServiceImpl(storeManager);
+ }
+
+ @Override
+ @After
+ public void tearDown() {
+ super.tearDown();
+ }
+
+ // This test is just added because this test class uses a different setup to connect to the
+ // server as long as the server bindings do not support the type mutability extension of
+ // CMIS 1.1. If this test fails then the setUp() fails!
+ @Test
+ public void testRepositoryInfo() {
+ log.info("starting testRepositoryInfo() ...");
+ List<RepositoryInfo> repositories = repSvc.getRepositoryInfos(fTestCallContext, null);
+ assertNotNull(repositories);
+ assertFalse(repositories.isEmpty());
+
+ log.info("geRepositoryInfo(), found " + repositories.size() + " repository/repositories).");
+
+ for (RepositoryInfo repository : repositories) {
+ RepositoryInfo repository2 = repSvc.getRepositoryInfo(fTestCallContext, repository.getId(), null);
+ assertNotNull(repository2);
+ assertEquals(repository.getId(), repository2.getId());
+ log.info("found repository" + repository2.getId());
+ }
+
+ log.info("... testRepositoryInfo() finished.");
+ }
+
+
+ @Test
+ public void testTypeMutabilityCreation() throws Exception {
+ log.info("");
+ log.info("starting testTypeMutabilityCreation() ...");
+ TypeDefinition typeDefRef = createTypeForAddingAtRuntime();
+ String repositoryId = getRepositoryId();
+ // add type.
+ repSvc.createTypeDefinition(repositoryId, new Holder<TypeDefinition>(typeDefRef), null);
+ TypeDefinition type = repSvc.getTypeDefinition(fTestCallContext, repositoryId, typeDefRef.getId(), null);
+ assertEquals(typeDefRef.getId(), type.getId());
+ assertEquals(typeDefRef.getDescription(), type.getDescription());
+ assertEquals(typeDefRef.getDisplayName(), type.getDisplayName());
+ assertEquals(typeDefRef.getLocalName(), type.getLocalName());
+ assertEquals(typeDefRef.getLocalNamespace(), type.getLocalNamespace());
+ RepositoryServiceTest.containsAllBasePropertyDefinitions(type);
+ log.info("... testTypeMutabilityCreation() finished.");
+ }
+
+ @Test
+ public void testTypeMutabilityCreateDuplicate() throws Exception {
+ log.info("");
+ log.info("starting testTypeMutabilityCreateDuplicate() ...");
+ TypeDefinition typeDefRef = createTypeForAddingAtRuntime();
+ String repositoryId = getRepositoryId();
+ // add type.
+ repSvc.createTypeDefinition(repositoryId, new Holder<TypeDefinition>(typeDefRef), null);
+ // add type again should fail
+ checkAddingType(repositoryId, typeDefRef, CmisInvalidArgumentException.class);
+ // type should still exist then
+ TypeDefinition type = repSvc.getTypeDefinition(fTestCallContext, repositoryId, typeDefRef.getId(), null);
+ assertEquals(typeDefRef.getId(), type.getId());
+ log.info("... testTypeMutabilityCreateDuplicate() finished.");
+ }
+
+
+ @Test
+ public void testTypeMutabilityTypeNameConstraints() throws Exception {
+ log.info("starting testTypeMutabilityTypeNameConstraints() ...");
+
+ String repositoryId = getRepositoryId();
+
+ // test illegal type id
+ InMemoryDocumentTypeDefinition typeDefRef = createTypeForAddingAtRuntime();
+ typeDefRef.setId(typeDefRef.getId() + "!!!");
+ checkAddingType(repositoryId, typeDefRef, CmisInvalidArgumentException.class);
+
+ // test illegal parent type id
+ typeDefRef = createTypeForAddingAtRuntime();
+ typeDefRef.setParentTypeId("NonExistingParentType");
+ checkAddingType(repositoryId, typeDefRef, CmisInvalidArgumentException.class);
+
+ // test null type id
+ typeDefRef = createTypeForAddingAtRuntime();
+ typeDefRef.setId(null);
+ checkAddingType(repositoryId, typeDefRef, CmisInvalidArgumentException.class);
+
+ // test null query name
+ typeDefRef = createTypeForAddingAtRuntime();
+ typeDefRef.setQueryName(null);
+ checkAddingType(repositoryId, typeDefRef, CmisInvalidArgumentException.class);
+
+ // test illegal query name
+ typeDefRef = createTypeForAddingAtRuntime();
+ typeDefRef.setQueryName(typeDefRef.getQueryName() + "!!!");
+ checkAddingType(repositoryId, typeDefRef, CmisInvalidArgumentException.class);
+
+ // test null local name
+ typeDefRef = createTypeForAddingAtRuntime();
+ typeDefRef.setLocalName(null);
+ checkAddingType(repositoryId, typeDefRef, CmisInvalidArgumentException.class);
+
+ // test illegal local name
+ typeDefRef = createTypeForAddingAtRuntime();
+ typeDefRef.setLocalName(typeDefRef.getLocalName() + "!!!");
+ checkAddingType(repositoryId, typeDefRef, CmisInvalidArgumentException.class);
+
+ log.info("... testTypeMutabilityTypeNameConstraints() finished.");
+ }
+
+ @Test
+ public void testTypeMutabilityPropertyNameConstraints() throws Exception {
+ log.info("starting testTypeMutabilityPropertyNameConstraints() ...");
+
+ String repositoryId = getRepositoryId();
+
+ // test null property id
+ InMemoryDocumentTypeDefinition typeDef = createTypeForAddingAtRuntime();
+ PropertyStringDefinitionImpl pd = getPropertyDefinitionImpl(typeDef);
+ pd.setId(null);
+ checkAddingType(repositoryId, typeDef, CmisInvalidArgumentException.class);
+
+ // test illegal property id
+ typeDef = createTypeForAddingAtRuntime();
+ pd = getPropertyDefinitionImpl(typeDef);
+ pd.setQueryName(pd.getQueryName() + "!!!");
+ checkAddingType(repositoryId, typeDef, CmisInvalidArgumentException.class);
+
+ // test null property query name
+ typeDef = createTypeForAddingAtRuntime();
+ pd = getPropertyDefinitionImpl(typeDef);
+ pd.setQueryName(null);
+ checkAddingType(repositoryId, typeDef, CmisInvalidArgumentException.class);
+
+ // test illegal property query name
+ typeDef = createTypeForAddingAtRuntime();
+ pd = getPropertyDefinitionImpl(typeDef);
+ pd.setQueryName(pd.getQueryName() + "!!!");
+ checkAddingType(repositoryId, typeDef, CmisInvalidArgumentException.class);
+
+ // test null property local name
+ typeDef = createTypeForAddingAtRuntime();
+ pd = getPropertyDefinitionImpl(typeDef);
+ pd.setLocalName(null);
+ checkAddingType(repositoryId, typeDef, CmisInvalidArgumentException.class);
+
+ // test illegal property local name
+ typeDef = createTypeForAddingAtRuntime();
+ pd = getPropertyDefinitionImpl(typeDef);
+ pd.setLocalName(typeDef.getLocalName() + "!!!");
+ checkAddingType(repositoryId, typeDef, CmisInvalidArgumentException.class);
+
+ log.info("... testTypeMutabilityPropertyNameConstraints() finished.");
+ }
+
+ private void checkAddingType(String repositoryId, TypeDefinition typeDef, Class<? extends Exception> clazz) {
+ try {
+ repSvc.createTypeDefinition(repositoryId, new Holder<TypeDefinition>(typeDef), null);
+ fail("Illegal type should throw a " + clazz.getName());
+ } catch (RuntimeException e) {
+ assertTrue("Illegal type name threw wrong exception type (should be a " + clazz.getName() + ")",
+ clazz.isInstance(e));
+ }
+ }
+
+ @Test
+ public void testTypeMutabilityUpdate() throws Exception {
+ log.info("");
+ log.info("starting testTypeMutabilityUpdate() ...");
+ TypeDefinition typeDefRef = createTypeForAddingAtRuntime();
+ String repositoryId = getRepositoryId();
+ repSvc.createTypeDefinition(repositoryId, new Holder<TypeDefinition>(typeDefRef), null);
+ // update type.
+ try {
+ repSvc.updateTypeDefinition(repositoryId, new Holder<TypeDefinition>(typeDefRef), null);
+ fail("updating a type should throw exception.");
+ } catch (Exception e) {
+ assert(e instanceof CmisNotSupportedException);
+ }
+ log.info("... testTypeMutabilityUpdate() finished.");
+ }
+
+ @Test
+ public void testTypeMutabilityDeletion() throws Exception {
+ log.info("");
+ log.info("starting testTypeMutabilityDeletion() ...");
+ TypeDefinition typeDefRef = createTypeForAddingAtRuntime();
+ String repositoryId = getRepositoryId();
+ repSvc.createTypeDefinition(repositoryId, new Holder<TypeDefinition>(typeDefRef), null);
+
+ String docId = createDoc("Book1", getRootFolderId(REPOSITORY_ID), TYPE_ID_MUTABILITY);
+
+ // try deleting type, should fail, because in use.
+ try {
+ repSvc.deleteTypeDefinition(repositoryId, TYPE_ID_MUTABILITY, null);
+ fail("deleting a type which is in use should throw exception.");
+ } catch (Exception e) {
+ assert(e instanceof CmisInvalidArgumentException);
+ }
+
+ objSvc.deleteObject(fTestCallContext, fRepositoryId, docId, true, null);
+
+ try {
+ repSvc.deleteTypeDefinition(repositoryId, TYPE_ID_MUTABILITY, null);
+ } catch (Exception e) {
+ fail("deleting a type which is in not in use should not throw exception! Exception is: " + e);
+ }
+
+ try {
+ repSvc.getTypeDefinition(fTestCallContext, repositoryId, TYPE_ID_MUTABILITY, null);
+ fail("getting a type after it was deleted should fail.");
+ } catch (Exception e) {
+ }
+
+ try {
+ repSvc.deleteTypeDefinition(repositoryId, BaseTypeId.CMIS_DOCUMENT.name(), null);
+ fail("deleting a CMIS base type throw exception.");
+ } catch (Exception e) {
+ assert(e instanceof CmisInvalidArgumentException);
+ }
+ try {
+ repSvc.deleteTypeDefinition(repositoryId, BaseTypeId.CMIS_FOLDER.name(), null);
+ fail("deleting a CMIS base type throw exception.");
+ } catch (Exception e) {
+ assert(e instanceof CmisInvalidArgumentException);
+ }
+
+ log.info("... testTypeMutabilityDeletion() finished.");
+ }
+
+ private String getRepositoryId() {
+ List<RepositoryInfo> repositories = repSvc.getRepositoryInfos(fTestCallContext, null);
+ RepositoryInfo repository = repositories.get(0);
+ assertNotNull(repository);
+ return repository.getId();
+ }
+
+ private String getRootFolderId(String repositoryId) {
+ RepositoryInfo repository = repSvc.getRepositoryInfo(fTestCallContext, repositoryId, null);
+ assertNotNull(repository);
+ return repository.getRootFolderId();
+ }
+
+ private PropertyStringDefinitionImpl getPropertyDefinitionImpl(TypeDefinition typeDef) {
+ @SuppressWarnings("unchecked")
+ PropertyStringDefinitionImpl pd = (PropertyStringDefinitionImpl) typeDef.getPropertyDefinitions().get(PROPERTY_ID_TITLE);
+ return pd;
+ }
+
+ private InMemoryDocumentTypeDefinition createTypeForAddingAtRuntime() {
+
+ InMemoryDocumentTypeDefinition cmisLaterType = new InMemoryDocumentTypeDefinition(TYPE_ID_MUTABILITY,
+ "Type with two properties", InMemoryDocumentTypeDefinition.getRootDocumentType());
+
+ Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+
+ PropertyIntegerDefinitionImpl prop1 = PropertyCreationHelper.createIntegerDefinition(PROPERTY_ID_NUMBER,
+ "Sample Int Property", Updatability.READWRITE);
+ propertyDefinitions.put(prop1.getId(), prop1);
+
+ PropertyStringDefinitionImpl prop2 = PropertyCreationHelper.createStringDefinition(PROPERTY_ID_TITLE,
+ "Sample String Property", Updatability.READWRITE);
+ propertyDefinitions.put(prop2.getId(), prop2);
+
+ cmisLaterType.addCustomPropertyDefinitions(propertyDefinitions);
+
+ return cmisLaterType;
+ }
+
+ String createDoc(String name, String folderId, String typeId) {
+ ContentStream contentStream = null;
+ List<String> policies = null;
+ ExtensionsData extension = null;
+
+ Properties props = createDocumentProperties(name, typeId);
+
+ String id = objSvc.createDocument(fTestCallContext, fRepositoryId, props, folderId, contentStream,
+ VersioningState.NONE, policies, null, null, extension);
+ return id;
+ }
+}
Modified: chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java?rev=1293600&r1=1293599&r2=1293600&view=diff
==============================================================================
--- chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java (original)
+++ chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java Sat Feb 25 13:43:31 2012
@@ -40,8 +40,8 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.inmemory.types.DocumentTypeCreationHelper;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -53,7 +53,7 @@ public class RepositoryServiceTest exten
// private CmisProvider fProvider;
- private static final Log log = LogFactory.getLog(RepositoryServiceTest.class);
+ private static final Logger log = LoggerFactory.getLogger(RepositoryServiceTest.class);
private static final String REPOSITORY_ID = "UnitTestRepository";
private static final String TYPE_ID_MUTABILITY = "BookTypeAddedLater";
Modified: chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/VersioningTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/VersioningTest.java?rev=1293600&r1=1293599&r2=1293600&view=diff
==============================================================================
--- chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/VersioningTest.java (original)
+++ chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/VersioningTest.java Sat Feb 25 13:43:31 2012
@@ -55,14 +55,14 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.spi.Holder;
import org.apache.chemistry.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class VersioningTest extends AbstractServiceTest {
- private static final Log log = LogFactory.getLog(ObjectServiceTest.class);
+ private static final Logger log = LoggerFactory.getLogger(ObjectServiceTest.class);
private static final String PROP_VALUE = "Mickey Mouse";
private static final String PROP_VALUE_NEW = "Donald Duck";
private static final String PROP_NAME = "My Versioned Document";
@@ -665,4 +665,4 @@ public class VersioningTest extends Abst
return verSeriesId;
}
-}
\ No newline at end of file
+}
Modified: chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/AbstractQueryConditionProcessor.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/AbstractQueryConditionProcessor.java?rev=1293600&r1=1293599&r2=1293600&view=diff
==============================================================================
--- chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/AbstractQueryConditionProcessor.java (original)
+++ chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/AbstractQueryConditionProcessor.java Sat Feb 25 13:43:31 2012
@@ -1,382 +1,382 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.chemistry.opencmis.inmemory.query;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.GregorianCalendar;
-import java.util.List;
-
-import org.antlr.runtime.ANTLRInputStream;
-import org.antlr.runtime.CharStream;
-import org.antlr.runtime.CommonTokenStream;
-import org.antlr.runtime.RecognitionException;
-import org.antlr.runtime.TokenSource;
-import org.antlr.runtime.TokenStream;
-import org.antlr.runtime.tree.CommonTree;
-import org.antlr.runtime.tree.CommonTreeNodeStream;
-import org.antlr.runtime.tree.Tree;
-import org.apache.chemistry.opencmis.server.support.query.CalendarHelper;
-import org.apache.chemistry.opencmis.server.support.query.CmisQlStrictLexer;
-import org.apache.chemistry.opencmis.server.support.query.CmisQlStrictParser;
-import org.apache.chemistry.opencmis.server.support.query.CmisQlStrictParser_CmisBaseGrammar.query_return;
-import org.apache.chemistry.opencmis.server.support.query.CmisQueryWalker;
-import org.apache.chemistry.opencmis.server.support.query.StringUtil;
-import org.apache.chemistry.opencmis.server.support.query.TextSearchLexer;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public abstract class AbstractQueryConditionProcessor implements QueryConditionProcessor {
-
- private static final Log LOG = LogFactory.getLog(ProcessQueryTest.class);
-
- public abstract void onStartProcessing(Tree whereNode);
- public abstract void onStopProcessing();
-
- // Compare operators
- public abstract void onEquals(Tree eqNode, Tree leftNode, Tree rightNode);
- public abstract void onNotEquals(Tree neNode, Tree leftNode, Tree rightNode);
- public abstract void onGreaterThan(Tree gtNode, Tree leftNode, Tree rightNode);
- public abstract void onGreaterOrEquals(Tree geNode, Tree leftNode, Tree rightNode);
- public abstract void onLessThan(Tree ltNode, Tree leftNode, Tree rightNode);
- public abstract void onLessOrEquals(Tree leqNode, Tree leftNode, Tree rightNode);
-
- // Boolean operators
- public void onPreNot(Tree opNode, Tree leftNode) {
- }
- public abstract void onNot(Tree opNode, Tree leftNode);
- public void onPostNot(Tree opNode, Tree leftNode) {
- }
- public void onPreAnd(Tree opNode, Tree leftNode, Tree rightNode) {
- }
- public abstract void onAnd(Tree opNode, Tree leftNode, Tree rightNode);
- public void onPostAnd(Tree opNode, Tree leftNode, Tree rightNode) {
- }
- public void onPreOr(Tree opNode, Tree leftNode, Tree rightNode) {
- }
- public abstract void onOr(Tree opNode, Tree leftNode, Tree rightNode);
- public void onPostOr(Tree opNode, Tree leftNode, Tree rightNode) {
- }
-
- // Multi-value:
- public abstract void onIn(Tree node, Tree colNode, Tree listNode);
- public abstract void onNotIn(Tree node, Tree colNode, Tree listNode);
- public abstract void onInAny(Tree node, Tree colNode, Tree listNode);
- public abstract void onNotInAny(Tree node, Tree colNode, Tree listNode);
- public abstract void onEqAny(Tree node, Tree literalNode, Tree colNode);
-
- // Null comparisons:
- public abstract void onIsNull(Tree nullNode, Tree colNode);
- public abstract void onIsNotNull(Tree notNullNode, Tree colNode);
-
- // String matching:
- public abstract void onIsLike(Tree node, Tree colNode, Tree stringNode);
- public abstract void onIsNotLike(Tree node, Tree colNode, Tree stringNode);
-
- // Functions:
- public abstract void onInFolder(Tree node, Tree colNode, Tree paramNode);
- public abstract void onInTree(Tree node, Tree colNode, Tree paramNode);
- public abstract void onScore(Tree node);
-
- public void onPreTextAnd(Tree node, List<Tree> conjunctionNodes) {
- }
- public abstract void onTextAnd(Tree node, List<Tree> conjunctionNodes);
- public void onPostTextAnd(Tree node, List<Tree> conjunctionNodes) {
- }
- public void onPreTextOr(Tree node, List<Tree> termNodes) {
- }
- public abstract void onTextOr(Tree node, List<Tree> termNodes);
- public void onPostTextOr(Tree node, List<Tree> termNodes) {
- }
- public abstract void onTextMinus(Tree node, Tree notNode);
- public abstract void onTextWord(String word);
- public abstract void onTextPhrase(String phrase);
-
- // convenience method because everybody needs this piece of code
- public static CmisQueryWalker getWalker(String statement) throws UnsupportedEncodingException, IOException, RecognitionException {
- CharStream input = new ANTLRInputStream(new ByteArrayInputStream(statement.getBytes("UTF-8")));
- TokenSource lexer = new CmisQlStrictLexer(input);
- TokenStream tokens = new CommonTokenStream(lexer);
- CmisQlStrictParser parser = new CmisQlStrictParser(tokens);
- CommonTree parserTree; // the ANTLR tree after parsing phase
-
- query_return parsedStatement = parser.query();
-// if (parser.errorMessage != null) {
-// throw new RuntimeException("Cannot parse query: " + statement + " (" + parser.errorMessage + ")");
-// }
- parserTree = (CommonTree) parsedStatement.getTree();
-
- CommonTreeNodeStream nodes = new CommonTreeNodeStream(parserTree);
- nodes.setTokenStream(tokens);
- CmisQueryWalker walker = new CmisQueryWalker(nodes);
- return walker;
- }
-
-
- // Base interface called from query parser
- public Boolean walkPredicate(Tree whereNode) {
- if (null != whereNode) {
- onStartProcessing(whereNode);
- evalWhereNode(whereNode);
- onStopProcessing();
- }
- return null; // unused
- }
-
- // ///////////////////////////////////////////////////////
- // Processing the WHERE clause
-
- // default implementation for ^ains
- public void onContains(Tree node, Tree typeNode, Tree searchExprNode) {
- LOG.debug("evaluating text search node: " + searchExprNode);
- evalTextSearchNode(searchExprNode);
- }
-
- protected void evalWhereNode(Tree node) {
- // Ensure that we receive only valid tokens and nodes in the where
- // clause:
- LOG.debug("evaluating node: " + node.toString());
- switch (node.getType()) {
- case CmisQlStrictLexer.WHERE:
- break; // ignore
- case CmisQlStrictLexer.EQ:
- evalWhereNode(node.getChild(0));
- onEquals(node, node.getChild(0), node.getChild(1));
- evalWhereNode(node.getChild(1));
- break;
- case CmisQlStrictLexer.NEQ:
- evalWhereNode(node.getChild(0));
- onNotEquals(node, node.getChild(0), node.getChild(1));
- evalWhereNode(node.getChild(1));
- break;
- case CmisQlStrictLexer.GT:
- evalWhereNode(node.getChild(0));
- onGreaterThan(node, node.getChild(0), node.getChild(1));
- evalWhereNode(node.getChild(1));
- break;
- case CmisQlStrictLexer.GTEQ:
- evalWhereNode(node.getChild(0));
- onGreaterOrEquals(node, node.getChild(0), node.getChild(1));
- evalWhereNode(node.getChild(1));
- break;
- case CmisQlStrictLexer.LT:
- evalWhereNode(node.getChild(0));
- onLessThan(node, node.getChild(0), node.getChild(1));
- evalWhereNode(node.getChild(1));
- break;
- case CmisQlStrictLexer.LTEQ:
- evalWhereNode(node.getChild(0));
- onLessOrEquals(node, node.getChild(0), node.getChild(1));
- evalWhereNode(node.getChild(1));
- break;
-
- case CmisQlStrictLexer.NOT:
- onPreNot(node, node.getChild(0));
- onNot(node, node.getChild(0));
- evalWhereNode(node.getChild(0));
- onPostNot(node, node.getChild(0));
- break;
- case CmisQlStrictLexer.AND:
- onPreAnd(node, node.getChild(0), node.getChild(1));
- evalWhereNode(node.getChild(0));
- onAnd(node, node.getChild(0), node.getChild(1));
- evalWhereNode(node.getChild(1));
- onPostAnd(node, node.getChild(0), node.getChild(1));
- break;
- case CmisQlStrictLexer.OR:
- onPreOr(node, node.getChild(0), node.getChild(1));
- evalWhereNode(node.getChild(0));
- onOr(node, node.getChild(0), node.getChild(1));
- evalWhereNode(node.getChild(1));
- onPostOr(node, node.getChild(0), node.getChild(1));
- break;
-
- // Multi-value:
- case CmisQlStrictLexer.IN:
- evalWhereNode(node.getChild(0));
- onIn(node, node.getChild(0), node.getChild(1));
- evalWhereNode(node.getChild(1));
- break;
- case CmisQlStrictLexer.NOT_IN:
- evalWhereNode(node.getChild(0));
- onNotIn(node, node.getChild(0), node.getChild(1));
- evalWhereNode(node.getChild(1));
- break;
- case CmisQlStrictLexer.IN_ANY:
- evalWhereNode(node.getChild(0));
- onInAny(node, node.getChild(0), node.getChild(1));
- evalWhereNode(node.getChild(1));
- break;
- case CmisQlStrictLexer.NOT_IN_ANY:
- evalWhereNode(node.getChild(0));
- onNotInAny(node, node.getChild(0), node.getChild(1));
- evalWhereNode(node.getChild(1));
- break;
- case CmisQlStrictLexer.EQ_ANY:
- evalWhereNode(node.getChild(0));
- onEqAny(node, node.getChild(0), node.getChild(1));
- evalWhereNode(node.getChild(1));
- break;
-
- // Null comparisons:
- case CmisQlStrictLexer.IS_NULL:
- onIsNull(node, node.getChild(0));
- evalWhereNode(node.getChild(0));
- break;
- case CmisQlStrictLexer.IS_NOT_NULL:
- onIsNotNull(node, node.getChild(0));
- evalWhereNode(node.getChild(0));
- break;
-
- // String matching
- case CmisQlStrictLexer.LIKE:
- evalWhereNode(node.getChild(0));
- onIsLike(node, node.getChild(0), node.getChild(1));
- evalWhereNode(node.getChild(1));
- break;
- case CmisQlStrictLexer.NOT_LIKE:
- evalWhereNode(node.getChild(0));
- onIsNotLike(node, node.getChild(0), node.getChild(1));
- evalWhereNode(node.getChild(1));
- break;
-
- // Functions
- case CmisQlStrictLexer.CONTAINS:
- onContains(node, null, node.getChild(0));
- break;
- case CmisQlStrictLexer.IN_FOLDER:
- if (node.getChildCount() == 1) {
- onInFolder(node, null, node.getChild(0));
- evalWhereNode(node.getChild(0));
- } else {
- evalWhereNode(node.getChild(0));
- onInFolder(node, node.getChild(0), node.getChild(1));
- evalWhereNode(node.getChild(1));
- }
- break;
- case CmisQlStrictLexer.IN_TREE:
- if (node.getChildCount() == 1) {
- onInTree(node, null, node.getChild(0));
- evalWhereNode(node.getChild(0));
- } else {
- evalWhereNode(node.getChild(0));
- onInTree(node, node.getChild(0), node.getChild(1));
- evalWhereNode(node.getChild(1));
- }
- break;
- case CmisQlStrictLexer.SCORE:
- onScore(node);
- break;
-
- default:
- // do nothing;
- }
- }
-
- protected void evalTextSearchNode(Tree node) {
- // Ensure that we receive only valid tokens and nodes in the where
- // clause:
- LOG.debug("evaluating node: " + node.toString());
- switch (node.getType()) {
- case TextSearchLexer.TEXT_AND:
- List<Tree> children = getChildrenAsList(node);
- onPreTextAnd(node, children);
- for (Tree child : children)
- evalTextSearchNode(child);
- onTextAnd(node, children);
- onPostTextAnd(node, children);
- break;
- case TextSearchLexer.TEXT_OR:
- children = getChildrenAsList(node);
- onPreTextOr(node, children);
- for (Tree child : children)
- evalTextSearchNode(child);
- onTextOr(node, children);
- onPostTextOr(node, children);
- break;
- case TextSearchLexer.TEXT_MINUS:
- onTextMinus(node, node.getChild(0));
- break;
- case TextSearchLexer.TEXT_SEARCH_PHRASE_STRING_LIT:
- onTextPhrase(onTextLiteral(node));
- break;
- case TextSearchLexer.TEXT_SEARCH_WORD_LIT:
- onTextWord(onTextLiteral(node));
- break;
- }
- }
-
- // helper functions that are needed by most query tree walkers
-
- protected Object onLiteral(Tree node) {
- int type = node.getType();
- String text = node.getText();
- switch (type) {
- case CmisQlStrictLexer.BOOL_LIT:
- return Boolean.parseBoolean(node.getText());
- case CmisQlStrictLexer.NUM_LIT:
- if (text.contains(".") || text.contains("e") || text.contains("E")) {
- return Double.parseDouble(text);
- } else {
- return Long.parseLong(text);
- }
- case CmisQlStrictLexer.STRING_LIT:
- return text.substring(1, text.length()-1);
- case CmisQlStrictLexer.TIME_LIT:
- GregorianCalendar gc = CalendarHelper.fromString(text.substring(text.indexOf('\'')+1, text.lastIndexOf('\'')));
- return gc;
- default:
- throw new RuntimeException("Unknown literal. " + node);
- }
- }
-
- protected String onTextLiteral(Tree node) {
- int type = node.getType();
- String text = node.getText();
- switch (type) {
- case TextSearchLexer.TEXT_SEARCH_PHRASE_STRING_LIT:
- return StringUtil.unescape(text.substring(1, text.length()-1), null);
- case TextSearchLexer.TEXT_SEARCH_WORD_LIT:
- return StringUtil.unescape(text, null);
- default:
- throw new RuntimeException("Unknown text literal. " + node);
- }
-
- }
-
- protected List<Object> onLiteralList(Tree node) {
- List<Object> res = new ArrayList<Object>(node.getChildCount());
- for (int i=0; i<node.getChildCount(); i++) {
- Tree literal = node.getChild(i);
- res.add(onLiteral(literal));
- }
- return res;
- }
-
- protected List<Tree> getChildrenAsList(Tree node) {
- List<Tree> res = new ArrayList<Tree>(node.getChildCount());
- for (int i=0; i<node.getChildCount(); i++) {
- Tree childNnode = node.getChild(i);
- res.add(childNnode);
- }
- return res;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.inmemory.query;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.GregorianCalendar;
+import java.util.List;
+
+import org.antlr.runtime.ANTLRInputStream;
+import org.antlr.runtime.CharStream;
+import org.antlr.runtime.CommonTokenStream;
+import org.antlr.runtime.RecognitionException;
+import org.antlr.runtime.TokenSource;
+import org.antlr.runtime.TokenStream;
+import org.antlr.runtime.tree.CommonTree;
+import org.antlr.runtime.tree.CommonTreeNodeStream;
+import org.antlr.runtime.tree.Tree;
+import org.apache.chemistry.opencmis.server.support.query.CalendarHelper;
+import org.apache.chemistry.opencmis.server.support.query.CmisQlStrictLexer;
+import org.apache.chemistry.opencmis.server.support.query.CmisQlStrictParser;
+import org.apache.chemistry.opencmis.server.support.query.CmisQlStrictParser_CmisBaseGrammar.query_return;
+import org.apache.chemistry.opencmis.server.support.query.CmisQueryWalker;
+import org.apache.chemistry.opencmis.server.support.query.StringUtil;
+import org.apache.chemistry.opencmis.server.support.query.TextSearchLexer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class AbstractQueryConditionProcessor implements QueryConditionProcessor {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ProcessQueryTest.class);
+
+ public abstract void onStartProcessing(Tree whereNode);
+ public abstract void onStopProcessing();
+
+ // Compare operators
+ public abstract void onEquals(Tree eqNode, Tree leftNode, Tree rightNode);
+ public abstract void onNotEquals(Tree neNode, Tree leftNode, Tree rightNode);
+ public abstract void onGreaterThan(Tree gtNode, Tree leftNode, Tree rightNode);
+ public abstract void onGreaterOrEquals(Tree geNode, Tree leftNode, Tree rightNode);
+ public abstract void onLessThan(Tree ltNode, Tree leftNode, Tree rightNode);
+ public abstract void onLessOrEquals(Tree leqNode, Tree leftNode, Tree rightNode);
+
+ // Boolean operators
+ public void onPreNot(Tree opNode, Tree leftNode) {
+ }
+ public abstract void onNot(Tree opNode, Tree leftNode);
+ public void onPostNot(Tree opNode, Tree leftNode) {
+ }
+ public void onPreAnd(Tree opNode, Tree leftNode, Tree rightNode) {
+ }
+ public abstract void onAnd(Tree opNode, Tree leftNode, Tree rightNode);
+ public void onPostAnd(Tree opNode, Tree leftNode, Tree rightNode) {
+ }
+ public void onPreOr(Tree opNode, Tree leftNode, Tree rightNode) {
+ }
+ public abstract void onOr(Tree opNode, Tree leftNode, Tree rightNode);
+ public void onPostOr(Tree opNode, Tree leftNode, Tree rightNode) {
+ }
+
+ // Multi-value:
+ public abstract void onIn(Tree node, Tree colNode, Tree listNode);
+ public abstract void onNotIn(Tree node, Tree colNode, Tree listNode);
+ public abstract void onInAny(Tree node, Tree colNode, Tree listNode);
+ public abstract void onNotInAny(Tree node, Tree colNode, Tree listNode);
+ public abstract void onEqAny(Tree node, Tree literalNode, Tree colNode);
+
+ // Null comparisons:
+ public abstract void onIsNull(Tree nullNode, Tree colNode);
+ public abstract void onIsNotNull(Tree notNullNode, Tree colNode);
+
+ // String matching:
+ public abstract void onIsLike(Tree node, Tree colNode, Tree stringNode);
+ public abstract void onIsNotLike(Tree node, Tree colNode, Tree stringNode);
+
+ // Functions:
+ public abstract void onInFolder(Tree node, Tree colNode, Tree paramNode);
+ public abstract void onInTree(Tree node, Tree colNode, Tree paramNode);
+ public abstract void onScore(Tree node);
+
+ public void onPreTextAnd(Tree node, List<Tree> conjunctionNodes) {
+ }
+ public abstract void onTextAnd(Tree node, List<Tree> conjunctionNodes);
+ public void onPostTextAnd(Tree node, List<Tree> conjunctionNodes) {
+ }
+ public void onPreTextOr(Tree node, List<Tree> termNodes) {
+ }
+ public abstract void onTextOr(Tree node, List<Tree> termNodes);
+ public void onPostTextOr(Tree node, List<Tree> termNodes) {
+ }
+ public abstract void onTextMinus(Tree node, Tree notNode);
+ public abstract void onTextWord(String word);
+ public abstract void onTextPhrase(String phrase);
+
+ // convenience method because everybody needs this piece of code
+ public static CmisQueryWalker getWalker(String statement) throws UnsupportedEncodingException, IOException, RecognitionException {
+ CharStream input = new ANTLRInputStream(new ByteArrayInputStream(statement.getBytes("UTF-8")));
+ TokenSource lexer = new CmisQlStrictLexer(input);
+ TokenStream tokens = new CommonTokenStream(lexer);
+ CmisQlStrictParser parser = new CmisQlStrictParser(tokens);
+ CommonTree parserTree; // the ANTLR tree after parsing phase
+
+ query_return parsedStatement = parser.query();
+// if (parser.errorMessage != null) {
+// throw new RuntimeException("Cannot parse query: " + statement + " (" + parser.errorMessage + ")");
+// }
+ parserTree = (CommonTree) parsedStatement.getTree();
+
+ CommonTreeNodeStream nodes = new CommonTreeNodeStream(parserTree);
+ nodes.setTokenStream(tokens);
+ CmisQueryWalker walker = new CmisQueryWalker(nodes);
+ return walker;
+ }
+
+
+ // Base interface called from query parser
+ public Boolean walkPredicate(Tree whereNode) {
+ if (null != whereNode) {
+ onStartProcessing(whereNode);
+ evalWhereNode(whereNode);
+ onStopProcessing();
+ }
+ return null; // unused
+ }
+
+ // ///////////////////////////////////////////////////////
+ // Processing the WHERE clause
+
+ // default implementation for ^ains
+ public void onContains(Tree node, Tree typeNode, Tree searchExprNode) {
+ LOG.debug("evaluating text search node: " + searchExprNode);
+ evalTextSearchNode(searchExprNode);
+ }
+
+ protected void evalWhereNode(Tree node) {
+ // Ensure that we receive only valid tokens and nodes in the where
+ // clause:
+ LOG.debug("evaluating node: " + node.toString());
+ switch (node.getType()) {
+ case CmisQlStrictLexer.WHERE:
+ break; // ignore
+ case CmisQlStrictLexer.EQ:
+ evalWhereNode(node.getChild(0));
+ onEquals(node, node.getChild(0), node.getChild(1));
+ evalWhereNode(node.getChild(1));
+ break;
+ case CmisQlStrictLexer.NEQ:
+ evalWhereNode(node.getChild(0));
+ onNotEquals(node, node.getChild(0), node.getChild(1));
+ evalWhereNode(node.getChild(1));
+ break;
+ case CmisQlStrictLexer.GT:
+ evalWhereNode(node.getChild(0));
+ onGreaterThan(node, node.getChild(0), node.getChild(1));
+ evalWhereNode(node.getChild(1));
+ break;
+ case CmisQlStrictLexer.GTEQ:
+ evalWhereNode(node.getChild(0));
+ onGreaterOrEquals(node, node.getChild(0), node.getChild(1));
+ evalWhereNode(node.getChild(1));
+ break;
+ case CmisQlStrictLexer.LT:
+ evalWhereNode(node.getChild(0));
+ onLessThan(node, node.getChild(0), node.getChild(1));
+ evalWhereNode(node.getChild(1));
+ break;
+ case CmisQlStrictLexer.LTEQ:
+ evalWhereNode(node.getChild(0));
+ onLessOrEquals(node, node.getChild(0), node.getChild(1));
+ evalWhereNode(node.getChild(1));
+ break;
+
+ case CmisQlStrictLexer.NOT:
+ onPreNot(node, node.getChild(0));
+ onNot(node, node.getChild(0));
+ evalWhereNode(node.getChild(0));
+ onPostNot(node, node.getChild(0));
+ break;
+ case CmisQlStrictLexer.AND:
+ onPreAnd(node, node.getChild(0), node.getChild(1));
+ evalWhereNode(node.getChild(0));
+ onAnd(node, node.getChild(0), node.getChild(1));
+ evalWhereNode(node.getChild(1));
+ onPostAnd(node, node.getChild(0), node.getChild(1));
+ break;
+ case CmisQlStrictLexer.OR:
+ onPreOr(node, node.getChild(0), node.getChild(1));
+ evalWhereNode(node.getChild(0));
+ onOr(node, node.getChild(0), node.getChild(1));
+ evalWhereNode(node.getChild(1));
+ onPostOr(node, node.getChild(0), node.getChild(1));
+ break;
+
+ // Multi-value:
+ case CmisQlStrictLexer.IN:
+ evalWhereNode(node.getChild(0));
+ onIn(node, node.getChild(0), node.getChild(1));
+ evalWhereNode(node.getChild(1));
+ break;
+ case CmisQlStrictLexer.NOT_IN:
+ evalWhereNode(node.getChild(0));
+ onNotIn(node, node.getChild(0), node.getChild(1));
+ evalWhereNode(node.getChild(1));
+ break;
+ case CmisQlStrictLexer.IN_ANY:
+ evalWhereNode(node.getChild(0));
+ onInAny(node, node.getChild(0), node.getChild(1));
+ evalWhereNode(node.getChild(1));
+ break;
+ case CmisQlStrictLexer.NOT_IN_ANY:
+ evalWhereNode(node.getChild(0));
+ onNotInAny(node, node.getChild(0), node.getChild(1));
+ evalWhereNode(node.getChild(1));
+ break;
+ case CmisQlStrictLexer.EQ_ANY:
+ evalWhereNode(node.getChild(0));
+ onEqAny(node, node.getChild(0), node.getChild(1));
+ evalWhereNode(node.getChild(1));
+ break;
+
+ // Null comparisons:
+ case CmisQlStrictLexer.IS_NULL:
+ onIsNull(node, node.getChild(0));
+ evalWhereNode(node.getChild(0));
+ break;
+ case CmisQlStrictLexer.IS_NOT_NULL:
+ onIsNotNull(node, node.getChild(0));
+ evalWhereNode(node.getChild(0));
+ break;
+
+ // String matching
+ case CmisQlStrictLexer.LIKE:
+ evalWhereNode(node.getChild(0));
+ onIsLike(node, node.getChild(0), node.getChild(1));
+ evalWhereNode(node.getChild(1));
+ break;
+ case CmisQlStrictLexer.NOT_LIKE:
+ evalWhereNode(node.getChild(0));
+ onIsNotLike(node, node.getChild(0), node.getChild(1));
+ evalWhereNode(node.getChild(1));
+ break;
+
+ // Functions
+ case CmisQlStrictLexer.CONTAINS:
+ onContains(node, null, node.getChild(0));
+ break;
+ case CmisQlStrictLexer.IN_FOLDER:
+ if (node.getChildCount() == 1) {
+ onInFolder(node, null, node.getChild(0));
+ evalWhereNode(node.getChild(0));
+ } else {
+ evalWhereNode(node.getChild(0));
+ onInFolder(node, node.getChild(0), node.getChild(1));
+ evalWhereNode(node.getChild(1));
+ }
+ break;
+ case CmisQlStrictLexer.IN_TREE:
+ if (node.getChildCount() == 1) {
+ onInTree(node, null, node.getChild(0));
+ evalWhereNode(node.getChild(0));
+ } else {
+ evalWhereNode(node.getChild(0));
+ onInTree(node, node.getChild(0), node.getChild(1));
+ evalWhereNode(node.getChild(1));
+ }
+ break;
+ case CmisQlStrictLexer.SCORE:
+ onScore(node);
+ break;
+
+ default:
+ // do nothing;
+ }
+ }
+
+ protected void evalTextSearchNode(Tree node) {
+ // Ensure that we receive only valid tokens and nodes in the where
+ // clause:
+ LOG.debug("evaluating node: " + node.toString());
+ switch (node.getType()) {
+ case TextSearchLexer.TEXT_AND:
+ List<Tree> children = getChildrenAsList(node);
+ onPreTextAnd(node, children);
+ for (Tree child : children)
+ evalTextSearchNode(child);
+ onTextAnd(node, children);
+ onPostTextAnd(node, children);
+ break;
+ case TextSearchLexer.TEXT_OR:
+ children = getChildrenAsList(node);
+ onPreTextOr(node, children);
+ for (Tree child : children)
+ evalTextSearchNode(child);
+ onTextOr(node, children);
+ onPostTextOr(node, children);
+ break;
+ case TextSearchLexer.TEXT_MINUS:
+ onTextMinus(node, node.getChild(0));
+ break;
+ case TextSearchLexer.TEXT_SEARCH_PHRASE_STRING_LIT:
+ onTextPhrase(onTextLiteral(node));
+ break;
+ case TextSearchLexer.TEXT_SEARCH_WORD_LIT:
+ onTextWord(onTextLiteral(node));
+ break;
+ }
+ }
+
+ // helper functions that are needed by most query tree walkers
+
+ protected Object onLiteral(Tree node) {
+ int type = node.getType();
+ String text = node.getText();
+ switch (type) {
+ case CmisQlStrictLexer.BOOL_LIT:
+ return Boolean.parseBoolean(node.getText());
+ case CmisQlStrictLexer.NUM_LIT:
+ if (text.contains(".") || text.contains("e") || text.contains("E")) {
+ return Double.parseDouble(text);
+ } else {
+ return Long.parseLong(text);
+ }
+ case CmisQlStrictLexer.STRING_LIT:
+ return text.substring(1, text.length()-1);
+ case CmisQlStrictLexer.TIME_LIT:
+ GregorianCalendar gc = CalendarHelper.fromString(text.substring(text.indexOf('\'')+1, text.lastIndexOf('\'')));
+ return gc;
+ default:
+ throw new RuntimeException("Unknown literal. " + node);
+ }
+ }
+
+ protected String onTextLiteral(Tree node) {
+ int type = node.getType();
+ String text = node.getText();
+ switch (type) {
+ case TextSearchLexer.TEXT_SEARCH_PHRASE_STRING_LIT:
+ return StringUtil.unescape(text.substring(1, text.length()-1), null);
+ case TextSearchLexer.TEXT_SEARCH_WORD_LIT:
+ return StringUtil.unescape(text, null);
+ default:
+ throw new RuntimeException("Unknown text literal. " + node);
+ }
+
+ }
+
+ protected List<Object> onLiteralList(Tree node) {
+ List<Object> res = new ArrayList<Object>(node.getChildCount());
+ for (int i=0; i<node.getChildCount(); i++) {
+ Tree literal = node.getChild(i);
+ res.add(onLiteral(literal));
+ }
+ return res;
+ }
+
+ protected List<Tree> getChildrenAsList(Tree node) {
+ List<Tree> res = new ArrayList<Tree>(node.getChildCount());
+ for (int i=0; i<node.getChildCount(); i++) {
+ Tree childNnode = node.getChild(i);
+ res.add(childNnode);
+ }
+ return res;
+ }
+}
Modified: chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java?rev=1293600&r1=1293599&r2=1293600&view=diff
==============================================================================
--- chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java (original)
+++ chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java Sat Feb 25 13:43:31 2012
@@ -35,15 +35,15 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
import org.apache.chemistry.opencmis.inmemory.AbstractServiceTest;
import org.apache.chemistry.opencmis.inmemory.UnitTestTypeSystemCreator;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class EvalQueryTest extends AbstractServiceTest {
- private static final Log log = LogFactory.getLog(EvalQueryTest.class);
+ private static final Logger log = LoggerFactory.getLogger(EvalQueryTest.class);
private QueryTestDataCreator dataCreator;
@Override
Modified: chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ProcessQueryTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ProcessQueryTest.java?rev=1293600&r1=1293599&r2=1293600&view=diff
==============================================================================
--- chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ProcessQueryTest.java (original)
+++ chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ProcessQueryTest.java Sat Feb 25 13:43:31 2012
@@ -35,14 +35,14 @@ import org.apache.chemistry.opencmis.ser
import org.apache.chemistry.opencmis.server.support.query.CmisQlStrictLexer;
import org.apache.chemistry.opencmis.server.support.query.QueryObject;
import org.apache.chemistry.opencmis.server.support.query.TextSearchLexer;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.junit.Before;
import org.junit.Test;
public class ProcessQueryTest extends AbstractQueryTest {
- private static final Log LOG = LogFactory.getLog(ProcessQueryTest.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ProcessQueryTest.class);
private static class TestQueryProcessor extends AbstractQueryConditionProcessor {
Modified: chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java?rev=1293600&r1=1293599&r2=1293600&view=diff
==============================================================================
--- chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java (original)
+++ chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java Sat Feb 25 13:43:31 2012
@@ -41,14 +41,14 @@ import org.apache.chemistry.opencmis.ser
import org.apache.chemistry.opencmis.server.support.query.QueryObject;
import org.apache.chemistry.opencmis.server.support.query.QueryObject.SortSpec;
import org.apache.chemistry.opencmis.server.support.query.TextSearchLexer;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.junit.Before;
import org.junit.Test;
public class QueryParseTest extends AbstractQueryTest {
- private static final Log LOG = LogFactory.getLog(QueryParseTest.class);
+ private static final Logger LOG = LoggerFactory.getLogger(QueryParseTest.class);
@Before
public void setUp() {
Modified: chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTypesTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTypesTest.java?rev=1293600&r1=1293599&r2=1293600&view=diff
==============================================================================
--- chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTypesTest.java (original)
+++ chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTypesTest.java Sat Feb 25 13:43:31 2012
@@ -34,15 +34,15 @@ import org.apache.chemistry.opencmis.ser
import org.apache.chemistry.opencmis.server.support.query.ColumnReference;
import org.apache.chemistry.opencmis.server.support.query.QueryObject;
import org.apache.chemistry.opencmis.server.support.query.QueryObject.SortSpec;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class QueryTypesTest extends AbstractQueryTest {
- private static final Log LOG = LogFactory.getLog(QueryTypesTest.class);
+ private static final Logger LOG = LoggerFactory.getLogger(QueryTypesTest.class);
private TypeManagerImpl tm;
private TestPredicateWalker pw;
Modified: chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrDocument.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrDocument.java?rev=1293600&r1=1293599&r2=1293600&view=diff
==============================================================================
--- chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrDocument.java (original)
+++ chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrDocument.java Sat Feb 25 13:43:31 2012
@@ -31,8 +31,8 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl;
import org.apache.chemistry.opencmis.commons.impl.server.ObjectInfoImpl;
import org.apache.chemistry.opencmis.jcr.type.JcrTypeHandlerManager;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.jcr.Binary;
import javax.jcr.Node;
@@ -48,7 +48,7 @@ import java.util.Set;
* Instances of this class represent a cmis:document backed by an underlying JCR <code>Node</code>.
*/
public abstract class JcrDocument extends JcrNode {
- private static final Log log = LogFactory.getLog(JcrDocument.class);
+ private static final Logger log = LoggerFactory.getLogger(JcrDocument.class);
public static final String MIME_UNKNOWN = "application/octet-stream";
Modified: chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrFolder.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrFolder.java?rev=1293600&r1=1293599&r2=1293600&view=diff
==============================================================================
--- chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrFolder.java (original)
+++ chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrFolder.java Sat Feb 25 13:43:31 2012
@@ -37,8 +37,8 @@ import org.apache.chemistry.opencmis.jcr
import org.apache.chemistry.opencmis.jcr.util.FilterIterator;
import org.apache.chemistry.opencmis.jcr.util.Predicate;
import org.apache.chemistry.opencmis.jcr.util.Util;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
@@ -57,7 +57,7 @@ import java.util.Set;
* Instances of this class represent a cmis:folder backed by an underlying JCR <code>Node</code>.
*/
public class JcrFolder extends JcrNode {
- private static final Log log = LogFactory.getLog(JcrFolder.class);
+ private static final Logger log = LoggerFactory.getLogger(JcrFolder.class);
public JcrFolder(Node node, JcrTypeManager typeManager, PathManager pathManager, JcrTypeHandlerManager typeHandlerManager) {
super(node, typeManager, pathManager, typeHandlerManager);
Modified: chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrNode.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrNode.java?rev=1293600&r1=1293599&r2=1293600&view=diff
==============================================================================
--- chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrNode.java (original)
+++ chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrNode.java Sat Feb 25 13:43:31 2012
@@ -49,8 +49,8 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.server.ObjectInfoHandler;
import org.apache.chemistry.opencmis.jcr.type.JcrTypeHandlerManager;
import org.apache.chemistry.opencmis.jcr.util.Util;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.jcr.ItemNotFoundException;
import javax.jcr.Node;
@@ -75,7 +75,7 @@ import java.util.Set;
*/
public abstract class JcrNode {
- private static final Log log = LogFactory.getLog(JcrNode.class);
+ private static final Logger log = LoggerFactory.getLogger(JcrNode.class);
/**
* Default value for last cmis:createdBy and cmis:modifiedBy
Modified: chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrPrivateWorkingCopy.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrPrivateWorkingCopy.java?rev=1293600&r1=1293599&r2=1293600&view=diff
==============================================================================
--- chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrPrivateWorkingCopy.java (original)
+++ chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrPrivateWorkingCopy.java Sat Feb 25 13:43:31 2012
@@ -21,8 +21,8 @@ package org.apache.chemistry.opencmis.jc
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.jcr.type.JcrTypeHandlerManager;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
@@ -32,7 +32,7 @@ import javax.jcr.RepositoryException;
* JCR <code>Node</code>.
*/
public class JcrPrivateWorkingCopy extends JcrVersionBase {
- private static final Log log = LogFactory.getLog(JcrPrivateWorkingCopy.class);
+ private static final Logger log = LoggerFactory.getLogger(JcrPrivateWorkingCopy.class);
/**
* Name of a private working copy
Modified: chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrRepository.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrRepository.java?rev=1293600&r1=1293599&r2=1293600&view=diff
==============================================================================
--- chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrRepository.java (original)
+++ chemistry/opencmis/branches/android/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrRepository.java Sat Feb 25 13:43:31 2012
@@ -62,8 +62,8 @@ import org.apache.chemistry.opencmis.jcr
import org.apache.chemistry.opencmis.jcr.type.JcrFolderTypeHandler;
import org.apache.chemistry.opencmis.jcr.type.JcrTypeHandlerManager;
import org.apache.chemistry.opencmis.jcr.util.Util;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.jcr.Credentials;
import javax.jcr.ItemNotFoundException;
@@ -90,7 +90,7 @@ import java.util.Set;
* JCR back-end for CMIS server.
*/
public class JcrRepository {
- private static final Log log = LogFactory.getLog(JcrRepository.class);
+ private static final Logger log = LoggerFactory.getLogger(JcrRepository.class);
private final Repository repository;
private final JcrTypeManager typeManager;
@@ -113,7 +113,7 @@ public class JcrRepository {
}
/**
- * Log into the underlying JCR repository.
+ * Logger into the underlying JCR repository.
*
* @param credentials
* @param workspaceName