You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-commits@db.apache.org by mb...@apache.org on 2005/05/22 20:40:21 UTC
svn commit: r171355 [28/31] - in /incubator/jdo/trunk/fostore20: ./ src/
src/conf/ src/java/ src/java/org/ src/java/org/apache/
src/java/org/apache/jdo/ src/java/org/apache/jdo/impl/
src/java/org/apache/jdo/impl/fostore/ test/ test/conf/ test/fsuid2/
test/fsuid2/org/ test/fsuid2/org/apache/ test/fsuid2/org/apache/jdo/
test/fsuid2/org/apache/jdo/pc/ test/java/ test/java/org/
test/java/org/apache/ test/java/org/apache/jdo/
test/java/org/apache/jdo/impl/ test/java/org/apache/jdo/impl/fostore/
test/java/org/apache/jdo/pc/ test/java/org/apache/jdo/pc/appid/
test/java/org/apache/jdo/pc/empdept/
test/java/org/apache/jdo/pc/serializable/
test/java/org/apache/jdo/pc/xempdept/ test/java/org/apache/jdo/test/
test/java/org/apache/jdo/test/query/ test/java/org/apache/jdo/test/util/
test/jdo/ test/jdo/org/ test/jdo/org/apache/ test/jdo/org/apache/jdo/
test/jdo/org/apache/jdo/pc/ test/jdo/org/apache/jdo/pc/appid/
test/jdo/org/apache/jdo/pc/empdept/ test/jdo/org/apache/jdo/pc/serializable/
test/jdo/org/apache/jdo/pc/xempdept/
Added: incubator/jdo/trunk/fostore20/test/java/org/apache/jdo/test/query/SemanticErrorTest.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/fostore20/test/java/org/apache/jdo/test/query/SemanticErrorTest.java?rev=171355&view=auto
==============================================================================
--- incubator/jdo/trunk/fostore20/test/java/org/apache/jdo/test/query/SemanticErrorTest.java (added)
+++ incubator/jdo/trunk/fostore20/test/java/org/apache/jdo/test/query/SemanticErrorTest.java Sun May 22 11:40:13 2005
@@ -0,0 +1,1363 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * SemanticErrorTest.java
+ *
+ * Created on April 6, 2000
+ */
+
+package org.apache.jdo.test.query;
+
+import java.util.Collection;
+import java.util.ArrayList;
+import java.util.Map;
+import java.io.PrintStream;
+
+import javax.jdo.*;
+
+import org.apache.jdo.jdoql.JDOQueryException;
+import org.apache.jdo.pc.xempdept.Department;
+import org.apache.jdo.pc.xempdept.Employee;
+
+/**
+ *
+ * @author Michael Bouschen
+ */
+public class SemanticErrorTest
+ extends NegativeTest
+{
+ public SemanticErrorTest(PersistenceManagerFactory pmf, PrintStream log)
+ {
+ super(pmf, log);
+ }
+
+ protected boolean isTestMethodName(String methodName)
+ {
+ return methodName.startsWith("semanticError");
+ }
+
+ // ==========================================================================
+ // Test methods
+ // ==========================================================================
+
+ /**
+ * Testcase: semantic error undefined field
+ */
+ public void semanticError001()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(6): Field 'michael' not defined for class 'org.apache.jdo.pc.xempdept.Employee'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("this.michael == 0");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+ /**
+ * Testcase: semantic error left hand side of dot does not define object
+ */
+ public void semanticError002()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(1): Expression of class type expected.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("empid.unknownField == 0");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: semantic error undefined expression
+ */
+ public void semanticError003()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(8): Undefined expression 'michael.field'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("michael.field == 0");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: invalid argument for logical operation &
+ */
+ public void semanticError004()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(11): Invalid argument(s) for '&'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("\"michael\" & true");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: invalid argument for logical operation |
+ */
+ public void semanticError005()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(11): Invalid argument(s) for '|'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("\"michael\" | true");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: invalid argument for conditional operation &&
+ */
+ public void semanticError006()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(11): Invalid argument(s) for '&&'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("\"michael\" && false");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+ /**
+ * Testcase: invalid argument for conditional operation ||
+ */
+ public void semanticError007()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(11): Invalid argument(s) for '||'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("\"michael\" || false");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: invalid argument for arithmetic operation +
+ */
+ public void semanticError008()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(11): Invalid argument(s) for '+'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("\"michael\" + 3");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: invalid argument for arithmetic operation -
+ */
+ public void semanticError009()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(7): Invalid argument(s) for '-'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("false - 6");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: invalid argument for arithmetic operation *
+ */
+ public void semanticError010()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(6): Invalid argument(s) for '*'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("true * 5");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: invalid argument for arithmetic operation /
+ */
+ public void semanticError011()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(5): Invalid argument(s) for '/'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("4.8 / \"michael\"");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: invalid argument for relational operation ==
+ */
+ public void semanticError012()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(7): Invalid argument(s) for '=='.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("false == 1");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: invalid argument for relational operation !=
+ */
+ public void semanticError013()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(5): Invalid argument(s) for '!='.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("1.0 != \"michael\"");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: invalid argument for relational operation <
+ */
+ public void semanticError014()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(11): Invalid argument(s) for '<'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("\"michael\" < 1");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: invalid argument for relational operation <=
+ */
+ public void semanticError015()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(3): Invalid argument(s) for '<='.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("1 <= \"michael\"");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: invalid argument for relational operation >
+ */
+ public void semanticError016()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(11): Invalid argument(s) for '>'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("\"michael\" > 1");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: invalid argument for relational operation >=
+ */
+ public void semanticError017()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(5): Invalid argument(s) for '>='.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("2.0 >= \"michael\"");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: invalid argument for unary !
+ */
+ public void semanticError018()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(1): Invalid argument(s) for '!'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("! 1");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: invalid argument for unary +
+ */
+ public void semanticError019()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(1): Invalid argument(s) for '+'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("+ false");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: invalid argument for unary -
+ */
+ public void semanticError020()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(1): Invalid argument(s) for '-'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("- \"michael\"");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: invalid argument for unary ~
+ */
+ public void semanticError021()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(1): Invalid argument(s) for '~'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("~ true");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: invalid argument for < (type does not define order)
+ */
+ public void semanticError022()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(6): Operand type 'boolean' of < is not sortable.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("true < false");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: multiple declaration of identifier
+ */
+ /*
+ public void semanticError023()
+ throws Exception
+ {
+ String expectedMsg = "declareImports column(1): 'Employee' already declared as type name.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareImports("import org.apache.jdo.pc.xempdept.Employee;");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+ */
+ /**
+ * Testcase: multiple declaration of identifier
+ */
+ public void semanticError024()
+ throws Exception
+ {
+ String expectedMsg = "declareParameters column(12): Multiple declaration of 'i'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareParameters("int i, int i");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: multiple declaration of identifier
+ */
+ public void semanticError025()
+ throws Exception
+ {
+ String expectedMsg = "declareVariables column(5): Multiple declaration of 'i'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareParameters("int i");
+ query.declareVariables("int i");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: unknown type in parameter declaration
+ */
+ public void semanticError026()
+ throws Exception
+ {
+ String expectedMsg = "declareParameters column(1): Unknown type 'Michael'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareParameters("Michael m");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: unknown type in variable declaration
+ */
+ public void semanticError027()
+ throws Exception
+ {
+ String expectedMsg = "declareVariables column(1): Unknown type 'Michael'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareVariables("Michael m");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: unknown type in import declaration
+ */
+ public void semanticError028()
+ throws Exception
+ {
+ String expectedMsg = "declareImports column(1): Unknown type 'Michael'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareImports("import Michael");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: identifier used in parameter declaration does not define type
+ */
+ public void semanticError029()
+ throws Exception
+ {
+ String expectedMsg = "declareParameters column(12): Unknown type 'index'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareParameters("int index, index i");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: too many actual parameters
+ */
+ public void semanticError030()
+ throws Exception
+ {
+ String expectedMsg = "Wrong number of query parameter values.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("empid == 1");
+ query.compile();
+ query.setCandidates(pm.getExtent(Employee.class, false));
+ query.execute("InvalidParameterValue");
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: Unbound query parameter
+ */
+ public void semanticError031()
+ throws Exception
+ {
+ String expectedMsg = "Unbound query parameter 'l'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareParameters("long l");
+ query.setFilter("empid == l");
+ query.compile();
+ query.setCandidates(pm.getExtent(Employee.class, false));
+ query.execute();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: type of actual parameter is not compatible with type of formal parameter
+ */
+ public void semanticError032()
+ throws Exception
+ {
+ String expectedMsg = "Incompatible type of actual query parameter. Cannot convert 'java.lang.String' to 'long'";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareParameters("long l");
+ query.setFilter("empid == l");
+ query.compile();
+ query.setCandidates(pm.getExtent(Employee.class, false));
+ query.execute("InvalidParameterValue");
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: map binds undefined parameter
+ */
+ public void semanticError033()
+ throws Exception
+ {
+ String expectedMsg = "Undefined query parameter 'param'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareParameters("long l");
+ query.setFilter("empid == l");
+ query.compile();
+ query.setCandidates(pm.getExtent(Employee.class, false));
+ Map actualParams = new java.util.HashMap();
+ actualParams.put("param", "InvalidParameterValue");
+ query.executeWithMap(actualParams);
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: invalid field in ordering specification
+ */
+ public void semanticError034()
+ throws Exception
+ {
+ String expectedMsg = "setOrdering column(1): Undefined identifier 'michael'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("empid > 2");
+ query.setOrdering("michael ascending");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: invalid field type in ordering specification
+ */
+ public void semanticError035()
+ throws Exception
+ {
+ String expectedMsg = "setOrdering column(1): Type 'org.apache.jdo.pc.xempdept.Department' of ordering expression is not sortable.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("empid > 2");
+ query.setOrdering("department ascending");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: invalid field type in ordering specification
+ */
+ public void semanticError036()
+ throws Exception
+ {
+ String expectedMsg = "setOrdering column(1): Type 'java.util.HashSet' of ordering expression is not sortable.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Department.class);
+ query.setFilter("deptid > 2");
+ query.setOrdering("employees descending");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: invalid method call
+ */
+ public void semanticError037()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(5): Invalid method call.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("this.getEmplId() == 2");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: filter expression is not of type boolean
+ */
+ public void semanticError038()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(1): Boolean expression expected, filter expression has type 'int'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("2");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: static reference to non static field
+ */
+ public void semanticError039()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(10): Cannot make a static reference to non-static variable 'empid' of class 'org.apache.jdo.pc.xempdept.Employee'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("Employee.empid == 2");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: access of non public field of non persistence capable class
+ */
+ /*
+ public void semanticError040()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(3): Cannot access non-public field 'elementCount' of non-persistence-capable class 'java.util.Vector'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareImports("import java.util.Vector");
+ query.declareVariables("Vector v");
+ query.setFilter("v.elementCount == 1");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+ */
+ /**
+ * Testcase: access of non public static field
+ */
+ /*
+ public void semanticError041()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(23): Cannot access non-public static field 'cache' of class 'java.text.Collator'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareImports("import java.text.Collator");
+ query.setFilter("firstname == Collator.cache");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+ */
+ /**
+ * Testcase: collection element type does not match variable type
+ * checks bug report 4367808
+ */
+ public void semanticError042()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(1): Collection element type 'org.apache.jdo.pc.xempdept.Employee' and argument type 'org.apache.jdo.pc.xempdept.Project' not compatible.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareImports("import org.apache.jdo.pc.xempdept.Project");
+ query.declareVariables("Project p");
+ query.setFilter("team.contains(p) && p.projid == 1");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: unsupported operation in ordering expression
+ */
+ /*
+ public void semanticError043()
+ throws Exception
+ {
+ String expectedMsg = "setOrdering column(7): Unsupported expression '+' in ordering specification.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("empid > 2");
+ query.setOrdering("empid + 1 ascending");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+ */
+ /**
+ * Testcase: isEmpty with arguments
+ */
+ public void semanticError044()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(14): Wrong number of arguments.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("team.isEmpty(1)");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: contains with too manay arguments
+ */
+ public void semanticError045()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(18): Wrong number of arguments.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareVariables("Employee e");
+ query.setFilter("team.contains(e, 1)");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: contains without arguments
+ */
+ public void semanticError046()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(6): Wrong number of arguments.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("team.contains()");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: invalid string method call
+ * checks bug report 4469306
+ */
+ public void semanticError047()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(9): Invalid method call.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("lastname.endWith(\"en\")");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: invalid string method call results in wrong error message
+ * checks bug report 4472057
+ */
+ public void semanticError048()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(9): Invalid method call.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("lastname.charAt(10)");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: invalid int literal
+ * checks bug report 4818832
+ */
+ public void semanticError049()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(10): Invalid int literal '12345678900'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("empid == 12345678900");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: invalid long literal
+ * checks bug report 4818832
+ */
+ public void semanticError050()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(11): Invalid long literal '-9223372036854775809L'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("empid == -9223372036854775809L");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: access of non persistent field of persistence capable class
+ */
+ /* TBD: need persistence capable class providing non persistent fields
+ public void semanticError0xx()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(10): cannot access non persistent field 'fieldName' of persistence capable class 'class'";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+ */
+}
Added: incubator/jdo/trunk/fostore20/test/java/org/apache/jdo/test/query/SyntaxErrorTest.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/fostore20/test/java/org/apache/jdo/test/query/SyntaxErrorTest.java?rev=171355&view=auto
==============================================================================
--- incubator/jdo/trunk/fostore20/test/java/org/apache/jdo/test/query/SyntaxErrorTest.java (added)
+++ incubator/jdo/trunk/fostore20/test/java/org/apache/jdo/test/query/SyntaxErrorTest.java Sun May 22 11:40:13 2005
@@ -0,0 +1,1336 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * SyntaxErrorTest.java
+ *
+ * Created on March 31, 2000
+ */
+
+package org.apache.jdo.test.query;
+
+import java.util.Collection;
+import java.util.ArrayList;
+import java.io.PrintStream;
+
+import javax.jdo.*;
+
+import org.apache.jdo.jdoql.JDOQueryException;
+import org.apache.jdo.pc.xempdept.Employee;
+
+/**
+ *
+ * @author Michael Bouschen
+ */
+public class SyntaxErrorTest
+ extends NegativeTest
+{
+ public SyntaxErrorTest(PersistenceManagerFactory pmf, PrintStream log)
+ {
+ super(pmf, log);
+ }
+
+ protected boolean isTestMethodName(String methodName)
+ {
+ return methodName.startsWith("syntaxError");
+ }
+
+ // ==========================================================================
+ // Test methods
+ // ==========================================================================
+
+ /**
+ * Testcase: lexical error unknown character %
+ */
+ public void syntaxError001()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(1): Syntax error unexpected char '%'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("%");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: lexical error empty char literal
+ */
+ public void syntaxError002()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(2): Syntax error unexpected char '''";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("'' == 'c'");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: lexical error missing closing parenthesis
+ */
+ public void syntaxError003()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(12): Unexpected end of text.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("(1 + 2 == 3");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: lexical error missing closing double quote
+ */
+ public void syntaxError004()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(22): Unexpected end of text.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("firstname == \"Michael");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: lexical error missing closing single quote
+ */
+ public void syntaxError005()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(10): Syntax error expected char ''', found ' '.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("'a' == 'b ");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: lexical error invalid interger literal 12a2
+ */
+ public void syntaxError006()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(3): Syntax error unexpected token 'a2'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("12a2");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: lexical error invalid octal literal 09
+ */
+ public void syntaxError007()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(2): Syntax error unexpected token '9'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("09");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: lexical error invalid hex literal 0x9g
+ */
+ public void syntaxError008()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(4): Syntax error unexpected token 'g'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("0x9g");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: lexical error invalid float literal 1.23.45
+ */
+ public void syntaxError009()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(5): Syntax error unexpected token '.45'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("1.23.45");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: lexical error invalid float literal suffix 1.23g
+ */
+ public void syntaxError010()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(5): Syntax error unexpected token 'g'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("1.23g");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: lexical error unknown keyword/identifier
+ */
+ public void syntaxError011()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(1): Undefined identifier 'select'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("select");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: lexical error keyword in mixed case
+ */
+ public void syntaxError012()
+ throws Exception
+ {
+ String expectedMsg = "declareImports column(1): Syntax error unexpected token 'iMpOrT'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareImports("iMpOrT org.apache.jdo.pc.xempdept.Department;");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error missing semicolon in import declaration
+ */
+ public void syntaxError013()
+ throws Exception
+ {
+ String expectedMsg = "declareImports column(44): Syntax error unexpected token 'import'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareImports("import org.apache.jdo.pc.xempdept.Employee import org.apache.jdo.pc.xempdept.Department");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error missing type specification in import declaration
+ */
+ public void syntaxError014()
+ throws Exception
+ {
+ String expectedMsg = "declareImports column(7): Syntax error at ';'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareImports("import;");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error missing comma in parameter declaration
+ */
+ public void syntaxError015()
+ throws Exception
+ {
+ String expectedMsg = "declareParameters column(8): Syntax error unexpected token 'int'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareParameters("long l int i");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error missing type specification in parameter declaration
+ */
+ public void syntaxError016()
+ throws Exception
+ {
+ String expectedMsg = "declareParameters column(2): Unexpected end of text.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareParameters("l");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error missing name specification in parameter declaration
+ */
+ public void syntaxError017()
+ throws Exception
+ {
+ String expectedMsg = "declareParameters column(4): Unexpected end of text.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareParameters("int");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error missing semicolon in variable declaration
+ */
+ public void syntaxError018()
+ throws Exception
+ {
+ String expectedMsg = "declareVariables column(13): Syntax error unexpected token 'Employee'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareImports("import org.apache.jdo.pc.xempdept.Employee");
+ query.declareVariables("Employee e1 Employee e2");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error missing type specification in variable declaration
+ */
+ public void syntaxError019()
+ throws Exception
+ {
+ String expectedMsg = "declareVariables column(2): Unexpected end of text.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareImports("import org.apache.jdo.pc.xempdept.Employee");
+ query.declareVariables("v");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error missing name specification in variable declaration
+ */
+ public void syntaxError020()
+ throws Exception
+ {
+ String expectedMsg = "declareVariables column(9): Unexpected end of text.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareImports("import org.apache.jdo.pc.xempdept.Employee");
+ query.declareVariables("Employee");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error missing comma in ordering specification
+ */
+ public void syntaxError021()
+ throws Exception
+ {
+ String expectedMsg = "setOrdering column(18): Syntax error unexpected token 'firstname'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setOrdering("deptid ascending firstname descending");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error missing field specification in ordering specification
+ */
+ public void syntaxError022()
+ throws Exception
+ {
+ String expectedMsg = "setOrdering column(1): Syntax error unexpected token 'ascending'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setOrdering("ascending");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error missing argument of unary operator
+ */
+ public void syntaxError023()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(2): Unexpected end of text.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("!");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+ /**
+ * Testcase: syntax error missing argument of logical operator
+ */
+ public void syntaxError024()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(7): Unexpected end of text.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("true &");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error missing argument of conditional operator
+ */
+ public void syntaxError025()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(8): Unexpected end of text.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("true ||");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error missing argument of relational operator
+ */
+ public void syntaxError026()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(5): Unexpected end of text.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("1 ==");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error missing argument of arithmetic operator
+ */
+ public void syntaxError027()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(5): Syntax error unexpected token '=='.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("1 + == 3");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error missing field in navigation path
+ */
+ public void syntaxError028()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(7): Syntax error at '=='.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("dept. == 1");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error multiple import keyword in import declaration
+ */
+ public void syntaxError029()
+ throws Exception
+ {
+ String expectedMsg = "declareImports column(8): Syntax error at 'import'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareImports("import import org.apache.jdo.pc.xempdept.Employee");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error multiple type specification in import declaration
+ */
+ public void syntaxError030()
+ throws Exception
+ {
+ String expectedMsg = "declareImports column(44): Syntax error unexpected token 'org'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareImports("import org.apache.jdo.pc.xempdept.Employee org.apache.jdo.pc.xempdept.Employee");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error multiple comma in parameter declaration
+ */
+ public void syntaxError031()
+ throws Exception
+ {
+ String expectedMsg = "declareParameters column(8): Syntax error at ','.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareParameters("int i, , long l");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+
+ /**
+ * Testcase: syntax error multiple type specification in parameter declaration
+ */
+ public void syntaxError032()
+ throws Exception
+ {
+ String expectedMsg = "declareParameters column(5): Syntax error at 'long'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareParameters("int long l");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+
+ /**
+ * Testcase: syntax error multiple name specification in parameter declaration
+ */
+ public void syntaxError033()
+ throws Exception
+ {
+ String expectedMsg = "declareParameters column(7): Syntax error unexpected token 'l'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareParameters("int i l");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+
+ /**
+ * Testcase: syntax error multiple semicolon in variable declaration
+ */
+ public void syntaxError034()
+ throws Exception
+ {
+ String expectedMsg = "declareVariables column(16): Syntax error at ';'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareImports("import org.apache.jdo.pc.xempdept.Department");
+ query.declareVariables("Department d1; ;Department d2");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error multiple type specification in variable declaration
+ */
+ public void syntaxError035()
+ throws Exception
+ {
+ String expectedMsg = "declareVariables column(23): Syntax error unexpected token 'd'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareVariables("Department Department d");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error multiple name specification in variable declaration
+ */
+ public void syntaxError036()
+ throws Exception
+ {
+ String expectedMsg = "declareVariables column(15): Syntax error unexpected token 'd2'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.declareVariables("Department d1 d2");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error multiple comma in ordering specification
+ */
+ public void syntaxError037()
+ throws Exception
+ {
+ String expectedMsg = "setOrdering column(6): Syntax error unexpected token ','.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setOrdering("empid, , firstname");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error multiple field specification in ordering specification
+ */
+ public void syntaxError038()
+ throws Exception
+ {
+ String expectedMsg = "setOrdering column(7): Syntax error unexpected token 'firstname'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setOrdering("empid firstname ascending");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error multiple direction in ordering specification
+ */
+ public void syntaxError039()
+ throws Exception
+ {
+ String expectedMsg = "setOrdering column(18): Syntax error unexpected token 'ascending'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setOrdering("empid descending ascending");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error multiple arguments of unary operation
+ */
+ public void syntaxError040()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(8): Syntax error unexpected token 'false'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("! true false");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error multiple arguments of logical operator
+ */
+ public void syntaxError041()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(19): Syntax error unexpected token 'false'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("empid == 1 | true false");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error multiple arguments of conditinal operator
+ */
+ public void syntaxError042()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(20): Syntax error unexpected token 'false'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("empid == 1 && true false");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error multiple arguments of relational operator
+ */
+ public void syntaxError043()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(13): Syntax error unexpected token '2'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("empid >= 1 2");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error multiple arguments of arithmetic operator
+ */
+ public void syntaxError044()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(17): Syntax error unexpected token '4'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("empid == (1 + 3 4)");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error unexpected parenthesis
+ */
+ public void syntaxError045()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(7): Syntax error unexpected token '('.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("empid ( empid");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error unexpected identifier
+ */
+ public void syntaxError046()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(7): Syntax error unexpected token 'empid'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("empid empid");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error invalid pre-increment operator
+ */
+ public void syntaxError047()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(1): Syntax error unexpected token '++'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("++empid == 1");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error invalid pre-decrement operator
+ */
+ public void syntaxError048()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(1): Syntax error unexpected token '--'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("--empid == 1");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error invalid assignemnt operator
+ */
+ public void syntaxError049()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(7): Syntax error unexpected token '='.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("empid = 1");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error invalid compound assignment operator
+ */
+ public void syntaxError050()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(7): Syntax error unexpected token '+='.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("empid += 1");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+ /**
+ * Testcase: syntax error invalid shift operator
+ */
+ public void syntaxError051()
+ throws Exception
+ {
+ String expectedMsg = "setFilter column(7): Syntax error unexpected token '<<'.";
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try
+ {
+ Query query = pm.newQuery(Employee.class);
+ query.setFilter("empid << 1");
+ query.compile();
+ checkMissingException(JDOQueryException.class, expectedMsg);
+ }
+ catch (JDOException ex)
+ {
+ checkJDOException(ex, JDOQueryException.class, expectedMsg);
+ }
+
+ tx.rollback();
+ }
+
+}