db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c..@apache.org
Subject svn commit: r383417 - in /db/jdo/trunk/tck20/src/java/org/apache/jdo/tck: ./ api/persistencemanager/fetchplan/
Date Sun, 05 Mar 2006 22:11:15 GMT
Author: clr
Date: Sun Mar  5 14:11:11 2006
New Revision: 383417

URL: http://svn.apache.org/viewcvs?rev=383417&view=rev
Log:
JDO-294 Added test for FetchPlan interface

Added:
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/AbstractFetchPlanTest.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanInterface.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanMakeTransient.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanQuery.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanRefresh.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanRetrieve.java
Modified:
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/JDO_Test.java

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/JDO_Test.java
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/JDO_Test.java?rev=383417&r1=383416&r2=383417&view=diff
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/JDO_Test.java (original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/JDO_Test.java Sun Mar  5 14:11:11 2006
@@ -904,4 +904,45 @@
         }
         return isTestToBePerformed;
     }
+    
+    /** New line.
+     */
+    public static final String NL = System.getProperty("line.separator");
+    
+    /** A buffer of of error messages.
+     */
+    protected static StringBuffer messages;
+    
+    /** Appends to error messages.
+     */
+    protected static synchronized void appendMessage(String message) {
+        if (messages == null) {
+            messages = new StringBuffer(NL);
+        }
+        messages.append(message);
+        messages.append(NL);
+    }
+    
+    /**
+     * Returns collected error messages, or <code>null</code> if there
+     * are none, and clears the buffer.
+     */
+    protected static synchronized String retrieveMessages() {
+        if (messages == null) {
+            return null;
+        }
+        final String msg = messages.toString();
+        messages = null;
+        return msg;
+    }
+
+    /** 
+     * Fail the test if there are any error messages.
+     */
+    protected void failOnError() {
+        String errors = retrieveMessages();
+        if (errors != null) {
+            fail (errors);
+        }
+    }
 }

Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/AbstractFetchPlanTest.java
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/AbstractFetchPlanTest.java?rev=383417&view=auto
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/AbstractFetchPlanTest.java
(added)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/AbstractFetchPlanTest.java
Sun Mar  5 14:11:11 2006
@@ -0,0 +1,145 @@
+/*
+ * 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.Collection;
+import java.util.HashSet;
+
+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;
+
+/**
+ * This class is an abstract superclass for the fetch plan tests.
+ * It contains methods useful for testing the behavior of the
+ * fetch plan.
+ */
+
+public class AbstractFetchPlanTest extends JDO_Test {
+
+    /**
+     * The <code>main</code> method is not defined in this abstract class.
+     */
+
+    /** The persistent instances used in the test.
+     */
+    protected PCPoint upperLeft;
+    protected PCPoint lowerRight;
+    protected PCRect pcrect;
+
+    /** The oids of the persistent instances used in the test.
+     */
+    protected Object upperLeftoid;
+    protected Object lowerRightoid;
+    protected Object pcrectoid;
+
+    /** The String arrays used for setting fetch groups.
+     */
+    protected String[] defaultGroup = new String[]
+        {"default"};
+    protected String[] upperLeftGroup = new String[]
+        {"default", "PCRect.upperLeft"};
+    protected String[] lowerRightGroup = new String[]
+        {"default", "PCRect.lowerRight"};
+    protected String[] bothGroup = new String[]{
+        "default", "PCRect.upperLeft", "PCRect.lowerRight"};
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        addTearDownClass(PCRect.class);
+        addTearDownClass(PCPoint.class);
+        upperLeft = new PCPoint(0,10);
+        lowerRight = new PCPoint(10,0);
+        pcrect = new PCRect(upperLeft, lowerRight);
+        getPM().currentTransaction().begin();
+        pm.makePersistent(pcrect); // makes all three persistent
+        upperLeftoid = pm.getObjectId(upperLeft);
+        lowerRightoid = pm.getObjectId(lowerRight);
+        pcrectoid = pm.getObjectId(pcrect);
+        pm.currentTransaction().commit();
+    }
+
+    /** Set the default plus upper left field as the fetch group.
+     */
+    protected void setDefaultGroup() {
+        FetchPlan fp = getPM().getFetchPlan();
+        fp.setGroups(defaultGroup);
+    }
+
+    /** Set the default plus upper left field as the fetch group.
+     */
+    protected void setUpperLeftGroup() {
+        FetchPlan fp = getPM().getFetchPlan();
+        fp.setGroups(upperLeftGroup);
+    }
+
+    /** Set the default plus lower right field as the fetch group.
+     */
+    protected void setLowerRightGroup() {
+        FetchPlan fp = getPM().getFetchPlan();
+        fp.setGroups(upperLeftGroup);
+    }
+
+    /** Set the default plus both fields as the fetch group.
+     */
+    protected void setBothGroup() {
+        FetchPlan fp = getPM().getFetchPlan();
+        fp.setGroups(bothGroup);
+    }
+
+    /** */
+    protected void checkBothLoaded(String location, PCRect pcrect) {
+        checkUpperLeftLoaded(location, pcrect);
+        checkLowerRightLoaded(location, pcrect);
+    }
+
+    /** */
+    protected void checkUpperLeftLoaded(String location, PCRect pcrect) {
+        if (pcrect.upperLeft == null) {
+            appendMessage(location + NL + "Upper Left was null." + NL +
+                "The fetch plan includes PCRect.upperLeft and this field" +
+                " should have been loaded.");
+        }
+    }
+
+    /** */
+    protected void checkLowerRightLoaded(String location, PCRect pcrect) {
+        if (pcrect.lowerRight == null) {
+            appendMessage(location + NL + "Lower Right was null." + NL +
+                "The fetch plan includes PCRect.lowerRight and this field" +
+                " should have been loaded.");
+        }
+    }
+    protected void checkGroups(String location, 
+            FetchPlan fetchPlan, String[] groups) {
+        Collection expected = new HashSet();
+        Collection actual = fetchPlan.getGroups();
+        for (int i = 0; i < groups.length; ++i) {
+            expected.add(groups[i]);
+        }
+        if (!expected.equals(actual)) {
+            appendMessage(location + NL + "Fetch groups differ." + NL +
+                "expected: " + expected + NL +
+                "actual: " + actual + NL);
+        }
+    }
+}
\ No newline at end of file

Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanInterface.java
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanInterface.java?rev=383417&view=auto
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanInterface.java
(added)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanInterface.java
Sun Mar  5 14:11:11 2006
@@ -0,0 +1,376 @@
+/*
+ * 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.5-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.5-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

Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanMakeTransient.java
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanMakeTransient.java?rev=383417&view=auto
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanMakeTransient.java
(added)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanMakeTransient.java
Sun Mar  5 14:11:11 2006
@@ -0,0 +1,94 @@
+/*
+ * 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.Collection;
+import java.util.HashSet;
+
+import org.apache.jdo.tck.api.persistencemanager.fetchplan.AbstractFetchPlanTest;
+
+import org.apache.jdo.tck.pc.mylib.PCRect;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Test FetchPlanMakeTransient
+ *<BR>
+ *<B>Keywords:</B> FetchPlan makeTransient
+ *<BR>
+ *<B>Assertion IDs:</B> Assertion 12.7.1
+ *<BR>
+ *<B>Assertion Description: </B>
+If the useFetchPlan parameter is true, the current FetchPlan, 
+including MaxFetchDepth, DETACH_LOAD_FIELDS, and DETACH_UNLOAD_FIELDS, 
+is applied to the pc or pcs parameter instance(s) to load fields 
+and instances from the datastore. The DetachmentRoots is not affected. 
+After the fetch plan is used to load instances, the entire graph 
+of instances reachable via loaded fields of the parameter instances 
+is made transient. Transient fields are not modified by the method. 
+ */
+
+public class FetchPlanMakeTransient extends AbstractFetchPlanTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion 12.7.1 (FetchPlanMakeTransient) 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(FetchPlanMakeTransient.class);
+    }
+    
+    /** */
+    public void testMakeTransientAllCollection() {
+        setBothGroup();
+        pm.currentTransaction().begin();
+        PCRect instance = (PCRect)pm.getObjectById(pcrectoid, false);
+        Collection instances = new HashSet();
+        instances.add(instance);
+        pm.makeTransientAll(instances, true);
+        checkBothLoaded(ASSERTION_FAILED, instance);
+        pm.currentTransaction().commit();
+        failOnError();
+    }
+
+    /** */
+    public void testMakeTransientAllArray() {
+        setBothGroup();
+        pm.currentTransaction().begin();
+        PCRect instance = (PCRect)pm.getObjectById(pcrectoid, false);
+        pm.makeTransientAll(new Object[]{instance}, true);
+        checkBothLoaded(ASSERTION_FAILED, instance);
+        pm.currentTransaction().commit();
+        failOnError();
+    }
+
+    /** */
+    public void testMakeTransient() {
+        setBothGroup();
+        pm.currentTransaction().begin();
+        PCRect instance = (PCRect)pm.getObjectById(pcrectoid, false);
+        pm.makeTransient(instance, true);
+        checkBothLoaded(ASSERTION_FAILED, instance);
+        pm.currentTransaction().commit();
+        failOnError();
+    }
+}
\ No newline at end of file

Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanQuery.java
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanQuery.java?rev=383417&view=auto
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanQuery.java
(added)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanQuery.java
Sun Mar  5 14:11:11 2006
@@ -0,0 +1,69 @@
+/*
+ * 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 javax.jdo.FetchPlan;
+import javax.jdo.Query;
+
+import org.apache.jdo.tck.api.persistencemanager.fetchplan.AbstractFetchPlanTest;
+
+import org.apache.jdo.tck.pc.mylib.PCRect;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Test FetchPlanQuery
+ *<BR>
+ *<B>Keywords:</B> FetchPlan Query
+ *<BR>
+ *<B>Assertion IDs:</B> Assertion 12.7.1
+ *<BR>
+ *<B>Assertion Description: </B>
+12.7.1 When executing a query the JDO implementation loads the fields 
+as specified in the fetch plan associated with the Query instance. 
+ */
+
+public class FetchPlanQuery extends AbstractFetchPlanTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion 12.7.1 (FetchPlanQuery) 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(FetchPlanQuery.class);
+    }
+    
+    /** */
+    public void testQuery() {
+        setBothGroup();
+        pm.currentTransaction().begin();
+        Query query = pm.newQuery(PCRect.class);
+        checkGroups(ASSERTION_FAILED + "after newQuery().getFetchPlan() ", 
+                query.getFetchPlan(), bothGroup);
+        query.setUnique(true);
+        PCRect instance = (PCRect)query.execute();
+        checkBothLoaded(ASSERTION_FAILED, instance);
+        pm.currentTransaction().commit();
+        failOnError();
+    }
+
+}
\ No newline at end of file

Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanRefresh.java
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanRefresh.java?rev=383417&view=auto
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanRefresh.java
(added)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanRefresh.java
Sun Mar  5 14:11:11 2006
@@ -0,0 +1,63 @@
+/*
+ * 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 org.apache.jdo.tck.api.persistencemanager.fetchplan.AbstractFetchPlanTest;
+
+import org.apache.jdo.tck.pc.mylib.PCRect;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Test FetchPlanRefresh
+ *<BR>
+ *<B>Keywords:</B> FetchPlan getObjectById
+ *<BR>
+ *<B>Assertion IDs:</B> Assertion 12.7.1
+ *<BR>
+ *<B>Assertion Description: </B>
+12.7.1 For refresh, after clearing fields in the instances, 
+the JDO implementation uses the fetch plan to determine 
+which fields to load from the datastore. 
+ */
+
+public class FetchPlanRefresh extends AbstractFetchPlanTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion 12.7.1 (FetchPlanRefresh) 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(FetchPlanRefresh.class);
+    }
+    
+    /** */
+    public void testRefresh() {
+        setBothGroup();
+        pm.currentTransaction().begin();
+        PCRect instance = (PCRect)pm.getObjectById(pcrectoid, false);
+        pm.refresh(instance);
+        checkBothLoaded(ASSERTION_FAILED, instance);
+        pm.currentTransaction().commit();
+        failOnError();
+    }
+}
\ No newline at end of file

Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanRetrieve.java
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanRetrieve.java?rev=383417&view=auto
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanRetrieve.java
(added)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanRetrieve.java
Sun Mar  5 14:11:11 2006
@@ -0,0 +1,64 @@
+/*
+ * 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 org.apache.jdo.tck.api.persistencemanager.fetchplan.AbstractFetchPlanTest;
+
+import org.apache.jdo.tck.pc.mylib.PCRect;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Test FetchPlanRetrieve
+ *<BR>
+ *<B>Keywords:</B> FetchPlan getObjectById
+ *<BR>
+ *<B>Assertion IDs:</B> Assertion 12.7.1
+ *<BR>
+ *<B>Assertion Description: </B>
+12.7.1 For retrieve with FGonly true, the implementation uses the fetch plan to 
+determine which fields are loaded from the datastore. With FGonly false, the 
+implementation reverts to JDO 1 behavior, which loads all fields from the 
+datastore; in this case, no related instances are loaded. 
+ */
+
+public class FetchPlanRetrieve extends AbstractFetchPlanTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion 12.7.1 (FetchPlanRetrieve) 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(FetchPlanRetrieve.class);
+    }
+    
+    /** */
+    public void testRetrieve() {
+        setBothGroup();
+        pm.currentTransaction().begin();
+        PCRect instance = (PCRect)pm.getObjectById(pcrectoid, false);
+        pm.retrieve(instance, true);
+        checkBothLoaded(ASSERTION_FAILED, instance);
+        pm.currentTransaction().commit();
+        failOnError();
+    }
+}
\ No newline at end of file



Mime
View raw message