chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1340032 - in /chemistry/opencmis/trunk/chemistry-opencmis-server: chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/...
Date Fri, 18 May 2012 08:46:21 GMT
Author: jens
Date: Fri May 18 08:46:21 2012
New Revision: 1340032

URL: http://svn.apache.org/viewvc?rev=1340032&view=rev
Log:
raise exception if query parsing does not consume all input tokens [CMIS-526]

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtil.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserStrict.java

Modified: 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/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java?rev=1340032&r1=1340031&r2=1340032&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java
Fri May 18 08:46:21 2012
@@ -451,6 +451,18 @@ public class QueryParseTest extends Abst
     }
 
     @Test
+    public void whereTestTokensAfterStatement() {
+    	String statement = "SELECT p1 FROM MyType WHERE p1 LIKE 'abc*' IN_FOLDER('def')";
+    	try {
+            checkTreeWhere(statement);    		
+    	} catch (Exception e) {
+    		LOG.debug("Exception is: " + e);
+    		assertTrue(e instanceof CmisInvalidArgumentException);
+    		assertTrue(e.getMessage().contains("illegal tokens after end"));
+    	}
+    }
+
+    @Test
     public void whereTestNotLike() {
         String statement = "SELECT p1 FROM MyType WHERE p1 NOT LIKE 'abc*'";
         checkTreeWhere(statement);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtil.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtil.java?rev=1340032&r1=1340031&r2=1340032&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtil.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtil.java
Fri May 18 08:46:21 2012
@@ -54,7 +54,10 @@ public class QueryUtil {
         query_return parsedStatement = parser.query();
         if (parser.hasErrors()) {
             throw new CmisInvalidArgumentException(parser.getErrorMessages());
+        } else if ( tokens.index()!=tokens.size() ) {
+            throw new  CmisInvalidArgumentException("Query String has illegal tokens after
end of statement: " + tokens.get(tokens.index()));
         }
+        
         parserTree = (CommonTree) parsedStatement.getTree();
 
         CommonTreeNodeStream nodes = new CommonTreeNodeStream(parserTree);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserStrict.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserStrict.java?rev=1340032&r1=1340031&r2=1340032&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserStrict.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserStrict.java
Fri May 18 08:46:21 2012
@@ -596,6 +596,10 @@ public class TestParserStrict extends Ab
         testParser("folder_predicate","IN_TREE('ID123')" , " (IN_TREE 'ID123')");
     }
 
+    @Test
+    public void folder_predicate() throws Exception {
+        testParser("search_condition", "id456 LIKE 'Foo%' AND IN_FOLDER('abc')", "(AND (LIKE
'id456' 'Foo%') (IN_FOLDER 'abc')");
+    }
 
 //    text_search_predicate:
 //    "CONTAINS('foo')" -> (CONTAINS 'foo')



Mime
View raw message