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 br...@apache.org on 2005/10/27 11:47:34 UTC

svn commit: r328842 - in /incubator/jdo/trunk/tck20: ./ test/conf/ test/java/org/apache/jdo/tck/pc/query/ test/java/org/apache/jdo/tck/query/jdoql/variables/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/query/ test/jdo/datastoreidentity/org/apach...

Author: brazil
Date: Thu Oct 27 02:47:10 2005
New Revision: 328842

URL: http://svn.apache.org/viewcvs?rev=328842&view=rev
Log:
JDO-161: Implement new JDO 2 query tests cases concerning variables.

Added:
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/query/NoExtent.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/variables/MixedVariables.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/variables/UnconstrainedVariable.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/variables/VariablesAndFields.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/variables/VariablesWithoutExtent.java
Modified:
    incubator/jdo/trunk/tck20/project.properties
    incubator/jdo/trunk/tck20/test/conf/alltests.conf
    incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/query/package.jdo
    incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/query/package.jdo
    incubator/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/query/package-derby.orm
    incubator/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/query/package-derby.orm
    incubator/jdo/trunk/tck20/test/sql/derby/applicationidentity/schema.sql
    incubator/jdo/trunk/tck20/test/sql/derby/datastoreidentity/schema.sql

Modified: incubator/jdo/trunk/tck20/project.properties
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/project.properties?rev=328842&r1=328841&r2=328842&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/project.properties (original)
+++ incubator/jdo/trunk/tck20/project.properties Thu Oct 27 02:47:10 2005
@@ -180,6 +180,7 @@
     org/apache/jdo/tck/pc/instancecallbacks/InstanceCallbackClass.java \
     org/apache/jdo/tck/pc/instancecallbacks/InstanceCallbackNonPersistFdsClass.java \
     org/apache/jdo/tck/pc/query/JDOQLKeywordsAsFieldNames.java \
+    org/apache/jdo/tck/pc/query/NoExtent.java \
     org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitivebyte.java \
     org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldByte.java \
     org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitivechar.java \
@@ -278,6 +279,7 @@
     org/apache/jdo/tck/pc/instancecallbacks/InstanceCallbackClass.class \
     org/apache/jdo/tck/pc/instancecallbacks/InstanceCallbackNonPersistFdsClass.class \
     org/apache/jdo/tck/pc/query/JDOQLKeywordsAsFieldNames.class \
+    org/apache/jdo/tck/pc/query/NoExtent.class \
     org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitivebyte.class \
     org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldByte.class \
     org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitivechar.class \

Modified: incubator/jdo/trunk/tck20/test/conf/alltests.conf
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/conf/alltests.conf?rev=328842&r1=328841&r2=328842&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/conf/alltests.conf (original)
+++ incubator/jdo/trunk/tck20/test/conf/alltests.conf Thu Oct 27 02:47:10 2005
@@ -350,6 +350,10 @@
 org.apache.jdo.tck.query.jdoql.parameters.ParameterBoundToDifferentPM \
 org.apache.jdo.tck.query.jdoql.parameters.ParameterDeclaredWithSameNameAsFieldOfCandidateClass \
 org.apache.jdo.tck.query.jdoql.parameters.PrimitiveParameterPassedAsNull \
