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 cl...@apache.org on 2021/05/07 23:12:22 UTC
[db-jdo] 40/43: JDO-513, JDO-514, and other test challenges
This is an automated email from the ASF dual-hosted git repository.
clr pushed a commit to branch origin/2.0.1
in repository https://gitbox.apache.org/repos/asf/db-jdo.git
commit 7fb72348825bf1c5c49714bcf493c321982678c5
Author: Michelle Caisse <mc...@apache.org>
AuthorDate: Fri Oct 5 18:59:15 2007 +0000
JDO-513, JDO-514, and other test challenges
---
.../fetchplan/FetchPlanInterface.java | 753 ++++++++--------
.../lifecycle/StateTransitionsReturnedObjects.java | 4 +-
.../org/apache/jdo/tck/query/api/ChangeQuery.java | 210 ++---
.../query/jdoql/parameters/ImplicitParameters.java | 371 ++++----
.../tck/query/result/ResultClassRequirements.java | 955 +++++++++++----------
5 files changed, 1149 insertions(+), 1144 deletions(-)
diff --git a/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanInterface.java b/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanInterface.java
index df90465..39db057 100644
--- a/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanInterface.java
+++ b/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanInterface.java
@@ -1,376 +1,377 @@
-/*
- * 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.api.persistencemanager.fetchplan;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.jdo.FetchPlan;
-
-import org.apache.jdo.tck.JDO_Test;
-
-import org.apache.jdo.tck.pc.mylib.PCPoint;
-import org.apache.jdo.tck.pc.mylib.PCRect;
-
-import org.apache.jdo.tck.util.BatchTestRunner;
-
-/**
- *<B>Title:</B> Test TITLE
- *<BR>
- *<B>Keywords:</B> fetch plan
- *<BR>
- *<B>Assertion IDs:</B> 12.7.1-1
- *<BR>
- *<B>Assertion Description: </B>
-public interface FetchPlan {
-String DEFAULT = "default";
-String ALL = "all";
-int FETCH_SIZE_GREEDY = -1;
-int FETCH_SIZE_OPTIMAL = 0;
-int DETACH_LOAD_FIELDS = 1;
-int DETACH_UNLOAD_FIELDS = 2;
-A12.7.1-1 [/** Add the fetchgroup to the set of active fetch groups. Duplicate names will be removed.
-FetchPlan addGroup(String fetchGroupName);
-/** Remove the fetch group from the set active fetch groups.
-FetchPlan removeGroup(String fetchGroupName);
-/** Remove all active groups, including the default fetch group.
-FetchPlan clearGroups();
-/** Return an immutable Set of the names of all active fetch groups.
-Set getGroups();
-/** Set a Collection of group names to replace the current groups. Duplicate names will be removed.
-FetchPlan setGroups(Collection fetchGroupNames);
-/** Set an array of group names to replace the current groups. Duplicate names will be removed.
-FetchPlan setGroups(String[] fetchGroupNames);
-/** Set a single group to replace the current groups.
-FetchPlan setGroup(String fetchGroupName);]
-/** Set the roots for DetachAllOnCommit
-FetchPlan setDetachmentRoots(Collection roots);
-/** Get the roots for DetachAllOnCommit
-Collection getDetachmentRoots();
-/** Set the roots for DetachAllOnCommit
-FetchPlan setDetachmentRootClasses(Class[] rootClasses);
-/** Get the roots for DetachAllOnCommit
-Class[] getDetachmentRootClasses();
-/** Set the maximum fetch depth.
-FetchPlan setMaxFetchDepth(int fetchDepth);
-/** Get the maximum fetch depth.
-int getMaxFetchDepth();
-A12.7.1-2 [/** Set the fetch size for large result set support.
-FetchPlan setFetchSize(int fetchSize);
-/** Return the fetch size; 0 if not set; -1 for greedy fetching.
-int getFetchSize();]
-A12.7.1-3 [/** Set detachment options
-FetchPlan setDetachmentOptions(int options);
-/** Return the detachment options
-int getDetachmentOptions();]
- */
-
-public class FetchPlanInterface extends JDO_Test {
-
- /** */
- private static final String ASSERTION_FAILED =
- "Assertion 12.7.1-1 (FetchPlanTest) 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(FetchPlanInterface.class);
- }
-
- /**
- * @see JDO_Test#localSetUp()
- */
- protected void localSetUp() {
- addTearDownClass(PCRect.class);
- addTearDownClass(PCPoint.class);
- }
-
- /** */
- protected boolean setEquals
- (Collection expected, Collection actual) {
- if (expected == actual)
- return true;
- if (expected == null || actual == null)
- return false;
- Set expectedSet = new HashSet(expected);
- Set actualSet = new HashSet(actual);
- return expectedSet.equals(actualSet);
- }
-
- /** */
- protected void failCompare(String message,
- Object expected, Object actual) {
- appendMessage(ASSERTION_FAILED + message);
- appendMessage("expected: " + expected);
- appendMessage("actual: " + actual);
- }
-
- /** */
- protected void failCompare(String message,
- int expected, int actual) {
- appendMessage(ASSERTION_FAILED + message);
- appendMessage("expected: " + expected);
- appendMessage("actual: " + actual);
- }
-
- /** */
- public void testGroups() {
- checkDefaultGroups();
- checkClearGroups();
- checkSetGroup();
- checkAddGroup();
- checkRemoveGroup();
- checkClearGroups();
- checkSetGroupsCollection();
- checkSetGroupsArray();
- failOnError();
- }
-
- /** */
- public void testDetachmentRoots() {
- checkGetDetachmentRoots();
- checkSetDetachmentRoots();
- checkSetDetachmentRootClasses();
- failOnError();
- }
-
- /** */
- public void testDetachmentOptions() {
- int expectedOptions =
- FetchPlan.DETACH_LOAD_FIELDS +
- FetchPlan.DETACH_UNLOAD_FIELDS;
- FetchPlan fp = getPM().getFetchPlan();
- int initialOptions = fp.getDetachmentOptions();
- if (FetchPlan.DETACH_LOAD_FIELDS != initialOptions) {
- failCompare(
- "testDetachmentOptions(): wrong getDetachmentOptions() " +
- "after getPersistenceManager().",
- FetchPlan.DETACH_LOAD_FIELDS, initialOptions);
- }
- fp.setDetachmentOptions(expectedOptions);
- int actualOptions = fp.getDetachmentOptions();
- if (expectedOptions != actualOptions) {
- failCompare(
- "testDetachmentOptions(): wrong getDetachmentOptions() " +
- "after setDetachmentOptions().",
- expectedOptions, actualOptions);
- }
- cleanupPM();
- failOnError();
- }
-
- /** */
- public void testMaxFetchDepth() {
- int expectedMaxFetchDepth = 12;
- FetchPlan fp = getPM().getFetchPlan();
- fp.setMaxFetchDepth(expectedMaxFetchDepth);
- int actualMaxFetchDepth = fp.getMaxFetchDepth();
- if (expectedMaxFetchDepth != actualMaxFetchDepth) {
- failCompare(
- "testMaxFetchDepth(): wrong getMaxFetchDepth() " +
- "after setMaxFetchDepth().",
- expectedMaxFetchDepth, actualMaxFetchDepth);
- }
- cleanupPM();
- failOnError();
- }
-
- /** */
- public void testFetchSize() {
- int expectedFetchSize = 12;
- FetchPlan fp = getPM().getFetchPlan();
- fp.setFetchSize(expectedFetchSize);
- int actualFetchSize = fp.getFetchSize();
- if (expectedFetchSize != actualFetchSize) {
- failCompare(
- "testFetchSize(): wrong getFetchSize() " +
- "after setFetchSize().",
- expectedFetchSize, actualFetchSize);
- }
- cleanupPM();
- failOnError();
- }
-
- /** */
- public void checkDefaultGroups() {
- Set expectedGroups = new HashSet();
- expectedGroups.add("default");
- FetchPlan fp = getPM().getFetchPlan();
- Collection groups = fp.getGroups();
- if (!setEquals(expectedGroups, groups)) {
- failCompare(
- "checkDefaultGroups(): wrong getGroups() " +
- "after getPersistenceManager().",
- expectedGroups, groups);
- }
- cleanupPM();
- }
-
- /** */
- public void checkClearGroups() {
- Set expectedGroups = new HashSet();
- FetchPlan fp = getPM().getFetchPlan();
- fp.clearGroups();
- Collection groups = fp.getGroups();
- if (!setEquals(expectedGroups, groups)) {
- failCompare(
- "checkClearGroups(): wrong getGroups() " +
- "after clearGroups.",
- expectedGroups, groups);
- }
- cleanupPM();
- }
-
- /** */
- public void checkSetGroup() {
- Set expectedGroups = new HashSet();
- expectedGroups.add("group1");
- FetchPlan fp = getPM().getFetchPlan();
- fp.setGroup("group1");
- Collection groups = fp.getGroups();
- if (!setEquals(expectedGroups, groups)) {
- failCompare(
- "checkSetGroup(): wrong getGroups() " +
- "after setGroup.",
- expectedGroups, groups);
- }
- cleanupPM();
- }
-
- /** */
- public void checkAddGroup() {
- Set expectedGroups = new HashSet();
- expectedGroups.add("default");
- expectedGroups.add("group1");
- FetchPlan fp = getPM().getFetchPlan();
- fp.addGroup("group1");
- Collection groups = fp.getGroups();
- if (!setEquals(expectedGroups, groups)) {
- failCompare(
- "checkAddGroup(): wrong getGroups() " +
- "after addGroup.",
- expectedGroups, groups);
- }
- cleanupPM();
- }
-
- /** */
- public void checkRemoveGroup() {
- Set expectedGroups = new HashSet();
- FetchPlan fp = getPM().getFetchPlan();
- Collection groups = fp.getGroups();
- fp.removeGroup("default");
- if (!setEquals(expectedGroups, groups)) {
- failCompare(
- "checkRemoveGroup(): wrong getGroups() " +
- "after removeGroup.",
- expectedGroups, groups);
- }
- cleanupPM();
- }
-
- /** */
- public void checkSetGroupsCollection() {
- Set expectedGroups = new HashSet();
- expectedGroups.add("default");
- expectedGroups.add("group1");
- expectedGroups.add("group2");
- FetchPlan fp = getPM().getFetchPlan();
- fp.setGroups(expectedGroups);
- Collection groups = fp.getGroups();
- if (!setEquals(expectedGroups, groups)) {
- failCompare(
- "checkSetGroupsCollection(): wrong getGroups() " +
- "after SetGroups(Collection).",
- expectedGroups, groups);
- }
- cleanupPM();
- }
-
- /** */
- public void checkSetGroupsArray() {
- Set expectedGroups = new HashSet();
- expectedGroups.add("default");
- expectedGroups.add("group1");
- expectedGroups.add("group2");
- FetchPlan fp = getPM().getFetchPlan();
- fp.setGroups(new String[] {"default", "group1", "group2"});
- Collection groups = fp.getGroups();
- if (!setEquals(expectedGroups, groups)) {
- failCompare(
- "checkSetGroupsArray(): wrong getGroups() " +
- "after setGroups(String[]).",
- expectedGroups, groups);
- }
- cleanupPM();
- }
-
- /** */
- protected void checkGetDetachmentRoots() {
- Set expectedRoots = new HashSet();
- FetchPlan fp = getPM().getFetchPlan();
- Collection roots = fp.getDetachmentRoots();
- if (!setEquals(expectedRoots, roots)) {
- failCompare(
- "checkGetDetachmentRoots(): wrong getDetachmentRoots() " +
- "after getPersistenceManager().",
- expectedRoots, roots);
- }
- cleanupPM();
- }
-
- /** */
- protected void checkSetDetachmentRoots() {
- PCPoint p = new PCPoint(10, 20);
- Set expectedRoots = new HashSet();
- expectedRoots.add(p);
- FetchPlan fp = getPM().getFetchPlan();
- fp.setDetachmentRoots(expectedRoots);
- Collection roots = fp.getDetachmentRoots();
- if (!setEquals(expectedRoots, roots)) {
- failCompare(
- "checkGetDetachmentRoots(): wrong getDetachmentRoots() " +
- "after setDetachmentRoots().",
- expectedRoots, roots);
- }
- cleanupPM();
- }
-
- /** */
- private void checkSetDetachmentRootClasses() {
- Class[] expectedRootClasses = new Class[] {PCPoint.class};
- FetchPlan fp = getPM().getFetchPlan();
- fp.setDetachmentRootClasses(
- expectedRootClasses);
- Class[] rootClasses = fp.getDetachmentRootClasses();
- if (!Arrays.equals(expectedRootClasses, rootClasses)) {
- failCompare(
- "checkGetDetachmentRootClasses(): " +
- "wrong getDetachmentRootClasses() " +
- "after setDetachmentRootClasses().",
- expectedRootClasses, rootClasses);
- }
- cleanupPM();
- }
-
-}
\ No newline at end of file
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.api.persistencemanager.fetchplan;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.jdo.FetchPlan;
+
+import org.apache.jdo.tck.JDO_Test;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.pc.mylib.PCRect;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Test TITLE
+ *<BR>
+ *<B>Keywords:</B> fetch plan
+ *<BR>
+ *<B>Assertion IDs:</B> 12.7.1-1
+ *<BR>
+ *<B>Assertion Description: </B>
+public interface FetchPlan {
+String DEFAULT = "default";
+String ALL = "all";
+int FETCH_SIZE_GREEDY = -1;
+int FETCH_SIZE_OPTIMAL = 0;
+int DETACH_LOAD_FIELDS = 1;
+int DETACH_UNLOAD_FIELDS = 2;
+A12.7.1-1 [/** Add the fetchgroup to the set of active fetch groups. Duplicate names will be removed.
+FetchPlan addGroup(String fetchGroupName);
+/** Remove the fetch group from the set active fetch groups.
+FetchPlan removeGroup(String fetchGroupName);
+/** Remove all active groups, including the default fetch group.
+FetchPlan clearGroups();
+/** Return an immutable Set of the names of all active fetch groups.
+Set getGroups();
+/** Set a Collection of group names to replace the current groups. Duplicate names will be removed.
+FetchPlan setGroups(Collection fetchGroupNames);
+/** Set an array of group names to replace the current groups. Duplicate names will be removed.
+FetchPlan setGroups(String[] fetchGroupNames);
+/** Set a single group to replace the current groups.
+FetchPlan setGroup(String fetchGroupName);]
+/** Set the roots for DetachAllOnCommit
+FetchPlan setDetachmentRoots(Collection roots);
+/** Get the roots for DetachAllOnCommit
+Collection getDetachmentRoots();
+/** Set the roots for DetachAllOnCommit
+FetchPlan setDetachmentRootClasses(Class[] rootClasses);
+/** Get the roots for DetachAllOnCommit
+Class[] getDetachmentRootClasses();
+/** Set the maximum fetch depth.
+FetchPlan setMaxFetchDepth(int fetchDepth);
+/** Get the maximum fetch depth.
+int getMaxFetchDepth();
+A12.7.1-2 [/** Set the fetch size for large result set support.
+FetchPlan setFetchSize(int fetchSize);
+/** Return the fetch size; 0 if not set; -1 for greedy fetching.
+int getFetchSize();]
+A12.7.1-3 [/** Set detachment options
+FetchPlan setDetachmentOptions(int options);
+/** Return the detachment options
+int getDetachmentOptions();]
+ */
+
+public class FetchPlanInterface extends JDO_Test {
+
+ /** */
+ private static final String ASSERTION_FAILED =
+ "Assertion 12.7.1-1 (FetchPlanTest) 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(FetchPlanInterface.class);
+ }
+
+ /**
+ * @see JDO_Test#localSetUp()
+ */
+ protected void localSetUp() {
+ addTearDownClass(PCRect.class);
+ addTearDownClass(PCPoint.class);
+ }
+
+ /** */
+ protected boolean setEquals
+ (Collection expected, Collection actual) {
+ if (expected == actual)
+ return true;
+ if (expected == null || actual == null)
+ return false;
+ Set expectedSet = new HashSet(expected);
+ Set actualSet = new HashSet(actual);
+ return expectedSet.equals(actualSet);
+ }
+
+ /** */
+ protected void failCompare(String message,
+ Object expected, Object actual) {
+ appendMessage(ASSERTION_FAILED + message);
+ appendMessage("expected: " + expected);
+ appendMessage("actual: " + actual);
+ }
+
+ /** */
+ protected void failCompare(String message,
+ int expected, int actual) {
+ appendMessage(ASSERTION_FAILED + message);
+ appendMessage("expected: " + expected);
+ appendMessage("actual: " + actual);
+ }
+
+ /** */
+ public void testGroups() {
+ checkDefaultGroups();
+ checkClearGroups();
+ checkSetGroup();
+ checkAddGroup();
+ checkRemoveGroup();
+ checkClearGroups();
+ checkSetGroupsCollection();
+ checkSetGroupsArray();
+ failOnError();
+ }
+
+ /** */
+ public void testDetachmentRoots() {
+ checkGetDetachmentRoots();
+ checkSetDetachmentRoots();
+ checkSetDetachmentRootClasses();
+ failOnError();
+ }
+
+ /** */
+ public void testDetachmentOptions() {
+ int expectedOptions =
+ FetchPlan.DETACH_LOAD_FIELDS +
+ FetchPlan.DETACH_UNLOAD_FIELDS;
+ FetchPlan fp = getPM().getFetchPlan();
+ int initialOptions = fp.getDetachmentOptions();
+ if (FetchPlan.DETACH_LOAD_FIELDS != initialOptions) {
+ failCompare(
+ "testDetachmentOptions(): wrong getDetachmentOptions() " +
+ "after getPersistenceManager().",
+ FetchPlan.DETACH_LOAD_FIELDS, initialOptions);
+ }
+ fp.setDetachmentOptions(expectedOptions);
+ int actualOptions = fp.getDetachmentOptions();
+ if (expectedOptions != actualOptions) {
+ failCompare(
+ "testDetachmentOptions(): wrong getDetachmentOptions() " +
+ "after setDetachmentOptions().",
+ expectedOptions, actualOptions);
+ }
+ cleanupPM();
+ failOnError();
+ }
+
+ /** */
+ public void testMaxFetchDepth() {
+ int expectedMaxFetchDepth = 12;
+ FetchPlan fp = getPM().getFetchPlan();
+ fp.setMaxFetchDepth(expectedMaxFetchDepth);
+ int actualMaxFetchDepth = fp.getMaxFetchDepth();
+ if (expectedMaxFetchDepth != actualMaxFetchDepth) {
+ failCompare(
+ "testMaxFetchDepth(): wrong getMaxFetchDepth() " +
+ "after setMaxFetchDepth().",
+ expectedMaxFetchDepth, actualMaxFetchDepth);
+ }
+ cleanupPM();
+ failOnError();
+ }
+
+ /** */
+ public void testFetchSize() {
+ int expectedFetchSize = 12;
+ FetchPlan fp = getPM().getFetchPlan();
+ fp.setFetchSize(expectedFetchSize);
+ int actualFetchSize = fp.getFetchSize();
+ if (expectedFetchSize != actualFetchSize) {
+ failCompare(
+ "testFetchSize(): wrong getFetchSize() " +
+ "after setFetchSize().",
+ expectedFetchSize, actualFetchSize);
+ }
+ cleanupPM();
+ failOnError();
+ }
+
+ /** */
+ public void checkDefaultGroups() {
+ Set expectedGroups = new HashSet();
+ expectedGroups.add("default");
+ FetchPlan fp = getPM().getFetchPlan();
+ Collection groups = fp.getGroups();
+ if (!setEquals(expectedGroups, groups)) {
+ failCompare(
+ "checkDefaultGroups(): wrong getGroups() " +
+ "after getPersistenceManager().",
+ expectedGroups, groups);
+ }
+ cleanupPM();
+ }
+
+ /** */
+ public void checkClearGroups() {
+ Set expectedGroups = new HashSet();
+ FetchPlan fp = getPM().getFetchPlan();
+ fp.clearGroups();
+ Collection groups = fp.getGroups();
+ if (!setEquals(expectedGroups, groups)) {
+ failCompare(
+ "checkClearGroups(): wrong getGroups() " +
+ "after clearGroups.",
+ expectedGroups, groups);
+ }
+ cleanupPM();
+ }
+
+ /** */
+ public void checkSetGroup() {
+ Set expectedGroups = new HashSet();
+ expectedGroups.add("group1");
+ FetchPlan fp = getPM().getFetchPlan();
+ fp.setGroup("group1");
+ Collection groups = fp.getGroups();
+ if (!setEquals(expectedGroups, groups)) {
+ failCompare(
+ "checkSetGroup(): wrong getGroups() " +
+ "after setGroup.",
+ expectedGroups, groups);
+ }
+ cleanupPM();
+ }
+
+ /** */
+ public void checkAddGroup() {
+ Set expectedGroups = new HashSet();
+ expectedGroups.add("default");
+ expectedGroups.add("group1");
+ FetchPlan fp = getPM().getFetchPlan();
+ fp.addGroup("group1");
+ Collection groups = fp.getGroups();
+ if (!setEquals(expectedGroups, groups)) {
+ failCompare(
+ "checkAddGroup(): wrong getGroups() " +
+ "after addGroup.",
+ expectedGroups, groups);
+ }
+ cleanupPM();
+ }
+
+ /** */
+ public void checkRemoveGroup() {
+ Set expectedGroups = new HashSet();
+ FetchPlan fp = getPM().getFetchPlan();
+ fp.removeGroup("default");
+ Collection groups = fp.getGroups();
+ if (!setEquals(expectedGroups, groups)) {
+ failCompare(
+ "checkRemoveGroup(): wrong getGroups() " +
+ "after removeGroup.",
+ expectedGroups, groups);
+ }
+ cleanupPM();
+ }
+
+ /** */
+ public void checkSetGroupsCollection() {
+ Set expectedGroups = new HashSet();
+ expectedGroups.add("default");
+ expectedGroups.add("group1");
+ expectedGroups.add("group2");
+ FetchPlan fp = getPM().getFetchPlan();
+ fp.setGroups(expectedGroups);
+ Collection groups = fp.getGroups();
+ if (!setEquals(expectedGroups, groups)) {
+ failCompare(
+ "checkSetGroupsCollection(): wrong getGroups() " +
+ "after SetGroups(Collection).",
+ expectedGroups, groups);
+ }
+ cleanupPM();
+ }
+
+ /** */
+ public void checkSetGroupsArray() {
+ Set expectedGroups = new HashSet();
+ expectedGroups.add("default");
+ expectedGroups.add("group1");
+ expectedGroups.add("group2");
+ FetchPlan fp = getPM().getFetchPlan();
+ fp.setGroups(new String[] {"default", "group1", "group2"});
+ Collection groups = fp.getGroups();
+ if (!setEquals(expectedGroups, groups)) {
+ failCompare(
+ "checkSetGroupsArray(): wrong getGroups() " +
+ "after setGroups(String[]).",
+ expectedGroups, groups);
+ }
+ cleanupPM();
+ }
+
+ /** */
+ protected void checkGetDetachmentRoots() {
+ Set expectedRoots = new HashSet();
+ FetchPlan fp = getPM().getFetchPlan();
+ Collection roots = fp.getDetachmentRoots();
+ if (!setEquals(expectedRoots, roots)) {
+ failCompare(
+ "checkGetDetachmentRoots(): wrong getDetachmentRoots() " +
+ "after getPersistenceManager().",
+ expectedRoots, roots);
+ }
+ cleanupPM();
+ }
+
+ /** */
+ protected void checkSetDetachmentRoots() {
+ PCPoint p = new PCPoint(10, 20);
+ Set expectedRoots = new HashSet();
+ expectedRoots.add(p);
+ FetchPlan fp = getPM().getFetchPlan();
+ fp.setDetachmentRoots(expectedRoots);
+ Collection roots = fp.getDetachmentRoots();
+ if (!setEquals(expectedRoots, roots)) {
+ failCompare(
+ "checkGetDetachmentRoots(): wrong getDetachmentRoots() " +
+ "after setDetachmentRoots().",
+ expectedRoots, roots);
+ }
+ cleanupPM();
+ }
+
+ /** */
+ private void checkSetDetachmentRootClasses() {
+ Class[] expectedRootClasses = new Class[] {PCPoint.class};
+ FetchPlan fp = getPM().getFetchPlan();
+ fp.setDetachmentRootClasses(
+ expectedRootClasses);
+ Class[] rootClasses = fp.getDetachmentRootClasses();
+ if (!Arrays.equals(expectedRootClasses, rootClasses)) {
+ failCompare(
+ "checkGetDetachmentRootClasses(): " +
+ "wrong getDetachmentRootClasses() " +
+ "after setDetachmentRootClasses().",
+ expectedRootClasses, rootClasses);
+ }
+ cleanupPM();
+ }
+
+}
diff --git a/tck20/src/java/org/apache/jdo/tck/lifecycle/StateTransitionsReturnedObjects.java b/tck20/src/java/org/apache/jdo/tck/lifecycle/StateTransitionsReturnedObjects.java
index 68ccd77..015565c 100644
--- a/tck20/src/java/org/apache/jdo/tck/lifecycle/StateTransitionsReturnedObjects.java
+++ b/tck20/src/java/org/apache/jdo/tck/lifecycle/StateTransitionsReturnedObjects.java
@@ -105,7 +105,7 @@ public class StateTransitionsReturnedObjects extends JDO_Test {
{ PERSISTENT_NEW, UNCHANGED, UNCHANGED,
UNCHANGED, UNCHANGED, PERSISTENT_NEW,
PERSISTENT_NEW, UNCHANGED, UNCHANGED,
- UNCHANGED, UNCHANGED, PERSISTENT_CLEAN,
+ UNCHANGED, UNCHANGED, UNSPECIFIED,
PERSISTENT_DIRTY},
// detachCopy outside tx
@@ -226,7 +226,7 @@ public class StateTransitionsReturnedObjects extends JDO_Test {
transaction.setNontransactionalRead(true);
}
if( current_state == PERSISTENT_NONTRANSACTIONAL_DIRTY) {
- transaction.setNontransactionalRead(true);
+ transaction.setNontransactionalWrite(true);
}
}
}
diff --git a/tck20/src/java/org/apache/jdo/tck/query/api/ChangeQuery.java b/tck20/src/java/org/apache/jdo/tck/query/api/ChangeQuery.java
index 0aae29c..3fac19d 100644
--- a/tck20/src/java/org/apache/jdo/tck/query/api/ChangeQuery.java
+++ b/tck20/src/java/org/apache/jdo/tck/query/api/ChangeQuery.java
@@ -1,104 +1,106 @@
-/*
- * 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.api;
-
-import java.math.BigDecimal;
-import java.util.Arrays;
-import java.util.List;
-
-import javax.jdo.Query;
-
-import org.apache.jdo.tck.JDO_Test;
-import org.apache.jdo.tck.pc.company.CompanyModelReader;
-import org.apache.jdo.tck.pc.company.FullTimeEmployee;
-import org.apache.jdo.tck.pc.company.Person;
-import org.apache.jdo.tck.query.QueryTest;
-import org.apache.jdo.tck.query.result.classes.FullName;
-import org.apache.jdo.tck.util.BatchTestRunner;
-
-/**
- *<B>Title:</B> Change Query.
- *<BR>
- *<B>Keywords:</B> query
- *<BR>
- *<B>Assertion ID:</B> A14.5-15.
- *<BR>
- *<B>Assertion Description: </B>
- * The Query instance returned from this method can be modified
- * by the application, just like any other Query instance.
- */
-public class ChangeQuery extends QueryTest {
-
- /** */
- private static final String ASSERTION_FAILED =
- "Assertion A14.5-15 (ChangeQuery) 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(ChangeQuery.class);
- }
-
- /** */
- public void testPositive() {
- Query query = getPM().newNamedQuery(Person.class, "changeQuery");
-
- // change query
- query.setResult("firstname, lastname");
- query.setResultClass(FullName.class);
- query.setClass(FullTimeEmployee.class);
- String filter = "salary > 1000 & projects.contains(p) & " +
- "p.budget > limit";
- query.setFilter(filter);
- String imports = "import org.apache.jdo.tck.pc.company.Project; " +
- "import java.math.BigDecimal;";
- query.declareImports(imports);
- query.declareVariables("Project p");
- query.declareParameters("BigDecimal limit");
- query.setOrdering("personid ASCENDING");
- query.setRange(0, 5);
- String singleStringQuery =
- "SELECT firstname, lastname INTO FullName FROM FullTimeEmployee " +
- "WHERE salary > 1000 & projects.contains(p) & " +
- "p.budget > limit " +
- "VARIABLES Project p PARAMETERS BigDecimal limit " +
- "ORDER BY personid ASCENDING RANGE 0, 5";
-
- // query parameters
- Object[] parameters = {new BigDecimal("2000")};
- // expected result
- List expectedResult = Arrays.asList(new Object[] {
- new FullName("emp1First", "emp1Last"),
- new FullName("emp2First", "emp2Last"),
- new FullName("emp5First", "emp5Last")});
-
- // execute query
- executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery, true,
- parameters, expectedResult, true);
- }
-
- /**
- * @see JDO_Test#localSetUp()
- */
- protected void localSetUp() {
- addTearDownClass(CompanyModelReader.getTearDownClasses());
- loadAndPersistCompanyModel(getPM());
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.api;
+
+import java.math.BigDecimal;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.jdo.Query;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.company.CompanyModelReader;
+import org.apache.jdo.tck.pc.company.FullTimeEmployee;
+import org.apache.jdo.tck.pc.company.Person;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.query.result.classes.FullName;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Change Query.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.5-15.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * The Query instance returned from this method can be modified
+ * by the application, just like any other Query instance.
+ */
+public class ChangeQuery extends QueryTest {
+
+ /** */
+ private static final String ASSERTION_FAILED =
+ "Assertion A14.5-15 (ChangeQuery) 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(ChangeQuery.class);
+ }
+
+ /** */
+ public void testPositive() {
+ Query query = getPM().newNamedQuery(Person.class, "changeQuery");
+
+ // change query
+ query.setResult("DISTINCT firstname, lastname");
+ query.setResultClass(FullName.class);
+ query.setClass(FullTimeEmployee.class);
+ String filter = "salary > 1000 & projects.contains(p) & " +
+ "p.budget > limit";
+ query.setFilter(filter);
+ String imports = "import org.apache.jdo.tck.pc.company.Project; " +
+ "import java.math.BigDecimal;";
+ query.declareImports(imports);
+ query.declareVariables("Project p");
+ query.declareParameters("BigDecimal limit");
+ query.setOrdering("firstname ASCENDING, lastname ASCENDING");
+ query.setRange(0, 5);
+ String singleStringQuery =
+ "SELECT DISTINCT firstname, lastname " +
+ "INTO FullName FROM FullTimeEmployee " +
+ "WHERE salary > 1000 & projects.contains(p) & " +
+ "p.budget > limit " +
+ "VARIABLES Project p PARAMETERS BigDecimal limit " +
+ "ORDER BY firstname ASCENDING, lastname ASCENDING RANGE 0, 5";
+
+ // query parameters
+ Object[] parameters = {new BigDecimal("2000")};
+ // expected result
+ List expectedResult = Arrays.asList(new Object[] {
+ new FullName("emp1First", "emp1Last"),
+ new FullName("emp2First", "emp2Last"),
+ new FullName("emp5First", "emp5Last")});
+
+ // execute query
+ executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery, true,
+ parameters, expectedResult, true);
+ }
+
+ /**
+ * @see JDO_Test#localSetUp()
+ */
+ protected void localSetUp() {
+ addTearDownClass(CompanyModelReader.getTearDownClasses());
+ loadAndPersistCompanyModel(getPM());
+ }
+}
diff --git a/tck20/src/java/org/apache/jdo/tck/query/jdoql/parameters/ImplicitParameters.java b/tck20/src/java/org/apache/jdo/tck/query/jdoql/parameters/ImplicitParameters.java
index ab10934..7f0b620 100644
--- a/tck20/src/java/org/apache/jdo/tck/query/jdoql/parameters/ImplicitParameters.java
+++ b/tck20/src/java/org/apache/jdo/tck/query/jdoql/parameters/ImplicitParameters.java
@@ -1,185 +1,186 @@
-/*
- * 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.parameters;
-
-import java.util.Arrays;
-import java.util.List;
-
-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> Implicit parameters.
- *<BR>
- *<B>Keywords:</B> query
- *<BR>
- *<B>Assertion ID:</B> A14.6.3-3.
- *<BR>
- *<B>Assertion Description: </B>
- * Parameters implicitly declared (in the result, filter, grouping, ordering,
- * or range) are identified by prepending a ":" to the parameter
- * everywhere it appears. All parameter types can be determined
- * by one of the following techniques:
- */
-public class ImplicitParameters extends QueryTest {
-
- /** */
- private static final String ASSERTION_FAILED =
- "Assertion A14.6.3-3 (ImplicitParameters) 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*/ "this, :param",
- /*INTO*/ null,
- /*FROM*/ Person.class,
- /*EXCLUDE*/ null,
- /*WHERE*/ null,
- /*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 == :param",
- /*VARIABLES*/ null,
- /*PARAMETERS*/ null,
- /*IMPORTS*/ null,
- /*GROUP BY*/ null,
- /*ORDER BY*/ null,
- /*FROM*/ null,
- /*TO*/ null),
- new QueryElementHolder(
- /*UNIQUE*/ null,
- /*RESULT*/ "department.name",
- /*INTO*/ null,
- /*FROM*/ Employee.class,
- /*EXCLUDE*/ null,
- /*WHERE*/ null,
- /*VARIABLES*/ null,
- /*PARAMETERS*/ null,
- /*IMPORTS*/ null,
- /*GROUP BY*/ "department.name HAVING COUNT(this) >= :min",
- /*ORDER BY*/ null,
- /*FROM*/ null,
- /*TO*/ null),
- new QueryElementHolder(
- /*UNIQUE*/ null,
- /*RESULT*/ null,
- /*INTO*/ null,
- /*FROM*/ Person.class,
- /*EXCLUDE*/ null,
- /*WHERE*/ null,
- /*VARIABLES*/ null,
- /*PARAMETERS*/ null,
- /*IMPORTS*/ null,
- /*GROUP BY*/ null,
- /*ORDER BY*/ null,
- /*FROM*/ ":zero",
- /*TO*/ ":five")
- };
-
- private static String parameter = "parameterInResult";
-
- /**
- * The expected results of valid queries.
- */
- private Object[] expectedResult = {
- getExpectedResultOfFirstQuery(
- getTransientCompanyModelInstancesAsList(new String[] {
- "emp1", "emp2", "emp3", "emp4", "emp5"})),
- getTransientCompanyModelInstancesAsList(new String[]{"emp1"}),
- /* Note: "Development" is not a bean name! */
- Arrays.asList(new Object[]{"Development"}),
- getTransientCompanyModelInstancesAsList(new String[] {
- "emp1", "emp2", "emp3", "emp4", "emp5"})
- };
-
- /**
- * 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(ImplicitParameters.class);
- }
-
- /** */
- public void testResult() {
- int index = 0;
- executeQuery(index, new Object[] {parameter});
- }
-
- /** */
- public void testFilter() {
- int index = 1;
- executeQuery(index, new Object[] {"emp1First"});
- }
-
- /** */
- public void testGrouping() {
- int index = 2;
- executeQuery(index, new Object[] {new Long(3)});
- }
-
- /** */
- public void testRange() {
- int index = 3;
- executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index],
- new Object[] {new Long(0), new Long(5)}, expectedResult[index]);
- }
-
- /**
- * @see JDO_Test#localSetUp()
- */
- protected void localSetUp() {
- addTearDownClass(CompanyModelReader.getTearDownClasses());
- loadAndPersistCompanyModel(getPM());
- }
-
- /** */
- private void executeQuery(int index, Object[] parameters) {
- executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index],
- parameters, expectedResult[index]);
- executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index],
- parameters, expectedResult[index]);
- }
-
- private List getExpectedResultOfFirstQuery(List instances) {
- Object[] expectedResult = new Object[instances.size()];
- for (int i = 0; i < expectedResult.length; i++) {
- expectedResult[i] = new Object[] {instances.get(i), parameter};
- }
- return Arrays.asList(expectedResult);
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.parameters;
+
+import java.util.Arrays;
+import java.util.List;
+
+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> Implicit parameters.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.3-3.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * Parameters implicitly declared (in the result, filter, grouping, ordering,
+ * or range) are identified by prepending a ":" to the parameter
+ * everywhere it appears. All parameter types can be determined
+ * by one of the following techniques:
+ */
+public class ImplicitParameters extends QueryTest {
+
+ /** */
+ private static final String ASSERTION_FAILED =
+ "Assertion A14.6.3-3 (ImplicitParameters) 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*/ "this, :param",
+ /*INTO*/ null,
+ /*FROM*/ Person.class,
+ /*EXCLUDE*/ null,
+ /*WHERE*/ null,
+ /*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 == :param",
+ /*VARIABLES*/ null,
+ /*PARAMETERS*/ null,
+ /*IMPORTS*/ null,
+ /*GROUP BY*/ null,
+ /*ORDER BY*/ null,
+ /*FROM*/ null,
+ /*TO*/ null),
+ new QueryElementHolder(
+ /*UNIQUE*/ null,
+ /*RESULT*/ "department.name",
+ /*INTO*/ null,
+ /*FROM*/ Employee.class,
+ /*EXCLUDE*/ null,
+ /*WHERE*/ null,
+ /*VARIABLES*/ null,
+ /*PARAMETERS*/ null,
+ /*IMPORTS*/ null,
+ /*GROUP BY*/ "department.name HAVING COUNT(this) >= :minValue",
+ /*ORDER BY*/ null,
+ /*FROM*/ null,
+ /*TO*/ null),
+ new QueryElementHolder(
+ /*UNIQUE*/ null,
+ /*RESULT*/ null,
+ /*INTO*/ null,
+ /*FROM*/ Person.class,
+ /*EXCLUDE*/ null,
+ /*WHERE*/ null,
+ /*VARIABLES*/ null,
+ /*PARAMETERS*/ null,
+ /*IMPORTS*/ null,
+ /*GROUP BY*/ null,
+ /*ORDER BY*/ null,
+ /*FROM*/ ":zero",
+ /*TO*/ ":five")
+ };
+
+ private static String parameter = "parameterInResult";
+
+ /**
+ * The expected results of valid queries.
+ */
+ private Object[] expectedResult = {
+ getExpectedResultOfFirstQuery(
+ getTransientCompanyModelInstancesAsList(new String[] {
+ "emp1", "emp2", "emp3", "emp4", "emp5"})),
+ getTransientCompanyModelInstancesAsList(new String[]{"emp1"}),
+ /* Note: "Development" is not a bean name! */
+ Arrays.asList(new Object[]{"Development"}),
+ getTransientCompanyModelInstancesAsList(new String[] {
+ "emp1", "emp2", "emp3", "emp4", "emp5"})
+ };
+
+ /**
+ * 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(ImplicitParameters.class);
+ }
+
+ /** */
+ public void testResult() {
+ int index = 0;
+ executeQuery(index, new Object[] {parameter});
+ }
+
+ /** */
+ public void testFilter() {
+ int index = 1;
+ executeQuery(index, new Object[] {"emp1First"});
+ }
+
+ /** */
+ public void testGrouping() {
+ int index = 2;
+ executeQuery(index, new Object[] {new Long(3)});
+ }
+
+ /** */
+ public void testRange() {
+ int index = 3;
+ executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index],
+ new Object[] {new Long(0), new Long(5)}, expectedResult[index]);
+ }
+
+ /**
+ * @see JDO_Test#localSetUp()
+ */
+ protected void localSetUp() {
+ addTearDownClass(CompanyModelReader.getTearDownClasses());
+ loadAndPersistCompanyModel(getPM());
+ }
+
+ /** */
+ private void executeQuery(int index, Object[] parameters) {
+ executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index],
+ parameters, expectedResult[index]);
+ executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index],
+ parameters, expectedResult[index]);
+ }
+
+ private List getExpectedResultOfFirstQuery(List instances) {
+ Object[] expectedResult = new Object[instances.size()];
+ for (int i = 0; i < expectedResult.length; i++) {
+ expectedResult[i] = new Object[] {instances.get(i), parameter};
+ }
+ return Arrays.asList(expectedResult);
+ }
+}
diff --git a/tck20/src/java/org/apache/jdo/tck/query/result/ResultClassRequirements.java b/tck20/src/java/org/apache/jdo/tck/query/result/ResultClassRequirements.java
index 6c1ff78..1792980 100644
--- a/tck20/src/java/org/apache/jdo/tck/query/result/ResultClassRequirements.java
+++ b/tck20/src/java/org/apache/jdo/tck/query/result/ResultClassRequirements.java
@@ -1,477 +1,478 @@
-/*
- * 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.result;
-
-import java.math.BigDecimal;
-import java.util.Arrays;
-import java.util.Map;
-
-import org.apache.jdo.tck.JDO_Test;
-import org.apache.jdo.tck.pc.company.CompanyModelReader;
-import org.apache.jdo.tck.pc.company.FullTimeEmployee;
-import org.apache.jdo.tck.pc.company.Project;
-import org.apache.jdo.tck.query.QueryElementHolder;
-import org.apache.jdo.tck.query.QueryTest;
-import org.apache.jdo.tck.query.result.classes.LongString;
-import org.apache.jdo.tck.query.result.classes.MissingNoArgsConstructor;
-import org.apache.jdo.tck.query.result.classes.NoFieldsNoMethods;
-import org.apache.jdo.tck.query.result.classes.PublicLongField;
-import org.apache.jdo.tck.query.result.classes.PublicPutMethod;
-import org.apache.jdo.tck.util.BatchTestRunner;
-import org.apache.jdo.tck.util.ConversionHelper;
-
-/**
- *<B>Title:</B> Result Class Requirements.
- *<BR>
- *<B>Keywords:</B> query
- *<BR>
- *<B>Assertion ID:</B> A14.6.12-1.
- *<BR>
- *<B>Assertion Description: </B>
- * The result class may be one of the java.lang classes ...
- */
-public class ResultClassRequirements extends QueryTest {
-
- /** */
- private static final String ASSERTION_FAILED =
- "Assertion A14.6.12-1 (ResultClassRequirements) failed: ";
-
- /**
- * The array of valid queries which may be executed as
- * single string queries and as API queries.
- */
- private static final QueryElementHolder[] VALID_QUERIES = {
- // Long
- new QueryElementHolder(
- /*UNIQUE*/ null,
- /*RESULT*/ "personid",
- /*INTO*/ Long.class,
- /*FROM*/ FullTimeEmployee.class,
- /*EXCLUDE*/ null,
- /*WHERE*/ null,
- /*VARIABLES*/ null,
- /*PARAMETERS*/ null,
- /*IMPORTS*/ null,
- /*GROUP BY*/ null,
- /*ORDER BY*/ null,
- /*FROM*/ null,
- /*TO*/ null),
-
- // Double
- new QueryElementHolder(
- /*UNIQUE*/ null,
- /*RESULT*/ "salary",
- /*INTO*/ Double.class,
- /*FROM*/ FullTimeEmployee.class,
- /*EXCLUDE*/ null,
- /*WHERE*/ null,
- /*VARIABLES*/ null,
- /*PARAMETERS*/ null,
- /*IMPORTS*/ null,
- /*GROUP BY*/ null,
- /*ORDER BY*/ null,
- /*FROM*/ null,
- /*TO*/ null),
-
- // BigDecimal
- new QueryElementHolder(
- /*UNIQUE*/ null,
- /*RESULT*/ "budget",
- /*INTO*/ BigDecimal.class,
- /*FROM*/ Project.class,
- /*EXCLUDE*/ null,
- /*WHERE*/ null,
- /*VARIABLES*/ null,
- /*PARAMETERS*/ null,
- /*IMPORTS*/ null,
- /*GROUP BY*/ null,
- /*ORDER BY*/ null,
- /*FROM*/ null,
- /*TO*/ null),
-
- // java.util.Date
- new QueryElementHolder(
- /*UNIQUE*/ null,
- /*RESULT*/ "hiredate",
- /*INTO*/ java.util.Date.class,
- /*FROM*/ FullTimeEmployee.class,
- /*EXCLUDE*/ null,
- /*WHERE*/ null,
- /*VARIABLES*/ null,
- /*PARAMETERS*/ null,
- /*IMPORTS*/ null,
- /*GROUP BY*/ null,
- /*ORDER BY*/ null,
- /*FROM*/ null,
- /*TO*/ null),
-
- // Map
- new QueryElementHolder(
- /*UNIQUE*/ null,
- /*RESULT*/ "personid AS id, lastname AS name",
- /*INTO*/ Map.class,
- /*FROM*/ FullTimeEmployee.class,
- /*EXCLUDE*/ null,
- /*WHERE*/ null,
- /*VARIABLES*/ null,
- /*PARAMETERS*/ null,
- /*IMPORTS*/ null,
- /*GROUP BY*/ null,
- /*ORDER BY*/ null,
- /*FROM*/ null,
- /*TO*/ null),
-
- // user defined result class
- new QueryElementHolder(
- /*UNIQUE*/ null,
- /*RESULT*/ "personid AS l, lastname AS s",
- /*INTO*/ LongString.class,
- /*FROM*/ FullTimeEmployee.class,
- /*EXCLUDE*/ null,
- /*WHERE*/ null,
- /*VARIABLES*/ null,
- /*PARAMETERS*/ null,
- /*IMPORTS*/ null,
- /*GROUP BY*/ null,
- /*ORDER BY*/ null,
- /*FROM*/ null,
- /*TO*/ null),
-
- // constructor
- new QueryElementHolder(
- /*UNIQUE*/ null,
- /*RESULT*/ "new LongString(personid, lastname)",
- /*INTO*/ null,
- /*FROM*/ FullTimeEmployee.class,
- /*EXCLUDE*/ null,
- /*WHERE*/ null,
- /*VARIABLES*/ null,
- /*PARAMETERS*/ null,
- /*IMPORTS*/ "import org.apache.jdo.tck.query.result.classes.LongString;",
- /*GROUP BY*/ null,
- /*ORDER BY*/ null,
- /*FROM*/ null,
- /*TO*/ null),
-
- // constructor without constructor call
- new QueryElementHolder(
- /*UNIQUE*/ null,
- /*RESULT*/ "personid, lastname",
- /*INTO*/ LongString.class,
- /*FROM*/ FullTimeEmployee.class,
- /*EXCLUDE*/ null,
- /*WHERE*/ null,
- /*VARIABLES*/ null,
- /*PARAMETERS*/ null,
- /*IMPORTS*/ null,
- /*GROUP BY*/ null,
- /*ORDER BY*/ null,
- /*FROM*/ null,
- /*TO*/ null),
-
- // public fields
- new QueryElementHolder(
- /*UNIQUE*/ null,
- /*RESULT*/ "personid AS l",
- /*INTO*/ PublicLongField.class,
- /*FROM*/ FullTimeEmployee.class,
- /*EXCLUDE*/ null,
- /*WHERE*/ null,
- /*VARIABLES*/ null,
- /*PARAMETERS*/ null,
- /*IMPORTS*/ null,
- /*GROUP BY*/ null,
- /*ORDER BY*/ null,
- /*FROM*/ null,
- /*TO*/ null),
-
- // public put method
- new QueryElementHolder(
- /*UNIQUE*/ null,
- /*RESULT*/ "personid, lastname",
- /*INTO*/ PublicPutMethod.class,
- /*FROM*/ FullTimeEmployee.class,
- /*EXCLUDE*/ null,
- /*WHERE*/ null,
- /*VARIABLES*/ null,
- /*PARAMETERS*/ null,
- /*IMPORTS*/ null,
- /*GROUP BY*/ null,
- /*ORDER BY*/ null,
- /*FROM*/ null,
- /*TO*/ null)
- };
-
- /**
- * The array of invalid queries which may be executed as
- * single string queries and as API queries.
- */
- private static final QueryElementHolder[] INVALID_QUERIES = {
- // JDK class
- new QueryElementHolder(
- /*UNIQUE*/ null,
- /*RESULT*/ "personid, lastname",
- /*INTO*/ Long.class,
- /*FROM*/ FullTimeEmployee.class,
- /*EXCLUDE*/ null,
- /*WHERE*/ null,
- /*VARIABLES*/ null,
- /*PARAMETERS*/ null,
- /*IMPORTS*/ null,
- /*GROUP BY*/ null,
- /*ORDER BY*/ null,
- /*FROM*/ null,
- /*TO*/ null),
-
- // JDK class, non assignment compatible
- new QueryElementHolder(
- /*UNIQUE*/ null,
- /*RESULT*/ "lastname",
- /*INTO*/ Long.class,
- /*FROM*/ FullTimeEmployee.class,
- /*EXCLUDE*/ null,
- /*WHERE*/ null,
- /*VARIABLES*/ null,
- /*PARAMETERS*/ null,
- /*IMPORTS*/ null,
- /*GROUP BY*/ null,
- /*ORDER BY*/ null,
- /*FROM*/ null,
- /*TO*/ null),
-
- // TCK class, salary field is not assignment compatible
- new QueryElementHolder(
- /*UNIQUE*/ null,
- /*RESULT*/ "personid AS l, salary AS s",
- /*INTO*/ LongString.class,
- /*FROM*/ FullTimeEmployee.class,
- /*EXCLUDE*/ null,
- /*WHERE*/ null,
- /*VARIABLES*/ null,
- /*PARAMETERS*/ null,
- /*IMPORTS*/ null,
- /*GROUP BY*/ null,
- /*ORDER BY*/ null,
- /*FROM*/ null,
- /*TO*/ null),
-
- // TCK class, non existing constructor
- new QueryElementHolder(
- /*UNIQUE*/ null,
- /*RESULT*/ "new LongString(personid)",
- /*INTO*/ null,
- /*FROM*/ FullTimeEmployee.class,
- /*EXCLUDE*/ null,
- /*WHERE*/ null,
- /*VARIABLES*/ null,
- /*PARAMETERS*/ null,
- /*IMPORTS*/ "import org.apache.jdo.tck.query.result.classes.LongString;",
- /*GROUP BY*/ null,
- /*ORDER BY*/ null,
- /*FROM*/ null,
- /*TO*/ null),
-
- // TCK class, no no-args constructor
- new QueryElementHolder(
- /*UNIQUE*/ null,
- /*RESULT*/ "personid",
- /*INTO*/ MissingNoArgsConstructor.class,
- /*FROM*/ FullTimeEmployee.class,
- /*EXCLUDE*/ null,
- /*WHERE*/ null,
- /*VARIABLES*/ null,
- /*PARAMETERS*/ null,
- /*IMPORTS*/ null,
- /*GROUP BY*/ null,
- /*ORDER BY*/ null,
- /*FROM*/ null,
- /*TO*/ null),
-
- // TCK class, no no-args constructor
- new QueryElementHolder(
- /*UNIQUE*/ null,
- /*RESULT*/ "personid",
- /*INTO*/ NoFieldsNoMethods.class,
- /*FROM*/ FullTimeEmployee.class,
- /*EXCLUDE*/ null,
- /*WHERE*/ null,
- /*VARIABLES*/ null,
- /*PARAMETERS*/ null,
- /*IMPORTS*/ null,
- /*GROUP BY*/ null,
- /*ORDER BY*/ null,
- /*FROM*/ null,
- /*TO*/ null),
- };
-
- // Two dimensional arrays to be converted to maps
- // in the expected result.
- private static Object[][] emp1Map =
- {{"id", new Long(1)},
- {"name", "emp1Last"}};
- private static Object[][] emp2Map =
- {{"id", new Long(2)},
- {"name", "emp2Last"}};
- private static Object[][] emp5Map =
- {{"id", new Long(5)},
- {"name", "emp5Last"}};
- private static Object[][] publicPutMethod1 =
- {{"personid", new Long(1)}, {"lastname", "emp1Last"}};
- private static Object[][] publicPutMethod2 =
- {{"personid", new Long(2)}, {"lastname", "emp2Last"}};
- private static Object[][] publicPutMethod5 =
- {{"personid", new Long(5)}, {"lastname", "emp5Last"}};
-
- /**
- * The expected results of valid queries.
- */
- private Object[] expectedResult = {
- // Long
- Arrays.asList(new Object[]{new Long(1), new Long(2), new Long(5)}),
- // Double
- Arrays.asList(new Object[]{
- new Double(20000.0), new Double(10000.0), new Double(45000.0)}),
- // BigDecimal
- Arrays.asList(new Object[]{new BigDecimal("2500000.99"),
- new BigDecimal("50000.00"), new BigDecimal("2000.99")}),
- // java.util.Date
- Arrays.asList(new Object[]{
- CompanyModelReader.stringToUtilDate("1/Jan/1999"),
- CompanyModelReader.stringToUtilDate("1/Jul/2003"),
- CompanyModelReader.stringToUtilDate("15/Aug/1998")}),
- // Map
- Arrays.asList(new Object[]{
- ConversionHelper.arrayToMap(emp1Map),
- ConversionHelper.arrayToMap(emp2Map),
- ConversionHelper.arrayToMap(emp5Map)}),
- // user defined result class
- Arrays.asList(new Object[]{
- new LongString(1, "emp1Last"),
- new LongString(2, "emp2Last"),
- new LongString(5, "emp5Last")}),
- // constructor
- Arrays.asList(new Object[]{
- new LongString(1, "emp1Last"),
- new LongString(2, "emp2Last"),
- new LongString(5, "emp5Last")}),
- // constructor without constructor call
- Arrays.asList(new Object[]{
- new LongString(1, "emp1Last"),
- new LongString(2, "emp2Last"),
- new LongString(5, "emp5Last")}),
- // public fields
- Arrays.asList(new Object[]{
- new PublicLongField(1),
- new PublicLongField(2),
- new PublicLongField(5)}),
- // public put method
- Arrays.asList(new Object[]{
- new PublicPutMethod(ConversionHelper.arrayToMap(publicPutMethod1)),
- new PublicPutMethod(ConversionHelper.arrayToMap(publicPutMethod2)),
- new PublicPutMethod(ConversionHelper.arrayToMap(publicPutMethod5))})
- };
-
- /**
- * 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(ResultClassRequirements.class);
- }
-
- /** */
- public void testLong() {
- int index = 0;
- executeQuery(index);
- }
-
- /** */
- public void testDouble() {
- int index = 1;
- executeQuery(index);
- }
-
- /** */
- public void testBigDecimal() {
- int index = 2;
- executeQuery(index);
- }
-
- /** */
- public void testDate() {
- int index = 3;
- executeQuery(index);
- }
-
- /** */
- public void testMap() {
- int index = 4;
- executeQuery(index);
- }
-
- /** */
- public void testUserDefinedResultClass() {
- int index = 5;
- executeQuery(index);
- }
-
- /** */
- public void testConstructor() {
- int index = 6;
- executeQuery(index);
- index++;
- executeQuery(index);
- }
-
- /** */
- public void testFields() {
- int index = 8;
- executeQuery(index);
- }
-
- /** */
- public void testPut() {
- int index = 9;
- executeQuery(index);
- }
-
- /** */
- 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);
- }
- }
-
- /** */
- private void executeQuery(int index) {
- executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index],
- expectedResult[index]);
- executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index],
- expectedResult[index]);
- }
-
- /**
- * @see JDO_Test#localSetUp()
- */
- protected void localSetUp() {
- addTearDownClass(CompanyModelReader.getTearDownClasses());
- loadAndPersistCompanyModel(getPM());
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.result;
+
+import java.math.BigDecimal;
+import java.util.Arrays;
+import java.util.Map;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.company.CompanyModelReader;
+import org.apache.jdo.tck.pc.company.FullTimeEmployee;
+import org.apache.jdo.tck.pc.company.Project;
+import org.apache.jdo.tck.query.QueryElementHolder;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.query.result.classes.LongString;
+import org.apache.jdo.tck.query.result.classes.MissingNoArgsConstructor;
+import org.apache.jdo.tck.query.result.classes.NoFieldsNoMethods;
+import org.apache.jdo.tck.query.result.classes.PublicLongField;
+import org.apache.jdo.tck.query.result.classes.PublicPutMethod;
+import org.apache.jdo.tck.util.BatchTestRunner;
+import org.apache.jdo.tck.util.ConversionHelper;
+
+/**
+ *<B>Title:</B> Result Class Requirements.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.12-1.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * The result class may be one of the java.lang classes ...
+ */
+public class ResultClassRequirements extends QueryTest {
+
+ /** */
+ private static final String ASSERTION_FAILED =
+ "Assertion A14.6.12-1 (ResultClassRequirements) failed: ";
+
+ /**
+ * The array of valid queries which may be executed as
+ * single string queries and as API queries.
+ */
+ private static final QueryElementHolder[] VALID_QUERIES = {
+ // Long
+ new QueryElementHolder(
+ /*UNIQUE*/ null,
+ /*RESULT*/ "personid",
+ /*INTO*/ Long.class,
+ /*FROM*/ FullTimeEmployee.class,
+ /*EXCLUDE*/ null,
+ /*WHERE*/ null,
+ /*VARIABLES*/ null,
+ /*PARAMETERS*/ null,
+ /*IMPORTS*/ null,
+ /*GROUP BY*/ null,
+ /*ORDER BY*/ null,
+ /*FROM*/ null,
+ /*TO*/ null),
+
+ // Double
+ new QueryElementHolder(
+ /*UNIQUE*/ null,
+ /*RESULT*/ "salary",
+ /*INTO*/ Double.class,
+ /*FROM*/ FullTimeEmployee.class,
+ /*EXCLUDE*/ null,
+ /*WHERE*/ null,
+ /*VARIABLES*/ null,
+ /*PARAMETERS*/ null,
+ /*IMPORTS*/ null,
+ /*GROUP BY*/ null,
+ /*ORDER BY*/ null,
+ /*FROM*/ null,
+ /*TO*/ null),
+
+ // BigDecimal
+ new QueryElementHolder(
+ /*UNIQUE*/ null,
+ /*RESULT*/ "budget",
+ /*INTO*/ BigDecimal.class,
+ /*FROM*/ Project.class,
+ /*EXCLUDE*/ null,
+ /*WHERE*/ null,
+ /*VARIABLES*/ null,
+ /*PARAMETERS*/ null,
+ /*IMPORTS*/ null,
+ /*GROUP BY*/ null,
+ /*ORDER BY*/ null,
+ /*FROM*/ null,
+ /*TO*/ null),
+
+ // java.util.Date
+ new QueryElementHolder(
+ /*UNIQUE*/ null,
+ /*RESULT*/ "hiredate",
+ /*INTO*/ java.util.Date.class,
+ /*FROM*/ FullTimeEmployee.class,
+ /*EXCLUDE*/ null,
+ /*WHERE*/ null,
+ /*VARIABLES*/ null,
+ /*PARAMETERS*/ null,
+ /*IMPORTS*/ null,
+ /*GROUP BY*/ null,
+ /*ORDER BY*/ null,
+ /*FROM*/ null,
+ /*TO*/ null),
+
+ // Map
+ new QueryElementHolder(
+ /*UNIQUE*/ null,
+ /*RESULT*/ "personid AS id, lastname AS name",
+ /*INTO*/ Map.class,
+ /*FROM*/ FullTimeEmployee.class,
+ /*EXCLUDE*/ null,
+ /*WHERE*/ null,
+ /*VARIABLES*/ null,
+ /*PARAMETERS*/ null,
+ /*IMPORTS*/ null,
+ /*GROUP BY*/ null,
+ /*ORDER BY*/ null,
+ /*FROM*/ null,
+ /*TO*/ null),
+
+ // user defined result class
+ new QueryElementHolder(
+ /*UNIQUE*/ null,
+ /*RESULT*/ "personid AS l, lastname AS s",
+ /*INTO*/ LongString.class,
+ /*FROM*/ FullTimeEmployee.class,
+ /*EXCLUDE*/ null,
+ /*WHERE*/ null,
+ /*VARIABLES*/ null,
+ /*PARAMETERS*/ null,
+ /*IMPORTS*/ null,
+ /*GROUP BY*/ null,
+ /*ORDER BY*/ null,
+ /*FROM*/ null,
+ /*TO*/ null),
+
+ // constructor
+ new QueryElementHolder(
+ /*UNIQUE*/ null,
+ /*RESULT*/ "new LongString(personid, lastname)",
+ /*INTO*/ null,
+ /*FROM*/ FullTimeEmployee.class,
+ /*EXCLUDE*/ null,
+ /*WHERE*/ null,
+ /*VARIABLES*/ null,
+ /*PARAMETERS*/ null,
+ /*IMPORTS*/ "import org.apache.jdo.tck.query.result.classes.LongString;",
+ /*GROUP BY*/ null,
+ /*ORDER BY*/ null,
+ /*FROM*/ null,
+ /*TO*/ null),
+
+ // constructor without constructor call
+ new QueryElementHolder(
+ /*UNIQUE*/ null,
+ /*RESULT*/ "personid, lastname",
+ /*INTO*/ LongString.class,
+ /*FROM*/ FullTimeEmployee.class,
+ /*EXCLUDE*/ null,
+ /*WHERE*/ null,
+ /*VARIABLES*/ null,
+ /*PARAMETERS*/ null,
+ /*IMPORTS*/ null,
+ /*GROUP BY*/ null,
+ /*ORDER BY*/ null,
+ /*FROM*/ null,
+ /*TO*/ null),
+
+ // public fields
+ new QueryElementHolder(
+ /*UNIQUE*/ null,
+ /*RESULT*/ "personid AS l",
+ /*INTO*/ PublicLongField.class,
+ /*FROM*/ FullTimeEmployee.class,
+ /*EXCLUDE*/ null,
+ /*WHERE*/ null,
+ /*VARIABLES*/ null,
+ /*PARAMETERS*/ null,
+ /*IMPORTS*/ null,
+ /*GROUP BY*/ null,
+ /*ORDER BY*/ null,
+ /*FROM*/ null,
+ /*TO*/ null),
+
+ // public put method
+ new QueryElementHolder(
+ /*UNIQUE*/ null,
+ /*RESULT*/ "personid, lastname",
+ /*INTO*/ PublicPutMethod.class,
+ /*FROM*/ FullTimeEmployee.class,
+ /*EXCLUDE*/ null,
+ /*WHERE*/ null,
+ /*VARIABLES*/ null,
+ /*PARAMETERS*/ null,
+ /*IMPORTS*/ null,
+ /*GROUP BY*/ null,
+ /*ORDER BY*/ null,
+ /*FROM*/ null,
+ /*TO*/ null)
+ };
+
+ /**
+ * The array of invalid queries which may be executed as
+ * single string queries and as API queries.
+ */
+ private static final QueryElementHolder[] INVALID_QUERIES = {
+ // JDK class
+ new QueryElementHolder(
+ /*UNIQUE*/ null,
+ /*RESULT*/ "personid, lastname",
+ /*INTO*/ Long.class,
+ /*FROM*/ FullTimeEmployee.class,
+ /*EXCLUDE*/ null,
+ /*WHERE*/ null,
+ /*VARIABLES*/ null,
+ /*PARAMETERS*/ null,
+ /*IMPORTS*/ null,
+ /*GROUP BY*/ null,
+ /*ORDER BY*/ null,
+ /*FROM*/ null,
+ /*TO*/ null),
+
+ // JDK class, non assignment compatible
+ new QueryElementHolder(
+ /*UNIQUE*/ null,
+ /*RESULT*/ "this",
+ /*INTO*/ Long.class,
+ /*FROM*/ FullTimeEmployee.class,
+ /*EXCLUDE*/ null,
+ /*WHERE*/ null,
+ /*VARIABLES*/ null,
+ /*PARAMETERS*/ null,
+ /*IMPORTS*/ null,
+ /*GROUP BY*/ null,
+ /*ORDER BY*/ null,
+ /*FROM*/ null,
+ /*TO*/ null),
+
+ // TCK class, salary field is not assignment compatible
+ new QueryElementHolder(
+ /*UNIQUE*/ null,
+ /*RESULT*/ "personid AS l, salary AS s",
+ /*INTO*/ LongString.class,
+ /*FROM*/ FullTimeEmployee.class,
+ /*EXCLUDE*/ null,
+ /*WHERE*/ null,
+ /*VARIABLES*/ null,
+ /*PARAMETERS*/ null,
+ /*IMPORTS*/ null,
+ /*GROUP BY*/ null,
+ /*ORDER BY*/ null,
+ /*FROM*/ null,
+ /*TO*/ null),
+
+ // TCK class, non existing constructor
+ new QueryElementHolder(
+ /*UNIQUE*/ null,
+ /*RESULT*/ "new LongString(personid)",
+ /*INTO*/ null,
+ /*FROM*/ FullTimeEmployee.class,
+ /*EXCLUDE*/ null,
+ /*WHERE*/ null,
+ /*VARIABLES*/ null,
+ /*PARAMETERS*/ null,
+ /*IMPORTS*/ "import org.apache.jdo.tck.query.result.classes.LongString;",
+ /*GROUP BY*/ null,
+ /*ORDER BY*/ null,
+ /*FROM*/ null,
+ /*TO*/ null),
+
+ // TCK class, no no-args constructor
+ new QueryElementHolder(
+ /*UNIQUE*/ null,
+ /*RESULT*/ "personid",
+ /*INTO*/ MissingNoArgsConstructor.class,
+ /*FROM*/ FullTimeEmployee.class,
+ /*EXCLUDE*/ null,
+ /*WHERE*/ null,
+ /*VARIABLES*/ null,
+ /*PARAMETERS*/ null,
+ /*IMPORTS*/ null,
+ /*GROUP BY*/ null,
+ /*ORDER BY*/ null,
+ /*FROM*/ null,
+ /*TO*/ null),
+
+ // TCK class, no no-args constructor
+ new QueryElementHolder(
+ /*UNIQUE*/ null,
+ /*RESULT*/ "personid",
+ /*INTO*/ NoFieldsNoMethods.class,
+ /*FROM*/ FullTimeEmployee.class,
+ /*EXCLUDE*/ null,
+ /*WHERE*/ null,
+ /*VARIABLES*/ null,
+ /*PARAMETERS*/ null,
+ /*IMPORTS*/ null,
+ /*GROUP BY*/ null,
+ /*ORDER BY*/ null,
+ /*FROM*/ null,
+ /*TO*/ null),
+ };
+
+ // Two dimensional arrays to be converted to maps
+ // in the expected result.
+ private static Object[][] emp1Map =
+ {{"id", new Long(1)},
+ {"name", "emp1Last"}};
+ private static Object[][] emp2Map =
+ {{"id", new Long(2)},
+ {"name", "emp2Last"}};
+ private static Object[][] emp5Map =
+ {{"id", new Long(5)},
+ {"name", "emp5Last"}};
+ private static Object[][] publicPutMethod1 =
+ {{"personid", new Long(1)}, {"lastname", "emp1Last"}};
+ private static Object[][] publicPutMethod2 =
+ {{"personid", new Long(2)}, {"lastname", "emp2Last"}};
+ private static Object[][] publicPutMethod5 =
+ {{"personid", new Long(5)}, {"lastname", "emp5Last"}};
+
+ /**
+ * The expected results of valid queries.
+ */
+ private Object[] expectedResult = {
+ // Long
+ Arrays.asList(new Object[]{new Long(1), new Long(2), new Long(5)}),
+ // Double
+ Arrays.asList(new Object[]{
+ new Double(20000.0), new Double(10000.0), new Double(45000.0)}),
+ // BigDecimal
+ Arrays.asList(new Object[]{new BigDecimal("2500000.99"),
+ new BigDecimal("50000.00"), new BigDecimal("2000.99")}),
+ // java.util.Date
+ Arrays.asList(new Object[]{
+ CompanyModelReader.stringToUtilDate("1/Jan/1999"),
+ CompanyModelReader.stringToUtilDate("1/Jul/2003"),
+ CompanyModelReader.stringToUtilDate("15/Aug/1998")}),
+ // Map
+ Arrays.asList(new Object[]{
+ ConversionHelper.arrayToMap(emp1Map),
+ ConversionHelper.arrayToMap(emp2Map),
+ ConversionHelper.arrayToMap(emp5Map)}),
+ // user defined result class
+ Arrays.asList(new Object[]{
+ new LongString(1, "emp1Last"),
+ new LongString(2, "emp2Last"),
+ new LongString(5, "emp5Last")}),
+ // constructor
+ Arrays.asList(new Object[]{
+ new LongString(1, "emp1Last"),
+ new LongString(2, "emp2Last"),
+ new LongString(5, "emp5Last")}),
+ // constructor without constructor call
+ Arrays.asList(new Object[]{
+ new LongString(1, "emp1Last"),
+ new LongString(2, "emp2Last"),
+ new LongString(5, "emp5Last")}),
+ // public fields
+ Arrays.asList(new Object[]{
+ new PublicLongField(1),
+ new PublicLongField(2),
+ new PublicLongField(5)}),
+ // public put method
+ Arrays.asList(new Object[]{
+ new PublicPutMethod(ConversionHelper.arrayToMap(publicPutMethod1)),
+ new PublicPutMethod(ConversionHelper.arrayToMap(publicPutMethod2)),
+ new PublicPutMethod(ConversionHelper.arrayToMap(publicPutMethod5))})
+ };
+
+ /**
+ * 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(ResultClassRequirements.class);
+ }
+
+ /** */
+ public void testLong() {
+ int index = 0;
+ executeQuery(index);
+ }
+
+ /** */
+ public void testDouble() {
+ int index = 1;
+ executeQuery(index);
+ }
+
+ /** */
+ public void testBigDecimal() {
+ int index = 2;
+ executeQuery(index);
+ }
+
+ /** */
+ public void testDate() {
+ int index = 3;
+ executeQuery(index);
+ }
+
+ /** */
+ public void testMap() {
+ int index = 4;
+ executeQuery(index);
+ }
+
+ /** */
+ public void testUserDefinedResultClass() {
+ int index = 5;
+ executeQuery(index);
+ }
+
+ /** */
+ public void testConstructor() {
+ int index = 6;
+ executeQuery(index);
+ index++;
+ executeQuery(index);
+ }
+
+ /** */
+ public void testFields() {
+ int index = 8;
+ executeQuery(index);
+ }
+
+ /** */
+ public void testPut() {
+ int index = 9;
+ executeQuery(index);
+ }
+
+ /** */
+ 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);
+ }
+ }
+
+ /** */
+ private void executeQuery(int index) {
+ executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index],
+ expectedResult[index]);
+ executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index],
+ expectedResult[index]);
+ }
+
+ /**
+ * @see JDO_Test#localSetUp()
+ */
+ protected void localSetUp() {
+ addTearDownClass(CompanyModelReader.getTearDownClasses());
+ loadAndPersistCompanyModel(getPM());
+ }
+}