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/03/19 02:09:52 UTC
svn commit: r158179 [40/61] - in incubator/jdo/trunk/tck11: ./ assertions/
iut_jars/ test/ test/conf/ test/java/ test/java/org/ test/java/org/apache/
test/java/org/apache/jdo/ test/java/org/apache/jdo/tck/
test/java/org/apache/jdo/tck/api/
test/java/org/apache/jdo/tck/api/instancecallbacks/
test/java/org/apache/jdo/tck/api/jdohelper/
test/java/org/apache/jdo/tck/api/persistencemanager/
test/java/org/apache/jdo/tck/api/persistencemanagerfactory/
test/java/org/apache/jdo/tck/enhancement/
test/java/org/apache/jdo/tck/extents/ test/java/org/apache/jdo/tck/lifecycle/
test/java/org/apache/jdo/tck/lifecycle/nontransactional/
test/java/org/apache/jdo/tck/models/
test/java/org/apache/jdo/tck/models/embedded/
test/java/org/apache/jdo/tck/models/fieldtypes/
test/java/org/apache/jdo/tck/models/inheritance/
test/java/org/apache/jdo/tck/pc/ test/java/org/apache/jdo/tck/pc/company/
test/java/org/apache/jdo/tck/pc/fieldtypes/
test/java/org/apache/jdo/tck/pc/inheritance/
test/java/org/apache/jdo/tck/pc/instancecallbacks/
test/java/org/apache/jdo/tck/pc/lifecycle/
test/java/org/apache/jdo/tck/pc/mylib/ test/java/org/apache/jdo/tck/query/
test/java/org/apache/jdo/tck/query/operators/
test/java/org/apache/jdo/tck/transactions/
test/java/org/apache/jdo/tck/util/ test/jdo/ test/jdo/applicationidentity/
test/jdo/applicationidentity/org/ test/jdo/applicationidentity/org/apache/
test/jdo/applicationidentity/org/apache/jdo/
test/jdo/applicationidentity/org/apache/jdo/tck/
test/jdo/applicationidentity/org/apache/jdo/tck/pc/
test/jdo/applicationidentity/org/apache/jdo/tck/pc/company/
test/jdo/applicationidentity/org/apache/jdo/tck/pc/fieldtypes/
test/jdo/applicationidentity/org/apache/jdo/tck/pc/inheritance/
test/jdo/applicationidentity/org/apache/jdo/tck/pc/instancecallbacks/
test/jdo/applicationidentity/org/apache/jdo/tck/pc/lifecycle/
test/jdo/applicationidentity/org/apache/jdo/tck/pc/mylib/
test/jdo/datastoreidentity/ test/jdo/datastoreidentity/org/
test/jdo/datastoreidentity/org/apache/
test/jdo/datastoreidentity/org/apache/jdo/
test/jdo/datastoreidentity/org/apache/jdo/tck/
test/jdo/datastoreidentity/org/apache/jdo/tck/pc/
test/jdo/datastoreidentity/org/apache/jdo/tck/pc/company/
test/jdo/datastoreidentity/org/apache/jdo/tck/pc/fieldtypes/
test/jdo/datastoreidentity/org/apache/jdo/tck/pc/inheritance/
test/jdo/datastoreidentity/org/apache/jdo/tck/pc/instancecallbacks/
test/jdo/datastoreidentity/org/apache/jdo/tck/pc/lifecycle/
test/jdo/datastoreidentity/org/apache/jdo/tck/pc/mylib/
Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/BooleanLogicalAND.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/BooleanLogicalAND.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/BooleanLogicalAND.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/BooleanLogicalAND.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,174 @@
+/*
+ * 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.operators;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import javax.jdo.JDOUserException;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.pc.mylib.PrimitiveTypes;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Boolean Logical AND Query Operator
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.2-20.
+ *<BR>
+ *<B>Assertion Description: </B>
+The Boolean logical AND (not bitwise) operator (<code>&</code>) is supported
+for all types as they are defined in the Java language.
+This includes the following types:
+<UL>
+<LI><code>Boolean, boolean</code></LI>
+</UL>
+ */
+
+public class BooleanLogicalAND extends QueryTest {
+
+ /** */
+ private static final String ASSERTION_FAILED =
+ "Assertion A14.6.2-20 (BooleanLogicalAND) failed: ";
+
+ /**
+ * 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(BooleanLogicalAND.class);
+ }
+
+ /** */
+ public void test() {
+ pm = getPM();
+
+ try {
+ loadPrimitiveTypes(pm);
+ runPositiveTest(pm);
+ }
+ finally {
+ cleanupDatabase(pm, PrimitiveTypes.class);
+ pm.close();
+ pm = null;
+ }
+ }
+
+ /** */
+ public void testBitwiseAND() {
+ pm = getPM();
+
+ runNegativeTest(pm);
+
+ pm.close();
+ pm = null;
+ }
+
+ /** */
+ void runPositiveTest(PersistenceManager pm) {
+ if (debug) logger.debug("\nExecuting positive test BooleanLogicalAND() ...");
+
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ Collection instance9 = (Collection)pm.newQuery(
+ PrimitiveTypes.class, "id == 9").execute();
+ Collection allOddInstances = (Collection)pm.newQuery(
+ PrimitiveTypes.class, "booleanNull").execute();
+ Collection allInstances = (Collection)pm.newQuery(
+ PrimitiveTypes.class, "true").execute();
+ Collection empty = new HashSet();
+
+ // case true & true
+ runSimplePrimitiveTypesQuery("true & true",
+ pm, allInstances, ASSERTION_FAILED);
+
+ // case true & false
+ runSimplePrimitiveTypesQuery("true & false",
+ pm, empty, ASSERTION_FAILED);
+
+ // case false & true
+ runSimplePrimitiveTypesQuery("false & true",
+ pm, empty, ASSERTION_FAILED);
+
+ // case false & false
+ runSimplePrimitiveTypesQuery("false & false",
+ pm, empty, ASSERTION_FAILED);
+
+ // case boolean & boolean
+ runSimplePrimitiveTypesQuery("intNotNull == 9 & booleanNotNull",
+ pm, instance9, ASSERTION_FAILED);
+
+ // case boolean & Boolean
+ runSimplePrimitiveTypesQuery("intNotNull == 9 & booleanNull",
+ pm, instance9, ASSERTION_FAILED);
+ // case Boolean & boolean
+ runSimplePrimitiveTypesQuery("booleanNull & intNotNull == 9",
+ pm, instance9, ASSERTION_FAILED);
+ // case Boolean & Boolean
+ runSimplePrimitiveTypesQuery("booleanNull & booleanNull",
+ pm, allOddInstances, ASSERTION_FAILED);
+
+ // case Boolean parameter
+ runParameterPrimitiveTypesQuery("param & id == 9",
+ "Boolean param", Boolean.TRUE,
+ pm, instance9, ASSERTION_FAILED);
+ runParameterPrimitiveTypesQuery("param & id == 9",
+ "Boolean param", Boolean.FALSE,
+ pm, empty, ASSERTION_FAILED);
+
+ // case boolean parameter
+ runParameterPrimitiveTypesQuery("param & id == 9",
+ "boolean param", Boolean.TRUE,
+ pm, instance9, ASSERTION_FAILED);
+ runParameterPrimitiveTypesQuery("param & id == 9",
+ "boolean param", Boolean.FALSE,
+ pm, empty, ASSERTION_FAILED);
+
+ tx.commit();
+ }
+
+ /** */
+ void runNegativeTest(PersistenceManager pm) {
+ if (debug) logger.debug("\nExecuting positive test BooleanLogicalAND() ...");
+
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try {
+ Query q = pm.newQuery(PrimitiveTypes.class,
+ "intNotNull & intNotNull");
+ Object result = q.execute();
+ fail(ASSERTION_FAILED,
+ "Query uisng bitwise & operator should throw JDOUserException.");
+ }
+ catch (JDOUserException ex) {
+ // expected exception
+ if (debug) {
+ logger.debug("expected exception: " + ex);
+ }
+ }
+ tx.commit();
+ }
+
+}
Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/BooleanLogicalOR.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/BooleanLogicalOR.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/BooleanLogicalOR.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/BooleanLogicalOR.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,178 @@
+/*
+ * 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.operators;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import javax.jdo.JDOUserException;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.pc.mylib.PrimitiveTypes;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Boolean Logical OR Query Operator
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.2-22.
+ *<BR>
+ *<B>Assertion Description: </B>
+The Boolean logical OR (not bitwise) operator (<code>|</code>) is supported for
+all types as they are defined in the Java language.
+This includes the following types:
+<UL>
+<LI><code>Boolean, boolean</code></LI>
+</UL>
+ */
+
+public class BooleanLogicalOR extends QueryTest {
+
+ /** */
+ private static final String ASSERTION_FAILED =
+ "Assertion A14.6.2-22 (BooleanLogicalOR) failed: ";
+
+ /**
+ * 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(BooleanLogicalOR.class);
+ }
+
+ /** */
+ public void test() {
+ pm = getPM();
+
+ try {
+ loadPrimitiveTypes(pm);
+ runPositiveTest(pm);
+ }
+ finally {
+ cleanupDatabase(pm, PrimitiveTypes.class);
+ pm.close();
+ pm = null;
+ }
+ }
+
+ /** */
+ public void testBitwiseAND() {
+ pm = getPM();
+
+ runNegativeTest(pm);
+
+ pm.close();
+ pm = null;
+ }
+
+ /** */
+ void runPositiveTest(PersistenceManager pm) {
+ if (debug) logger.debug("\nExecuting positive test BooleanLogicalOR() ...");
+
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ Collection instance9 = (Collection)pm.newQuery(
+ PrimitiveTypes.class, "id == 9").execute();
+ Collection instancesLess3 = (Collection)pm.newQuery(
+ PrimitiveTypes.class, "id < 3").execute();
+ Collection allOddInstances = (Collection)pm.newQuery(
+ PrimitiveTypes.class, "booleanNull").execute();
+ Collection allInstances = (Collection)pm.newQuery(
+ PrimitiveTypes.class, "true").execute();
+ Collection empty = new HashSet();
+
+ // case true | true
+ runSimplePrimitiveTypesQuery("true | true",
+ pm, allInstances, ASSERTION_FAILED);
+
+ // case true | false
+ runSimplePrimitiveTypesQuery("true | false",
+ pm, allInstances, ASSERTION_FAILED);
+
+ // case false | true
+ runSimplePrimitiveTypesQuery("false | true",
+ pm, allInstances, ASSERTION_FAILED);
+
+ // case false | false
+ runSimplePrimitiveTypesQuery("false | false",
+ pm, empty, ASSERTION_FAILED);
+
+ // case boolean | boolean
+ runSimplePrimitiveTypesQuery("intNotNull == 9 | booleanNotNull",
+ pm, allOddInstances, ASSERTION_FAILED);
+ runSimplePrimitiveTypesQuery("id == 1 | id == 2",
+ pm, instancesLess3, ASSERTION_FAILED);
+
+ // case boolean | Boolean
+ runSimplePrimitiveTypesQuery("intNotNull == 9 | booleanNull",
+ pm, allOddInstances, ASSERTION_FAILED);
+ // case Boolean | boolean
+ runSimplePrimitiveTypesQuery("booleanNull | intNotNull == 9",
+ pm, allOddInstances, ASSERTION_FAILED);
+ // case Boolean | Boolean
+ runSimplePrimitiveTypesQuery("booleanNull | booleanNull",
+ pm, allOddInstances, ASSERTION_FAILED);
+
+ // case Boolean parameter
+ runParameterPrimitiveTypesQuery("param | id == 9",
+ "Boolean param", Boolean.TRUE,
+ pm, allInstances, ASSERTION_FAILED);
+ runParameterPrimitiveTypesQuery("param | id == 9",
+ "Boolean param", Boolean.FALSE,
+ pm, instance9, ASSERTION_FAILED);
+
+ // case boolean parameter
+ runParameterPrimitiveTypesQuery("param | id == 9",
+ "boolean param", Boolean.TRUE,
+ pm, allInstances, ASSERTION_FAILED);
+ runParameterPrimitiveTypesQuery("param | id == 9",
+ "boolean param", Boolean.FALSE,
+ pm, instance9, ASSERTION_FAILED);
+ tx.commit();
+ }
+
+ /** */
+ void runNegativeTest(PersistenceManager pm) {
+ if (debug) logger.debug("\nExecuting positive test BooleanLogicalAND() ...");
+
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ try {
+ Query q = pm.newQuery(PrimitiveTypes.class,
+ "intNotNull | intNotNull");
+ Object result = q.execute();
+ fail(ASSERTION_FAILED,
+ "Query uisng bitwise | operator should throw JDOUserException.");
+ }
+ catch (JDOUserException ex) {
+ // expected exception
+ if (debug) {
+ logger.debug("expected exception: " + ex);
+ }
+ }
+ tx.commit();
+ }
+
+}
+
Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/ComparisonTests.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/ComparisonTests.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/ComparisonTests.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/ComparisonTests.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,143 @@
+/*
+ * 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.operators;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.jdo.Extent;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.fieldtypes.AllTypes;
+
+public abstract class ComparisonTests extends JDO_Test {
+ protected PersistenceManager pm;
+ protected Query query;
+ protected Transaction tx;
+ protected Collection query_result;
+
+ protected static String BooleanParameter = "Boolean value";
+ protected static String booleanParameter = "boolean value";
+ protected static String ByteParameter = "Byte value";
+ protected static String byteParameter = "byte value";
+ protected static String CharacterParameter = "Character value";
+ protected static String charParameter = "char value";
+ protected static String DoubleParameter = "Double value";
+ protected static String doubleParameter = "double value";
+ protected static String FloatParameter = "Float value";
+ protected static String floatParameter = "float value";
+ protected static String IntegerParameter = "Integer value";
+ protected static String intParameter = "int value";
+ protected static String LongParameter = "Long value";
+ protected static String longParameter = "long value";
+ protected static String ShortParameter = "Short value";
+ protected static String shortParameter = "short value";
+ protected static String StringParameter = "String value";
+ protected static String LocaleParameter = "java.util.Locale value";
+ protected static String BigDecimalParameter = "java.math.BigDecimal value";
+ protected static String BigIntegerParameter = "java.math.BigInteger value";
+ protected static String DateParameter = "java.util.Date value";
+ protected static String AllTypesParameter = "org.apache.jdo.tck.pc.fieldtypes.AllTypes value";
+
+ /** */
+ protected void verifyDataLoaded(PersistenceManager pm)
+ {
+ Transaction tx = pm.currentTransaction();
+ int cnt = 0;
+ try {
+ tx.begin();
+ Extent e = pm.getExtent(AllTypes.class, false);
+ Iterator i = e.iterator();
+ while(i.hasNext()){
+ Object o = i.next();
+ cnt++;
+ }
+ e.close(i);
+ tx.rollback();
+
+ if (cnt == AllTypes.NUM_VALUES)
+ return;
+
+ tx.begin();
+ i = e.iterator();
+ while (i.hasNext()) {
+ Object o = i.next();
+ pm.deletePersistent(o);
+ }
+ e.close(i);
+ tx.commit();
+ }
+ finally {
+ if ((tx !=null) && tx.isActive())
+ tx.rollback();
+ }
+ AllTypes.load(pm);
+ }
+
+
+ /** */
+ protected void fail(String assertion, String message, String filter, String parameter)
+ {
+ StringBuffer buf = new StringBuffer();
+ buf.append(message);
+ buf.append("(");
+ buf.append(" filter \"").append(filter).append("\"");
+ if (parameter != null) {
+ buf.append(" , parameter \"").append(parameter).append("\"");
+ }
+ buf.append(")");
+
+ fail(assertion, buf.toString());
+ }
+
+ /** */
+ protected void runQuery(PersistenceManager pm,
+ String filter, String parameter, Object parameterValue,
+ String assertion)
+ {
+ Extent e = pm.getExtent(AllTypes.class, false);
+ query = pm.newQuery(e, filter);
+ query_result = null;
+ try {
+ if (parameter != null) {
+ query.declareParameters(parameter);
+ query_result = (Collection) query.execute(parameterValue);
+ }
+ else {
+ query_result = (Collection) query.execute();
+ }
+ }
+ catch (Throwable throwable) {
+ if (debug)
+ throwable.printStackTrace();
+ fail(assertion, "Exception on Query.execute " + throwable, filter, parameter);
+ query_result = null;
+ if (tx.isActive())
+ tx.rollback();
+ return;
+ }
+ if (query_result == null) {
+ fail(assertion, "Query.execute returned a null", filter, parameter);
+ if (tx.isActive())
+ tx.rollback();
+ }
+ }
+}
+
Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/ConditionalAND.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/ConditionalAND.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/ConditionalAND.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/ConditionalAND.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,139 @@
+/*
+ * 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.operators;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.pc.mylib.PrimitiveTypes;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Conditional AND Query Operator
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.2-21.
+ *<BR>
+ *<B>Assertion Description: </B>
+The conditional AND operator (<code>&&</code>) is supported for all
+types as they are defined in the Java language.
+This includes the following types:
+<UL>
+<LI><code>Boolean, boolean</code></LI>
+</UL>
+*/
+
+public class ConditionalAND extends QueryTest {
+
+ /** */
+ private static final String ASSERTION_FAILED =
+ "Assertion A14.6.2-21 (ConditionalAND) failed: ";
+
+ /**
+ * 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(ConditionalAND.class);
+ }
+
+
+ /** */
+ public void test() {
+ pm = getPM();
+
+ try {
+ loadPrimitiveTypes(pm);
+ runTest(pm);
+ }
+ finally {
+ cleanupDatabase(pm, PrimitiveTypes.class);
+ pm.close();
+ pm = null;
+ }
+ }
+
+ /** */
+ void runTest(PersistenceManager pm) {
+ if (debug) logger.debug("\nExecuting test ConditionalAND() ...");
+
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ Collection instance9 = (Collection)pm.newQuery(
+ PrimitiveTypes.class, "id == 9").execute();
+ Collection allOddInstances = (Collection)pm.newQuery(
+ PrimitiveTypes.class, "booleanNull").execute();
+ Collection allInstances = (Collection)pm.newQuery(
+ PrimitiveTypes.class, "true").execute();
+ Collection empty = new HashSet();
+
+ // case true && true
+ runSimplePrimitiveTypesQuery("true && true",
+ pm, allInstances, ASSERTION_FAILED);
+
+ // case true && false
+ runSimplePrimitiveTypesQuery("true && false",
+ pm, empty, ASSERTION_FAILED);
+
+ // case false && true
+ runSimplePrimitiveTypesQuery("false && true",
+ pm, empty, ASSERTION_FAILED);
+
+ // case false && false
+ runSimplePrimitiveTypesQuery("false && false",
+ pm, empty, ASSERTION_FAILED);
+
+ // case boolean && boolean
+ runSimplePrimitiveTypesQuery("intNotNull == 9 && booleanNotNull",
+ pm, instance9, ASSERTION_FAILED);
+
+ // case boolean && Boolean
+ runSimplePrimitiveTypesQuery("intNotNull == 9 && booleanNull",
+ pm, instance9, ASSERTION_FAILED);
+ // case Boolean && boolean
+ runSimplePrimitiveTypesQuery("booleanNull && intNotNull == 9",
+ pm, instance9, ASSERTION_FAILED);
+ // case Boolean && Boolean
+ runSimplePrimitiveTypesQuery("booleanNull && booleanNull",
+ pm, allOddInstances, ASSERTION_FAILED);
+
+ // case Boolean parameter
+ runParameterPrimitiveTypesQuery("param && id == 9",
+ "Boolean param", Boolean.TRUE,
+ pm, instance9, ASSERTION_FAILED);
+ runParameterPrimitiveTypesQuery("param && id == 9",
+ "Boolean param", Boolean.FALSE,
+ pm, empty, ASSERTION_FAILED);
+
+ // case boolean parameter
+ runParameterPrimitiveTypesQuery("param && id == 9",
+ "boolean param", Boolean.TRUE,
+ pm, instance9, ASSERTION_FAILED);
+ runParameterPrimitiveTypesQuery("param && id == 9",
+ "boolean param", Boolean.FALSE,
+ pm, empty, ASSERTION_FAILED);
+
+ tx.commit();
+ }
+}
Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/ConditionalOR.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/ConditionalOR.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/ConditionalOR.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/ConditionalOR.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,139 @@
+/*
+ * 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.operators;
+
+import java.util.Collection;
+import java.util.HashSet;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.pc.mylib.PrimitiveTypes;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Conditional OR Query Operator
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.2-23.
+ *<BR>
+ *<B>Assertion Description: </B>
+The conditional OR operator (<code>||</code>) is supported for all types
+as they are defined in the Java language. This includes the following types:
+<UL>
+<LI><code>Boolean, boolean</code></LI>
+</UL>
+ */
+
+public class ConditionalOR extends QueryTest {
+
+ /** */
+ private static final String ASSERTION_FAILED =
+ "Assertion A14.6.2-23 (ConditionalOR) failed: ";
+
+ /**
+ * 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(ConditionalOR.class);
+ }
+
+ /** */
+ public void test() {
+ pm = getPM();
+
+ try {
+ loadPrimitiveTypes(pm);
+ runTest(pm);
+ }
+ finally {
+ cleanupDatabase(pm, PrimitiveTypes.class);
+ pm.close();
+ pm = null;
+ }
+ }
+
+ /** */
+ void runTest(PersistenceManager pm) {
+ if (debug) logger.debug("\nExecuting test ConditionalOR() ...");
+
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ Collection instance9 = (Collection)pm.newQuery(
+ PrimitiveTypes.class, "id == 9").execute();
+ Collection instancesLess3 = (Collection)pm.newQuery(
+ PrimitiveTypes.class, "id < 3").execute();
+ Collection allOddInstances = (Collection)pm.newQuery(
+ PrimitiveTypes.class, "booleanNull").execute();
+ Collection allInstances = (Collection)pm.newQuery(
+ PrimitiveTypes.class, "true").execute();
+ Collection empty = new HashSet();
+
+ // case true || true
+ runSimplePrimitiveTypesQuery("true || true",
+ pm, allInstances, ASSERTION_FAILED);
+
+ // case true || false
+ runSimplePrimitiveTypesQuery("true || false",
+ pm, allInstances, ASSERTION_FAILED);
+
+ // case false || true
+ runSimplePrimitiveTypesQuery("false || true",
+ pm, allInstances, ASSERTION_FAILED);
+
+ // case false || false
+ runSimplePrimitiveTypesQuery("false || false",
+ pm, empty, ASSERTION_FAILED);
+
+ // case boolean || boolean
+ runSimplePrimitiveTypesQuery("intNotNull == 9 || booleanNotNull",
+ pm, allOddInstances, ASSERTION_FAILED);
+ runSimplePrimitiveTypesQuery("id == 1 || id == 2",
+ pm, instancesLess3, ASSERTION_FAILED);
+
+ // case boolean || Boolean
+ runSimplePrimitiveTypesQuery("intNotNull == 9 || booleanNull",
+ pm, allOddInstances, ASSERTION_FAILED);
+ // case Boolean || boolean
+ runSimplePrimitiveTypesQuery("booleanNull || intNotNull == 9",
+ pm, allOddInstances, ASSERTION_FAILED);
+ // case Boolean || Boolean
+ runSimplePrimitiveTypesQuery("booleanNull || booleanNull",
+ pm, allOddInstances, ASSERTION_FAILED);
+
+ // case Boolean parameter
+ runParameterPrimitiveTypesQuery("param || id == 9",
+ "Boolean param", Boolean.TRUE,
+ pm, allInstances, ASSERTION_FAILED);
+ runParameterPrimitiveTypesQuery("param || id == 9",
+ "Boolean param", Boolean.FALSE,
+ pm, instance9, ASSERTION_FAILED);
+
+ // case boolean parameter
+ runParameterPrimitiveTypesQuery("param || id == 9",
+ "boolean param", Boolean.TRUE,
+ pm, allInstances, ASSERTION_FAILED);
+ runParameterPrimitiveTypesQuery("param || id == 9",
+ "boolean param", Boolean.FALSE,
+ pm, instance9, ASSERTION_FAILED);
+ tx.commit();
+ }
+}
Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/Division.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/Division.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/Division.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/Division.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,131 @@
+/*
+ * 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.operators;
+
+import java.util.Collection;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PrimitiveTypes;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Division Query Operator
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.2-31.
+ *<BR>
+ *<B>Assertion Description: </B>
+The division operator (<code>/</code>) is supported for all types as they are
+defined in the Java language. This includes the following types:
+<UL>
+<LI><code>byte, short, int, long, char, Byte, Short Integer, Long, Character</code></LI>
+<LI><code>float, double, Float, Double</code></LI>
+<LI><code>BigDecimal, BigInteger</code></LI>
+</UL>
+The operation on object-valued fields of wrapper types (<code>Boolean, Byte,
+Short, Integer, Long, Float</code>, and <code>Double</code>), and numeric types
+(<code>BigDecimal</code> and <code>BigInteger</code>)
+use the wrapped values as operands.
+ */
+
+public class Division extends QueryTest {
+
+ /** */
+ private static final String ASSERTION_FAILED =
+ "Assertion A14.6.2-31 (Division) failed: ";
+
+ /**
+ * 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(Division.class);
+ }
+
+ /** */
+ public void test() {
+ pm = getPM();
+
+ try {
+ loadPrimitiveTypes(pm);
+ runTest(pm);
+ }
+ finally {
+ cleanupDatabase(pm, PrimitiveTypes.class);
+ pm.close();
+ pm = null;
+ }
+ }
+
+ /** */
+ void runTest(PersistenceManager pm) {
+ if (debug) logger.debug("\nExecuting test Division() ...");
+
+ Transaction tx = pm.currentTransaction();
+ tx.begin();
+
+ Collection instance8 = (Collection)pm.newQuery(
+ PrimitiveTypes.class, "id == 8").execute();
+
+ Collection instances8And9 = (Collection)pm.newQuery(
+ PrimitiveTypes.class, "id == 8 || id == 9").execute();
+
+ runSimplePrimitiveTypesQuery("id / 2 == 4",
+ pm, instances8And9, ASSERTION_FAILED);
+ runSimplePrimitiveTypesQuery("byteNotNull / 2 == 4",
+ pm, instances8And9, ASSERTION_FAILED);
+ runSimplePrimitiveTypesQuery("shortNotNull / 2 == 4",
+ pm, instances8And9, ASSERTION_FAILED);
+ runSimplePrimitiveTypesQuery("intNotNull / 2 == 4",
+ pm, instances8And9, ASSERTION_FAILED);
+ runSimplePrimitiveTypesQuery("longNotNull / 2 == 4",
+ pm, instances8And9, ASSERTION_FAILED);
+ /* testing float division?
+ runSimplePrimitiveTypesQuery("floatNotNull / 2 == 4",
+ pm, instance8, ASSERTION_FAILED);*/
+ /* testing double division?
+ runSimplePrimitiveTypesQuery("doubleNotNull / 2 == 4",
+ pm, instance8, ASSERTION_FAILED);*/
+ runSimplePrimitiveTypesQuery("byteNull / 2 == 4",
+ pm, instances8And9, ASSERTION_FAILED);
+ runSimplePrimitiveTypesQuery("shortNull / 2 == 4",
+ pm, instances8And9, ASSERTION_FAILED);
+ runSimplePrimitiveTypesQuery("intNull / 2 == 4",
+ pm, instances8And9, ASSERTION_FAILED);
+ runSimplePrimitiveTypesQuery("longNull / 2 == 4",
+ pm, instances8And9, ASSERTION_FAILED);
+ /* testing float division?
+ runSimplePrimitiveTypesQuery("floatNull / 2 == 4",
+ pm, instance8, ASSERTION_FAILED);*/
+ /* testing double division?
+ runSimplePrimitiveTypesQuery("doubleNull / 2 == 4",
+ pm, instance8, ASSERTION_FAILED);*/
+ /* testing BigDecimal division? Scaling issue!
+ runSimplePrimitiveTypesQuery("bigDecimal / 2 == 4",
+ pm, instances8And9, ASSERTION_FAILED);*/
+ runSimplePrimitiveTypesQuery("bigInteger / 2 == 4",
+ pm, instances8And9, ASSERTION_FAILED);
+
+ tx.commit();
+ }
+}