+org.apache.jdo.tck.query.jdoql.variables.MixedVariables \
+org.apache.jdo.tck.query.jdoql.variables.UnconstrainedVariable \
+org.apache.jdo.tck.query.jdoql.variables.VariablesAndFields \
+org.apache.jdo.tck.query.jdoql.variables.VariablesWithoutExtent \
 org.apache.jdo.tck.query.jdoql.variables.VariableDeclaredWithSameNameAsFieldOfCandidateClass \
 org.apache.jdo.tck.query.result.ImmutableQueryResult \
 org.apache.jdo.tck.transactions.AfterCompletionMethodCalledWhenCommitted \

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/query/NoExtent.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/query/NoExtent.java?rev=328842&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/query/NoExtent.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/query/NoExtent.java Thu Oct 27 02:47:10 2005
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+ 
+package org.apache.jdo.tck.pc.query;
+
+/**
+ * The PC class for testing JDOQL queries.
+ */
+public class NoExtent {
+    
+    /**
+     * The primary key field.
+     */
+    private int id;
+
+    public NoExtent(int id) {
+        this.id = id;
+    }
+    
+    public int getId() {
+        return this.id;
+    }
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/variables/MixedVariables.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/variables/MixedVariables.java?rev=328842&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/variables/MixedVariables.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/variables/MixedVariables.java Thu Oct 27 02:47:10 2005
@@ -0,0 +1,144 @@
+/*
+ * 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.
+ */
+
+package org.apache.jdo.tck.query.jdoql.variables;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.company.CompanyModelReader;
+import org.apache.jdo.tck.pc.company.Employee;
+import org.apache.jdo.tck.query.QueryElementHolder;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Mixed Variables.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.5-3.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * All variables must be explicitly declared, 
+ * or all variables must be implicitly declared.
+ */
+public class MixedVariables extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.5-3 (MixedVariables) failed: ";
+    
+    /** 
+     * The array of invalid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] INVALID_QUERIES = {
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      null, 
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "(team.contains(employee) & employee.firstname == 'emp1First') & " +
+                        "(projects.contains(project) & project.name == 'orange')",
+        /*VARIABLES*/   "Employee employee",
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null)
+    };
+    
+    /** 
+     * The array of valid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] VALID_QUERIES = {
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      null, 
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "(team.contains(employee) & employee.firstname == 'emp1First') & " +
+                        "(projects.contains(project) & project.name == 'orange')",
+        /*VARIABLES*/   "Employee employee; Project project",
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      null, 
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "(team.contains(employee) & employee.firstname == 'emp1First') & " +
+                        "(projects.contains(project) & project.name == 'orange')",
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null)
+    };
+    
+    /** The expected results of valid queries. */
+    private static String[][] expectedResult = {
+        {"emp2"},
+        {"emp2"}
+    };
+            
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(MixedVariables.class);
+    }
+    
+    /** */
+    public void testPositive() {
+        for (int i = 0; i < VALID_QUERIES.length; i++) {
+            Object[] expectedResultValues = 
+                getCompanyModelInstances(expectedResult[i]);
+            executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
+                    expectedResultValues);
+            executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
+                    expectedResultValues);
+        }
+    }
+
+    public void testNegative() {
+        for (int i = 0; i < INVALID_QUERIES.length; i++) {
+            compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false);
+            compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], 
+                    false);
+        }
+    }
+
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        loadCompanyModel(getPM(), COMPANY_TESTDATA);
+        addTearDownClass(CompanyModelReader.getTearDownClasses());
+    }
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/variables/UnconstrainedVariable.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/variables/UnconstrainedVariable.java?rev=328842&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/variables/UnconstrainedVariable.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/variables/UnconstrainedVariable.java Thu Oct 27 02:47:10 2005
@@ -0,0 +1,105 @@
+/*
+ * 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.
+ */
+
+package org.apache.jdo.tck.query.jdoql.variables;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.company.CompanyModelReader;
+import org.apache.jdo.tck.pc.company.Employee;
+import org.apache.jdo.tck.query.QueryElementHolder;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Unconstrained Variables.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.5-1.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * A variable that is not constrained with an explicit contains clause 
+ * is constrained by the extent of the persistence capable class 
+ * (including subclasses).
+ */
+public class UnconstrainedVariable extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.5-1 (UnconstrainedVariable) failed: ";
+    
+    /** 
+     * The array of valid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] VALID_QUERIES = {
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      null, 
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "this.hireDate > e.hireDate & e.personid = id",
+        /*VARIABLES*/   "Employee e",
+        /*PARAMETERS*/  "int id",
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null)
+    };
+    
+    /** The expected results of valid queries. */
+    private static String[][] expectedResult = {
+        {"emp2", "emp3", "emp4"}
+    };
+            
+    /** Parameters of valid queries. */
+    private static Object[][] parameters = {
+        {new Integer(1)},
+    };
+            
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(UnconstrainedVariable.class);
+    }
+    
+    /** */
+    public void testPositive() {
+        if (isUnconstrainedVariablesSupported()) {
+            for (int i = 0; i < VALID_QUERIES.length; i++) {
+                Object[] expectedResultValues = 
+                    getCompanyModelInstances(expectedResult[i]);
+                executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
+                        parameters[i], expectedResultValues);
+                executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
+                        parameters[i], expectedResultValues);
+            }
+        }
+    }
+    
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        loadCompanyModel(getPM(), COMPANY_TESTDATA);
+        addTearDownClass(CompanyModelReader.getTearDownClasses());
+    }
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/variables/VariablesAndFields.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/variables/VariablesAndFields.java?rev=328842&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/variables/VariablesAndFields.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/variables/VariablesAndFields.java Thu Oct 27 02:47:10 2005
@@ -0,0 +1,162 @@
+/*
+ * 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.
+ */
+
+package org.apache.jdo.tck.query.jdoql.variables;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.company.CompanyModelReader;
+import org.apache.jdo.tck.pc.company.Employee;
+import org.apache.jdo.tck.pc.company.Person;
+import org.apache.jdo.tck.query.QueryElementHolder;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Variables and Fields.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.5-4.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * Names are treated as variable names if they are explicitly declared 
+ * via declareVariables. Otherwise, names are treated as field names 
+ * if they are members of the candidate class. 
+ * Finally, names are treated as implicitly defined variable names.
+ */
+public class VariablesAndFields extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.5-4 (VariablesAndFields) failed: ";
+    
+    /** 
+     * The array of valid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] VALID_QUERIES = {
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      null, 
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "team.contains(employee) & employee.firstname == " +
+                        "'emp1First'",
+        /*VARIABLES*/   "Employee employee",
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      null, 
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "team.contains(employee) & employee.firstname == " +
+                        "'emp1First'",
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      null, 
+        /*INTO*/        null, 
+        /*FROM*/        Person.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "firstname == 'emp1First'",
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      null, 
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "team.contains(manager) & manager.firstname = 'emp1First'",
+        /*VARIABLES*/   "Employee manager",
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      null, 
+        /*INTO*/        null, 
+        /*FROM*/        Person.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "team.contains(manager) & manager.firstname = 'emp1First'",
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null)
+    };
+    
+    /** The expected results of valid queries. */
+    private static String[][] expectedResult = {
+        {"emp2"},
+        {"emp2"},
+        {"emp1"},
+        {"emp2"},
+        {}
+    };
+            
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(VariablesAndFields.class);
+    }
+    
+    /** */
+    public void testPositive() {
+        for (int i = 0; i < VALID_QUERIES.length; i++) {
+            Object[] expectedResultValues = 
+                getCompanyModelInstances(expectedResult[i]);
+            executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
+                    expectedResultValues);
+            executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
+                    expectedResultValues);
+        }
+    }
+
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        loadCompanyModel(getPM(), COMPANY_TESTDATA);
+        addTearDownClass(CompanyModelReader.getTearDownClasses());
+    }
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/variables/VariablesWithoutExtent.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/variables/VariablesWithoutExtent.java?rev=328842&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/variables/VariablesWithoutExtent.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/variables/VariablesWithoutExtent.java Thu Oct 27 02:47:10 2005
@@ -0,0 +1,123 @@
+/*
+ * 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.
+ */
+
+package org.apache.jdo.tck.query.jdoql.variables;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.company.CompanyModelReader;
+import org.apache.jdo.tck.pc.company.Person;
+import org.apache.jdo.tck.pc.query.NoExtent;
+import org.apache.jdo.tck.query.QueryElementHolder;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Variables without Extent.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.5-2.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * If the class does not manage an Extent, 
+ * then no results will satisfy the query.
+ */
+public class VariablesWithoutExtent extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.5-2 (VariablesWithoutExtent) failed: ";
+    
+    /** 
+     * The array of valid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] VALID_QUERIES = {
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      null, 
+        /*INTO*/        null, 
+        /*FROM*/        Person.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "this.personid = noExtent.id",
+        /*VARIABLES*/   "NoExtent noExtent",
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     "IMPORT org.apache.jdo.tck.pc.query.NoExtent;",
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null)
+    };
+    
+    /** The expected results of valid queries. */
+    private static String[][] expectedResult = {
+        {}
+    };
+    
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(VariablesWithoutExtent.class);
+    }
+    
+    /** */
+    public void testPositive() {
+        if (isUnconstrainedVariablesSupported()) {
+            for (int i = 0; i < VALID_QUERIES.length; i++) {
+                executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
+                        expectedResult[i]);
+                executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
+                        expectedResult[i]);
+            }
+        }
+    }
+    
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        loadCompanyModel(getPM(), COMPANY_TESTDATA);
+        addTearDownClass(CompanyModelReader.getTearDownClasses());
+        NoExtent noExtent = new NoExtent(1);
+        makePersistent(noExtent);
+        addTearDownInstance(noExtent);
+    }
+    
+    /**
+     * Makes the given instance persistent.
+     * @param o the instance to be made persistent.
+     */
+    private void makePersistent(Object o) {
+        PersistenceManager pm = getPM();
+        Transaction transaction = pm.currentTransaction();
+        transaction.begin();
+        try {
+            pm.makePersistent(o);
+            transaction.commit();
+        } finally {
+            if (transaction.isActive()) {
+                transaction.rollback();
+            }
+        }
+    }
+
+}

