You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by je...@apache.org on 2010/11/29 21:09:16 UTC
svn commit: r1040262 - in
/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server:
chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/
chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistr...
Author: jens
Date: Mon Nov 29 20:09:15 2010
New Revision: 1040262
URL: http://svn.apache.org/viewvc?rev=1040262&view=rev
Log:
code cleanup after FindBugs check
Modified:
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTestDataCreator.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTypesTest.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQueryWalker.g
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java?rev=1040262&r1=1040261&r2=1040262&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java Mon Nov 29 20:09:15 2010
@@ -580,7 +580,7 @@ public class InMemoryQueryProcessor {
if (rVal instanceof Double)
return lDoubleValue.compareTo((Double) rVal);
else if (rVal instanceof Long)
- return Double.valueOf(((Integer) lValue).doubleValue()).compareTo((Double) rVal);
+ return Double.valueOf(((Integer) lValue).doubleValue()).compareTo(((Long)rVal).doubleValue());
else
throwIncompatibleTypesException(lValue, rVal);
break;
@@ -625,7 +625,7 @@ public class InMemoryQueryProcessor {
return null;
else {
if (pd.getCardinality() == Cardinality.SINGLE)
- return null == lVal ? null : lVal.getFirstValue();
+ return lVal.getFirstValue();
else
return lVal.getValues();
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java?rev=1040262&r1=1040261&r2=1040262&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java Mon Nov 29 20:09:15 2010
@@ -224,7 +224,7 @@ public class InMemoryObjectServiceImpl e
fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, od, objectInfo);
objectInfos.addObjectInfo(objectInfo);
}
- return so.getId();
+ return so != null ? so.getId() : null;
}
public void deleteContentStream(CallContext context, String repositoryId, Holder<String> objectId,
@@ -304,7 +304,7 @@ public class InMemoryObjectServiceImpl e
LOG.debug("start getAllowableActions()");
StoredObject so = checkStandardParameters(repositoryId, objectId);
- ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
+ fStoreManager.getObjectStore(repositoryId);
if (so == null)
throw new CmisObjectNotFoundException("Unknown object id: " + objectId);
@@ -804,7 +804,6 @@ public class InMemoryObjectServiceImpl e
Map<String, PropertyData<?>> propMapNew = setDefaultProperties(typeDef, propMap);
if (propMapNew != propMap) {
properties = new PropertiesImpl(propMapNew.values());
- propMap = propMapNew;
}
TypeValidator.validateProperties(typeDef, properties, true);
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java?rev=1040262&r1=1040261&r2=1040262&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java Mon Nov 29 20:09:15 2010
@@ -24,6 +24,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import org.apache.chemistry.opencmis.commons.PropertyIds;
import org.apache.chemistry.opencmis.commons.data.AllowableActions;
@@ -273,12 +274,10 @@ public class PropertyCreationHelper {
}
// add functions:
BindingsObjectFactory objFactory = new BindingsObjectFactoryImpl();
- for (String func : requestedFuncs.keySet()) {
- PropertyInteger pi = objFactory.createPropertyIntegerData(func, BigInteger.valueOf(100)); // fixed
- // dummy
- // value
- mappedProperties.put(requestedFuncs.get(func), pi);
-
+ for (Entry<String, String> funcEntry : requestedFuncs.entrySet()) {
+ PropertyInteger pi = objFactory.createPropertyIntegerData(funcEntry.getKey(), BigInteger.valueOf(100));
+ // fixed dummy value
+ mappedProperties.put(funcEntry.getValue(), pi);
}
Properties props = new PropertiesImpl(mappedProperties.values());
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java?rev=1040262&r1=1040261&r2=1040262&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java Mon Nov 29 20:09:15 2010
@@ -128,6 +128,7 @@ public class ObjectServiceTest extends A
Properties props = createDocumentProperties("DocumentWithAFolderType", FOLDER_TYPE_ID);
id = fObjSvc.createDocument(fRepositoryId, props, fRootFolderId, null, VersioningState.NONE, null, null,
null, null);
+ assertNotNull(id);
fail("Creating document with a folder type should fail.");
} catch (Exception e) {
log.info("Creating document with a folder type failed as expected.");
@@ -135,7 +136,7 @@ public class ObjectServiceTest extends A
// test create a document with an illegal name, should fail:
try {
Properties props = createDocumentProperties("abc ()", DOCUMENT_TYPE_ID);
- id = fObjSvc.createDocument(fRepositoryId, props, fRootFolderId, null, VersioningState.NONE, null, null,
+ fObjSvc.createDocument(fRepositoryId, props, fRootFolderId, null, VersioningState.NONE, null, null,
null, null);
fail("Creating document with an illegal name should fail.");
} catch (Exception e) {
@@ -161,7 +162,7 @@ public class ObjectServiceTest extends A
}
try {
- createDocumentNoCatch("/(%#$§", fRootFolderId, DOCUMENT_TYPE_ID, VersioningState.NONE, false);
+ createDocumentNoCatch("/(%#$�", fRootFolderId, DOCUMENT_TYPE_ID, VersioningState.NONE, false);
fail("Document creation with ilegal name should fail.");
} catch (Exception e) {
assertTrue(e instanceof CmisInvalidArgumentException);
@@ -193,7 +194,7 @@ public class ObjectServiceTest extends A
}
try {
- createFolderNoCatch("/(%#$§", fRootFolderId, FOLDER_TYPE_ID);
+ createFolderNoCatch("/(%#$�", fRootFolderId, FOLDER_TYPE_ID);
fail("Folder creation with ilegal name should fail.");
} catch (Exception e) {
assertTrue(e instanceof CmisInvalidArgumentException);
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java?rev=1040262&r1=1040261&r2=1040262&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java Mon Nov 29 20:09:15 2010
@@ -723,7 +723,7 @@ public class EvalQueryTest extends Abstr
statement = "SELECT * FROM " + COMPLEX_TYPE + " WHERE 'black' = ANY " + UnitTestTypeSystemCreator.PROP_ID_STRING;
try {
- res = doQuery(statement);
+ doQuery(statement);
fail("Unknown = ANY with single value prop should throw exception");
} catch (Exception e) {
assertTrue(e.toString().contains("only is allowed on multi-value properties"));
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java?rev=1040262&r1=1040261&r2=1040262&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java Mon Nov 29 20:09:15 2010
@@ -20,17 +20,15 @@ package org.apache.chemistry.opencmis.in
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.Map;
import org.antlr.runtime.FailedPredicateException;
-import org.antlr.runtime.MismatchedTokenException;
import org.antlr.runtime.RecognitionException;
import org.antlr.runtime.tree.CommonTree;
import org.antlr.runtime.tree.Tree;
@@ -66,9 +64,9 @@ public class QueryParseTest extends Abst
@Test
public void simpleFailTest() {
String statement = "SELECT * TO MyType ORDER BY abc.def ASC";
-// String statement = "SELECT dsfj disfj dsifj dsoijfß039fi ";
+// String statement = "SELECT dsfj disfj dsifj dsoijf�039fi ";
try {
- CmisQueryWalker walker = traverseStatement(statement);
+ traverseStatement(statement);
fail("Errornous statement should throw exception.");
} catch (Exception e) {
LOG.debug("Exception in simpleFailTest: " + e);
@@ -79,6 +77,7 @@ public class QueryParseTest extends Abst
String statement = "SELECT SCORE() FROM cmis:document";
CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
+ assertNotNull(walker);
List<CmisSelector> selects = queryObj.getSelectReferences();
assertTrue(1 == selects.size());
assertTrue(selects.get(0) instanceof FunctionReference);
@@ -90,6 +89,7 @@ public class QueryParseTest extends Abst
public void simpleSelectTest2() throws Exception {
String statement = "SELECT abc FROM cmis:document";
CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
+ assertNotNull(walker);
List<CmisSelector> selects = queryObj.getSelectReferences();
assertTrue(1 == selects.size());
// nothing should be in where references
@@ -105,6 +105,7 @@ public class QueryParseTest extends Abst
public void simpleSelectTest3() throws Exception {
String statement = "SELECT t1.abc FROM cmis:document";
CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
+ assertNotNull(walker);
List<CmisSelector> selects = queryObj.getSelectReferences();
assertTrue(1 == selects.size());
// nothing should be in where references
@@ -120,6 +121,7 @@ public class QueryParseTest extends Abst
public void simpleSelectTest4() throws Exception {
String statement = "SELECT * FROM cmis:document";
CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
+ assertNotNull(walker);
List<CmisSelector> selects = queryObj.getSelectReferences();
assertTrue(1 == selects.size());
// nothing should be in where references
@@ -136,6 +138,7 @@ public class QueryParseTest extends Abst
public void simpleSelectTest5() throws Exception {
String statement = "SELECT t1.* FROM cmis:document";
CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
+ assertNotNull(walker);
List<CmisSelector> selects = queryObj.getSelectReferences();
assertTrue(1 == selects.size());
// nothing should be in where references
@@ -151,6 +154,7 @@ public class QueryParseTest extends Abst
public void simpleSelectTest6() throws Exception {
String statement = "SELECT t2.aaa myalias FROM cmis:document";
CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
+ assertNotNull(walker);
List<CmisSelector> selects = queryObj.getSelectReferences();
assertTrue(1 == selects.size());
// nothing should be in where references
@@ -180,6 +184,7 @@ public class QueryParseTest extends Abst
String statement = "SELECT * FROM MyType MyAlias";
CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
+ assertNotNull(walker);
Map<String,String> types = queryObj.getTypes();
assertTrue(1 == types.size());
String key = types.keySet().iterator().next();
@@ -191,6 +196,7 @@ public class QueryParseTest extends Abst
public void simpleFromTest2() throws Exception {
String statement = "SELECT * FROM MyType";
CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
+ assertNotNull(walker);
Map<String,String> types = queryObj.getTypes();
assertTrue(1 == types.size());
String key = types.keySet().iterator().next();
@@ -203,6 +209,7 @@ public class QueryParseTest extends Abst
public void simpleFromTest3() throws Exception {
String statement = "SELECT t2.aaa FROM MyType abc123";
CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
+ assertNotNull(walker);
Map<String,String> types = queryObj.getTypes();
assertTrue(1 == types.size());
String key = types.keySet().iterator().next();
@@ -214,6 +221,7 @@ public class QueryParseTest extends Abst
public void simpleFromTest4() throws Exception {
String statement = "SELECT X.aaa FROM MyType AS X WHERE 10 = ANY X.aaa ";
CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
+ assertNotNull(walker);
Map<String,String> types = queryObj.getTypes();
assertTrue(1 == types.size());
String key = types.keySet().iterator().next();
@@ -226,6 +234,7 @@ public class QueryParseTest extends Abst
String statement = "SELECT * FROM MyType WHERE MyProp1=123";
CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
+ assertNotNull(walker);
List<CmisSelector> whereRefs = queryObj.getWhereReferences();
Map<Integer, CmisSelector> colRefs = queryObj.getColumnReferences();
assertTrue(1 == whereRefs.size());
@@ -259,14 +268,6 @@ public class QueryParseTest extends Abst
return found;
}
- // check if the map containing all column references in the where clause has an existing node as key
- private void traverseTreeAndFindNodeInColumnMap2(Tree node, Map<Object, CmisSelector> colRefs) {
- for (Object obj : colRefs.keySet()){
- LOG.debug("find object: " + obj + " identity hash code: " + System.identityHashCode(obj));
- assertTrue(traverseTreeAndFindNodeInColumnMap2(node, obj));
- }
- }
-
private boolean traverseTreeAndFindNodeInColumnMap2(Tree node, Object colRef) {
int count = node.getChildCount();
LOG.debug(" checking with: " + node + " identity hash code: " + System.identityHashCode(node));
@@ -285,6 +286,7 @@ public class QueryParseTest extends Abst
String statement = "SELECT * FROM MyType ORDER BY abc.def ASC";
CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
+ assertNotNull(walker);
List<SortSpec> orderBys = queryObj.getOrderBys();
assertTrue(1 == orderBys.size());
SortSpec sp = orderBys.get(0);
@@ -299,6 +301,7 @@ public class QueryParseTest extends Abst
public void simpleSortTest2() throws Exception {
String statement = "SELECT * FROM MyType ORDER BY def DESC";
CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
+ assertNotNull(walker);
List<SortSpec> orderBys = queryObj.getOrderBys();
assertTrue(1 == orderBys.size());
SortSpec sp = orderBys.get(0);
@@ -474,6 +477,7 @@ public class QueryParseTest extends Abst
String statement = "SELECT * FROM MyType JOIN YourType WHERE a='1'";
CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
+ assertNotNull(walker);
QueryObject from = queryObj;
Map<String,String> types = from.getTypes();
assertTrue(2 == types.size());
@@ -644,6 +648,7 @@ public class QueryParseTest extends Abst
break; // ignore
case CmisQlStrictLexer.COL:
evalColumn(node);
+ break;
case CmisQlStrictLexer.IN_LIST:
evalInList(node);
break;
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTestDataCreator.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTestDataCreator.java?rev=1040262&r1=1040261&r2=1040262&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTestDataCreator.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTestDataCreator.java Mon Nov 29 20:09:15 2010
@@ -117,12 +117,13 @@ public class QueryTestDataCreator {
new HashMap<String, Object>() {
{
put(PROP_ID_STRING, "Alpha");
- put(PROP_ID_INT, new Integer(-100));
- put(PROP_ID_DECIMAL, new Double(-4.0E24d));
+ put(PROP_ID_INT, Integer.valueOf(-100));
+ put(PROP_ID_DECIMAL, Double.valueOf(-4.0E24d));
put(PROP_ID_DATETIME, gc1);
put(PROP_ID_BOOLEAN, true);
}};
doc1 = createDocument("alpha", rootFolderId, COMPLEX_TYPE, propertyMap1);
+ assertNotNull(doc1);
final GregorianCalendar gc2 = new GregorianCalendar(TZ);
gc2.clear();
@@ -132,23 +133,25 @@ public class QueryTestDataCreator {
new HashMap<String, Object>() {
{
put(PROP_ID_STRING, "Beta");
- put(PROP_ID_INT, new Integer(-50));
- put(PROP_ID_DECIMAL, new Double(-1.6E-5d));
+ put(PROP_ID_INT, Integer.valueOf(-50));
+ put(PROP_ID_DECIMAL, Double.valueOf(-1.6E-5d));
put(PROP_ID_DATETIME, gc2);
put(PROP_ID_BOOLEAN, false);
}};
doc2 = createDocument("beta", rootFolderId, COMPLEX_TYPE, propertyMap2);
+ assertNotNull(doc2);
final Map<String, Object> propertyMap3 =
new HashMap<String, Object>() {
{
put(PROP_ID_STRING, "Gamma");
- put(PROP_ID_INT, new Integer(0));
- put(PROP_ID_DECIMAL, new Double(Math.PI));
+ put(PROP_ID_INT, Integer.valueOf(0));
+ put(PROP_ID_DECIMAL, Double.valueOf(Math.PI));
put(PROP_ID_DATETIME, new GregorianCalendar(TZ));
put(PROP_ID_BOOLEAN, true);
}};
doc3 = createDocument("gamma", rootFolderId, COMPLEX_TYPE, propertyMap3);
+ assertNotNull(doc3);
final GregorianCalendar gc4 = new GregorianCalendar(TZ);
gc4.clear();
@@ -158,12 +161,13 @@ public class QueryTestDataCreator {
new HashMap<String, Object>() {
{
put(PROP_ID_STRING, "Delta");
- put(PROP_ID_INT, new Integer(50));
- put(PROP_ID_DECIMAL, new Double(1.23456E-6));
+ put(PROP_ID_INT, Integer.valueOf(50));
+ put(PROP_ID_DECIMAL, Double.valueOf(1.23456E-6));
put(PROP_ID_DATETIME, gc4);
put(PROP_ID_BOOLEAN, true);
}};
doc4 = createDocument("delta", rootFolderId, COMPLEX_TYPE, propertyMap4);
+ assertNotNull(doc4);
final GregorianCalendar gc5 = new GregorianCalendar(TZ);
gc5.clear();
@@ -173,12 +177,13 @@ public class QueryTestDataCreator {
new HashMap<String, Object>() {
{
put(PROP_ID_STRING, "Epsilon");
- put(PROP_ID_INT, new Integer(100));
- put(PROP_ID_DECIMAL, new Double(1.2345E12));
+ put(PROP_ID_INT, Integer.valueOf(100));
+ put(PROP_ID_DECIMAL, Double.valueOf(1.2345E12));
put(PROP_ID_DATETIME, gc5);
put(PROP_ID_BOOLEAN, false);
}};
doc5 = createDocument("epsilon", rootFolderId, COMPLEX_TYPE, propertyMap5);
+ assertNotNull(doc5);
}
@@ -196,7 +201,7 @@ public class QueryTestDataCreator {
new HashMap<String, Object>() {
{
put(PROP_ID_STRING_MULTI_VALUE, mvProps1);
- put(PROP_ID_INT, new Integer(100));
+ put(PROP_ID_INT, Integer.valueOf(100));
}};
createDocument("mv-alpha", rootFolderId, COMPLEX_TYPE, propertyMap1);
@@ -212,7 +217,7 @@ public class QueryTestDataCreator {
new HashMap<String, Object>() {
{
put(PROP_ID_STRING_MULTI_VALUE, mvProps2);
- put(PROP_ID_INT, new Integer(200));
+ put(PROP_ID_INT, Integer.valueOf(200));
}};
createDocument("mv-beta", rootFolderId, COMPLEX_TYPE, propertyMap2);
}
@@ -222,7 +227,7 @@ public class QueryTestDataCreator {
final Map<String, Object> propertyMap1 =
new HashMap<String, Object>() {
{
- put(PROP_ID_INT, new Integer(1234));
+ put(PROP_ID_INT, Integer.valueOf(1234));
put(PROP_ID_STRING, "ABCD");
}};
folder1 = createFolder("Folder 1", rootFolderId, FOLDER_TYPE, propertyMap1);
@@ -230,7 +235,7 @@ public class QueryTestDataCreator {
final Map<String, Object> propertyMap2 =
new HashMap<String, Object>() {
{
- put(PROP_ID_INT, new Integer(-2345));
+ put(PROP_ID_INT, Integer.valueOf(-2345));
put(PROP_ID_STRING, "defg");
}};
folder2 = createFolder("Folder 2", rootFolderId, FOLDER_TYPE, propertyMap2);
@@ -238,7 +243,7 @@ public class QueryTestDataCreator {
final Map<String, Object> propertyMap3 =
new HashMap<String, Object>() {
{
- put(PROP_ID_INT, new Integer(123));
+ put(PROP_ID_INT, Integer.valueOf(123));
put(PROP_ID_STRING, "ZZZZ");
}};
folder11 = createFolder("Folder 11", folder1, FOLDER_TYPE, propertyMap3);
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTypesTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTypesTest.java?rev=1040262&r1=1040261&r2=1040262&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTypesTest.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTypesTest.java Mon Nov 29 20:09:15 2010
@@ -18,6 +18,7 @@
*/
package org.apache.chemistry.opencmis.inmemory.query;
+import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -138,6 +139,7 @@ public class QueryTypesTest extends Abst
private void verifyResolveSelect(String statement) throws Exception {
CmisQueryWalker walker = traverseStatement(statement);
+ assertNotNull(walker);
Map<String,String> types = queryObj.getTypes();
assertTrue(1 == types.size());
List<CmisSelector> selects = queryObj.getSelectReferences();
@@ -155,6 +157,7 @@ public class QueryTypesTest extends Abst
String statement = "SELECT BookType.Title, MyDocType.MyStringProp FROM BookType JOIN MyDocType WHERE BookType.ISBN = '100'";
CmisQueryWalker walker = traverseStatement(statement);
+ assertNotNull(walker);
Map<String,String> types = queryObj.getTypes();
assertTrue(2 == types.size());
List<CmisSelector> selects = queryObj.getSelectReferences();
@@ -174,7 +177,8 @@ public class QueryTypesTest extends Abst
String statement = "SELECT Title, MyStringProp FROM BookType JOIN MyDocType AS MyDocAlias WHERE BookType.ISBN = '100'";
CmisQueryWalker walker = traverseStatement(statement);
- Map<String,String> types = queryObj.getTypes();
+ assertNotNull(walker);
+ Map<String,String> types = queryObj.getTypes();
assertTrue(2 == types.size());
List<CmisSelector> selects = queryObj.getSelectReferences();
assertTrue(2 == selects.size());
@@ -206,6 +210,7 @@ public class QueryTypesTest extends Abst
String statement = "SELECT MyDocType.MyStringProp FROM MyDocTypeCopy JOIN MyDocType";
CmisQueryWalker walker = traverseStatement(statement);
+ assertNotNull(walker);
Map<String,String> types = queryObj.getTypes();
assertTrue(2 == types.size());
List<CmisSelector> selects = queryObj.getSelectReferences();
@@ -219,6 +224,7 @@ public class QueryTypesTest extends Abst
public void resolveTypesTest11() throws Exception {
String statement = "SELECT BookType.* FROM BookType WHERE ISBN = '100'";
CmisQueryWalker walker = traverseStatement(statement);
+ assertNotNull(walker);
Map<String,String> types = queryObj.getTypes();
assertTrue(1 == types.size());
List<CmisSelector> selects = queryObj.getSelectReferences();
@@ -232,6 +238,7 @@ public class QueryTypesTest extends Abst
public void resolveTypesTest12() throws Exception {
String statement = "SELECT * FROM MyDocTypeCopy JOIN MyDocType";
CmisQueryWalker walker = traverseStatement(statement);
+ assertNotNull(walker);
Map<String,String> types = queryObj.getTypes();
assertTrue(2 == types.size());
List<CmisSelector> selects = queryObj.getSelectReferences();
@@ -269,6 +276,7 @@ public class QueryTypesTest extends Abst
public void resolveTypesWhereWithTwoFromsUnqualified() throws Exception {
String statement = "SELECT * FROM BookType JOIN MyDocType WHERE ISBN = '100'";
CmisQueryWalker walker = traverseStatement(statement);
+ assertNotNull(walker);
List<CmisSelector> wheres = queryObj.getWhereReferences();
assertTrue(1 == wheres.size());
for (CmisSelector where : wheres) {
@@ -283,6 +291,7 @@ public class QueryTypesTest extends Abst
public void resolveTypesWhereWithTwoFromsQualified() throws Exception {
String statement = "SELECT * FROM BookType JOIN MyDocType AS MyDocAlias WHERE BookType.ISBN = '100'";
CmisQueryWalker walker = traverseStatement(statement);
+ assertNotNull(walker);
List<CmisSelector> wheres = queryObj.getWhereReferences();
assertTrue(1 == wheres.size());
for (CmisSelector where : wheres) {
@@ -298,6 +307,7 @@ public class QueryTypesTest extends Abst
public void resolveTypesWhereWithTwoFromsQualifiedWithAlias() throws Exception {
String statement = "SELECT * FROM BookType AS MyBookAlias JOIN MyDocType WHERE MyBookAlias.ISBN = '100'";
CmisQueryWalker walker = traverseStatement(statement);
+ assertNotNull(walker);
List<CmisSelector> wheres = queryObj.getWhereReferences();
assertTrue(1 == wheres.size());
for (CmisSelector where : wheres) {
@@ -313,6 +323,7 @@ public class QueryTypesTest extends Abst
// String statement = "SELECT X.aaa FROM MyType AS X WHERE 10 = ANY X.aaa ";
String statement = "SELECT MyBookAlias.Title FROM BookType AS MyBookAlias WHERE MyBookAlias.ISBN = '100'";
CmisQueryWalker walker = traverseStatement(statement);
+ assertNotNull(walker);
List<CmisSelector> wheres = queryObj.getWhereReferences();
assertTrue(1 == wheres.size());
for (CmisSelector where : wheres) {
@@ -324,6 +335,7 @@ public class QueryTypesTest extends Abst
private void verifyResolveWhere(String statement) throws Exception {
CmisQueryWalker walker = traverseStatement(statement);
+ assertNotNull(walker);
Map<String,String> types = queryObj.getTypes();
assertTrue(1 == types.size());
List<CmisSelector> wheres = queryObj.getWhereReferences();
@@ -341,7 +353,7 @@ public class QueryTypesTest extends Abst
String statement = "SELECT * FROM MyDocTypeCopy JOIN MyDocType WHERE MyStringProp = '100'";
try {
- CmisQueryWalker walker = traverseStatement(statement);
+ traverseStatement(statement);
fail("Select with an unqualified property that is not unique should fail.");
} catch (Exception e) {
assertTrue(e instanceof RecognitionException);
@@ -353,6 +365,7 @@ public class QueryTypesTest extends Abst
public void resolveTypesWhereWithTwoFromsUniqueByQualifying() throws Exception {
String statement = "SELECT * FROM MyDocTypeCopy JOIN MyDocType WHERE MyDocType.MyStringProp = '100'";
CmisQueryWalker walker = traverseStatement(statement);
+ assertNotNull(walker);
List<CmisSelector> wheres = queryObj.getWhereReferences();
assertTrue(1 == wheres.size());
for (CmisSelector where : wheres) {
@@ -367,6 +380,7 @@ public class QueryTypesTest extends Abst
public void resolveTypesOrderBy() throws Exception {
String statement = "SELECT Title AS TitleAlias FROM BookType WHERE Author = 'Jim' ORDER BY TitleAlias";
CmisQueryWalker walker = traverseStatement(statement);
+ assertNotNull(walker);
List<SortSpec> sorts = queryObj.getOrderBys();
assertTrue(1 == sorts.size());
for (SortSpec sort : sorts) {
@@ -381,6 +395,7 @@ public class QueryTypesTest extends Abst
public void resolveTypesOrderBy2() throws Exception {
String statement = "SELECT Title AS TitleAlias FROM BookType WHERE Author = 'Jim' ORDER BY BookType.Author";
CmisQueryWalker walker = traverseStatement(statement);
+ assertNotNull(walker);
List<SortSpec> sorts = queryObj.getOrderBys();
assertTrue(1 == sorts.size());
for (SortSpec sort : sorts) {
@@ -395,6 +410,7 @@ public class QueryTypesTest extends Abst
public void resolveTypesOrderBy3() throws Exception {
String statement = "SELECT Title FROM BookType WHERE ISBN < '100' ORDER BY Author";
CmisQueryWalker walker = traverseStatement(statement);
+ assertNotNull(walker);
List<SortSpec> sorts = queryObj.getOrderBys();
assertTrue(1 == sorts.size());
for (SortSpec sort : sorts) {
@@ -409,6 +425,7 @@ public class QueryTypesTest extends Abst
public void resolveJoinTypesSimple() throws Exception {
String statement = "SELECT * FROM MyDocType JOIN BookType ON MyDocType.MyStringProp = BookType.Title";
CmisQueryWalker walker = traverseStatement(statement);
+ assertNotNull(walker);
List<CmisSelector> joins = queryObj.getJoinReferences();
assertTrue(2 == joins.size());
for (CmisSelector join : joins) {
@@ -431,6 +448,7 @@ public class QueryTypesTest extends Abst
// "FROM ( POLICY AS X JOIN CLAIMS AS Y ON X.POLICY_NUM = Y.POLICY_NUM ) " +
// "WHERE ( 100000 = ANY Y.DAMAGE_ESTIMATES )";
CmisQueryWalker walker = traverseStatement(statement);
+ assertNotNull(walker);
List<CmisSelector> joins = queryObj.getJoinReferences();
assertTrue(2 == joins.size());
for (CmisSelector join : joins) {
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQueryWalker.g
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQueryWalker.g?rev=1040262&r1=1040261&r2=1040262&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQueryWalker.g (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQueryWalker.g Mon Nov 29 20:09:15 2010
@@ -301,12 +301,12 @@ literal returns [Object value]:
| STRING_LIT
{
String s = $STRING_LIT.text;
- $value = s.substring(1, s.length() - 1);
+ $value = s!= null ? s.substring(1, s.length() - 1) : null;
}
| TIME_LIT
{
String s = $TIME_LIT.text;
- s = s.substring(s.indexOf('\'') + 1, s.length() - 1);
+ s = s!= null ? s.substring(s.indexOf('\'') + 1, s.length() - 1) : null;
try {
// $value = CalendarHelper.fromString(s);
} catch (IllegalArgumentException e) {