Modified: incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/query/package.jdo
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/query/package.jdo?rev=328842&r1=328841&r2=328842&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/query/package.jdo (original)
+++ incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/query/package.jdo Thu Oct 27 02:47:10 2005
@@ -9,6 +9,11 @@
       <field name="select" primary-key="true"/>
     </class>
 
+    <class name="NoExtent" requires-extent="false"
+           identity-type="application" objectid-class="javax.jdo.identity.IntIdentity">
+      <field name="id" primary-key="true"/>
+    </class>
+
   </package>
 </jdo>
 

Modified: incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/query/package.jdo
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/query/package.jdo?rev=328842&r1=328841&r2=328842&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/query/package.jdo (original)
+++ incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/query/package.jdo Thu Oct 27 02:47:10 2005
@@ -4,6 +4,7 @@
 <jdo>
   <package name="org.apache.jdo.tck.pc.query">
     <class name="JDOQLKeywordsAsFieldNames" identity-type="datastore"/>
+    <class name="NoExtent" requires-extent="false" identity-type="datastore"/>
   </package>
 </jdo>
 

Modified: incubator/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/query/package-derby.orm
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/query/package-derby.orm?rev=328842&r1=328841&r2=328842&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/query/package-derby.orm (original)
+++ incubator/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/query/package-derby.orm Thu Oct 27 02:47:10 2005
@@ -7,6 +7,10 @@
       <field name="select" column="ID" primary-key="true"/>
     </class>
 
+    <class name="NoExtent" table="NoExtent">
+      <field name="id" column="ID" primary-key="true"/>
+    </class>
+
   </package>
 </orm>
 

Modified: incubator/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/query/package-derby.orm
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/query/package-derby.orm?rev=328842&r1=328841&r2=328842&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/query/package-derby.orm (original)
+++ incubator/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/query/package-derby.orm Thu Oct 27 02:47:10 2005
@@ -12,5 +12,10 @@
             <field name="select" column="ID"/>
         </class>
 
+        <class name="NoExtent" table="NoExtent">
+            <datastore-identity strategy="identity" column="DATASTORE_IDENTITY"/>
+            <field name="id" column="ID"/>
+        </class>
+
     </package>
 </orm>

Modified: incubator/jdo/trunk/tck20/test/sql/derby/applicationidentity/schema.sql
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/sql/derby/applicationidentity/schema.sql?rev=328842&r1=328841&r2=328842&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/sql/derby/applicationidentity/schema.sql (original)
+++ incubator/jdo/trunk/tck20/test/sql/derby/applicationidentity/schema.sql Thu Oct 27 02:47:10 2005
@@ -66,10 +66,16 @@
 -------------------------
 
 DROP TABLE JDOQLKeywordsAsFieldNames;
+DROP TABLE NoExtent;
 
 CREATE TABLE JDOQLKeywordsAsFieldNames (
     ID VARCHAR(64) NOT NULL,
     CONSTRAINT KEYWORDS_PK PRIMARY KEY (ID)
+);
+
+CREATE TABLE NoExtent (
+    ID INTEGER NOT NULL,
+    CONSTRAINT NOEXTENT_PK PRIMARY KEY (ID)
 );
 
 -------------------------

Modified: incubator/jdo/trunk/tck20/test/sql/derby/datastoreidentity/schema.sql
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/sql/derby/datastoreidentity/schema.sql?rev=328842&r1=328841&r2=328842&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/sql/derby/datastoreidentity/schema.sql (original)
+++ incubator/jdo/trunk/tck20/test/sql/derby/datastoreidentity/schema.sql Thu Oct 27 02:47:10 2005
@@ -70,11 +70,18 @@
 -------------------------
 
 DROP TABLE JDOQLKeywordsAsFieldNames;
+DROP TABLE NoExtent;
 
 CREATE TABLE JDOQLKeywordsAsFieldNames (
     DATASTORE_IDENTITY INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY,
     ID VARCHAR(64) NOT NULL,
     CONSTRAINT KEYWORDS_PK PRIMARY KEY (DATASTORE_IDENTITY)
+);
+
+CREATE TABLE NoExtent (
+    DATASTORE_IDENTITY INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY,
+    ID INTEGER NOT NULL,
+    CONSTRAINT NOEXTENT_PK PRIMARY KEY (DATASTORE_IDENTITY)
 );
 
 -------------------------