db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c..@apache.org
Subject svn commit: r386502 - in /db/jdo/trunk/tck20/src: conf/ java/org/apache/jdo/tck/lifecycle/ java/org/apache/jdo/tck/lifecycle/nontransactional/
Date Fri, 17 Mar 2006 01:13:14 GMT
Author: clr
Date: Thu Mar 16 17:13:10 2006
New Revision: 386502

URL: http://svn.apache.org/viewcvs?rev=386502&view=rev
Log:
JDO-259 Added new NontransactionalWrite tests; removed the old test

Added:
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteDatastoreCommit.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteDatastoreCommitConflict.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteDatastoreRollback.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticCommit.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticCommitConflict.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticRollback.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteTest.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteThrows.java
Removed:
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/nontransactional/
Modified:
    db/jdo/trunk/tck20/src/conf/lifecycle.conf

Modified: db/jdo/trunk/tck20/src/conf/lifecycle.conf
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/src/conf/lifecycle.conf?rev=386502&r1=386501&r2=386502&view=diff
==============================================================================
--- db/jdo/trunk/tck20/src/conf/lifecycle.conf (original)
+++ db/jdo/trunk/tck20/src/conf/lifecycle.conf Thu Mar 16 17:13:10 2006
@@ -7,10 +7,16 @@
 jdo.tck.classes = \
 org.apache.jdo.tck.lifecycle.HollowInstanceMaintainsPK \
 org.apache.jdo.tck.lifecycle.MultiplePMsReturnInstancesRepresentingSamePC \
+org.apache.jdo.tck.lifecycle.NontransactionalWriteThrows \
+org.apache.jdo.tck.lifecycle.NontransactionalWriteDatastoreRollback \
+org.apache.jdo.tck.lifecycle.NontransactionalWriteDatastoreCommit \
+org.apache.jdo.tck.lifecycle.NontransactionalWriteDatastoreCommitConflict \
+org.apache.jdo.tck.lifecycle.NontransactionalWriteOptimisticRollback \
+org.apache.jdo.tck.lifecycle.NontransactionalWriteOptimisticCommit \
+org.apache.jdo.tck.lifecycle.NontransactionalWriteOptimisticCommitConflict \
 org.apache.jdo.tck.lifecycle.ObjectIdNotModifiedWhenObjectIdInstanceModified \
 org.apache.jdo.tck.lifecycle.PMReturnsIdenticalInstancesForEqualObjIds \
 org.apache.jdo.tck.lifecycle.PMsCanSharePCClassesButNotPCInstances \
 org.apache.jdo.tck.lifecycle.StateTransitions \
 org.apache.jdo.tck.lifecycle.TransientTransactionalStateCommit \
-org.apache.jdo.tck.lifecycle.TransientTransactionalStateRollback \
-org.apache.jdo.tck.lifecycle.nontransactional.ModificationOfNontransactionalInstanceOutsideTransaction
+org.apache.jdo.tck.lifecycle.TransientTransactionalStateRollback 

Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteDatastoreCommit.java
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteDatastoreCommit.java?rev=386502&view=auto
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteDatastoreCommit.java
(added)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteDatastoreCommit.java
Thu Mar 16 17:13:10 2006
@@ -0,0 +1,90 @@
+/*
+ * 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.lifecycle;
+
+import javax.jdo.JDOUnsupportedOptionException;
+import javax.jdo.PersistenceManager;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.lifecycle.nontransactional.*;
+
+import org.apache.jdo.tck.pc.mylib.VersionedPCPoint;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Test NontransactionalWriteDatastoreCommit
+ *<BR>
+ *<B>Keywords:</B> NontransactionalWrite datastore commit
+ *<BR>
+ *<B>Assertion ID:</B> A5.6.2-4, A5.6.2-6, A5.6.2-8, A5.6.2-10.
+ *<BR>
+ *<B>Assertion Description: </B>
+A5.6.2-4 [If a datastore transaction is begun, commit will write 
+the changes to the datastore with no checking as to 
+the current state of the instances in the datastore. 
+That is, the changes made outside the transaction 
+together with any changes made inside the transaction 
+will overwrite the current state of the datastore.] 
+
+A5.6.2-6 [If a datastore transaction is begun, rollback will not write 
+any changes to the datastore.] 
+
+A5.6.2-8 [If an optimistic transaction is begun, commit will write 
+the changes to the datastore after checking as to the current state 
+of the instances in the datastore. The changes made outside 
+the transaction together with any changes made inside the transaction 
+will update the current state of the datastore if the version 
+checking is successful.] 
+
+A5.6.2-10 [If an optimistic transaction is begun, rollback will not write 
+any changes to the datastore. The persistent-nontransactional-dirty 
+instances will transition according to the RestoreValues flag. ] 
+ */
+
+public class NontransactionalWriteDatastoreCommit 
+        extends NontransactionalWriteTest {
+
+    /** */
+    protected static final String ASSERTION_FAILED = 
+        "Assertion A5.6.2-4 (NontransactionalWriteDatastoreCommit) 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(NontransactionalWriteDatastoreCommit.class);
+    }
+
+    /** 
+     * Create a nontransactional dirty instance, begin and commit 
+     * a datastore transaction, and check that the instance in 
+     * the datastore has the value as changed by the transaction.
+     */
+    public void testDatastoreCommit() {
+        if (!checkNontransactionalFeaturesSupported(false)) 
+            return;
+        createAndModifyVersionedPCPoint();
+        beginAndCommitTransaction(false);
+        checkXValue(ASSERTION_FAILED + "after datastore commit",
+                newXValue);
+        failOnError();
+    }
+
+}
\ No newline at end of file

Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteDatastoreCommitConflict.java
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteDatastoreCommitConflict.java?rev=386502&view=auto
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteDatastoreCommitConflict.java
(added)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteDatastoreCommitConflict.java
Thu Mar 16 17:13:10 2006
@@ -0,0 +1,92 @@
+/*
+ * 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.lifecycle;
+
+import javax.jdo.JDOUnsupportedOptionException;
+import javax.jdo.PersistenceManager;
+
+import org.apache.jdo.tck.JDO_Test;
+
+import org.apache.jdo.tck.pc.mylib.VersionedPCPoint;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Test NontransactionalWriteDatastoreCommitConflict
+ *<BR>
+ *<B>Keywords:</B> NontransactionalWrite datastore commit
+ *<BR>
+ *<B>Assertion ID:</B> A5.6.2-4, A5.6.2-6, A5.6.2-8, A5.6.2-10.
+ *<BR>
+ *<B>Assertion Description: </B>
+A5.6.2-4 [If a datastore transaction is begun, commit will write 
+the changes to the datastore with no checking as to 
+the current state of the instances in the datastore. 
+That is, the changes made outside the transaction 
+together with any changes made inside the transaction 
+will overwrite the current state of the datastore.] 
+
+A5.6.2-6 [If a datastore transaction is begun, rollback will not write 
+any changes to the datastore.] 
+
+A5.6.2-8 [If an optimistic transaction is begun, commit will write 
+the changes to the datastore after checking as to the current state 
+of the instances in the datastore. The changes made outside 
+the transaction together with any changes made inside the transaction 
+will update the current state of the datastore if the version 
+checking is successful.] 
+
+A5.6.2-10 [If an optimistic transaction is begun, rollback will not write 
+any changes to the datastore. The persistent-nontransactional-dirty 
+instances will transition according to the RestoreValues flag. ] 
+ */
+
+public class NontransactionalWriteDatastoreCommitConflict 
+        extends NontransactionalWriteTest {
+
+    /** */
+    protected static final String ASSERTION_FAILED = 
+        "Assertion A5.6.2-4 " +
+            "(NontransactionalWriteDatastoreCommitConflict) 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(NontransactionalWriteDatastoreCommitConflict.class);
+    }
+
+    /** 
+     * Create a nontransactional dirty instance, begin and commit
+     * a conflicting transaction, begin and commit a datastore
+     * transaction, and check that the instance in the datastore
+     * was overwritten by this datastore transaction.
+     */
+    public void testDatastoreCommitConflict() {
+        if (!checkNontransactionalFeaturesSupported(false)) 
+            return;
+        createAndModifyVersionedPCPoint();
+        conflictingUpdate();
+        beginAndCommitTransaction(false);
+        checkXValue(ASSERTION_FAILED + "after datastore commit with conflict",
+                newXValue);
+        failOnError();
+    }
+
+}
\ No newline at end of file

Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteDatastoreRollback.java
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteDatastoreRollback.java?rev=386502&view=auto
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteDatastoreRollback.java
(added)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteDatastoreRollback.java
Thu Mar 16 17:13:10 2006
@@ -0,0 +1,89 @@
+/*
+ * 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.lifecycle;
+
+import javax.jdo.JDOUnsupportedOptionException;
+import javax.jdo.PersistenceManager;
+
+import org.apache.jdo.tck.JDO_Test;
+
+import org.apache.jdo.tck.pc.mylib.VersionedPCPoint;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Test NontransactionalWriteDatastoreRollback
+ *<BR>
+ *<B>Keywords:</B> NontransactionalWrite datastore rollback
+ *<BR>
+ *<B>Assertion ID:</B> A5.6.2-4, A5.6.2-6, A5.6.2-8, A5.6.2-10.
+ *<BR>
+ *<B>Assertion Description: </B>
+A5.6.2-4 [If a datastore transaction is begun, commit will write 
+the changes to the datastore with no checking as to 
+the current state of the instances in the datastore. 
+That is, the changes made outside the transaction 
+together with any changes made inside the transaction 
+will overwrite the current state of the datastore.] 
+
+A5.6.2-6 [If a datastore transaction is begun, rollback will not write 
+any changes to the datastore.] 
+
+A5.6.2-8 [If an optimistic transaction is begun, commit will write 
+the changes to the datastore after checking as to the current state 
+of the instances in the datastore. The changes made outside 
+the transaction together with any changes made inside the transaction 
+will update the current state of the datastore if the version 
+checking is successful.] 
+
+A5.6.2-10 [If an optimistic transaction is begun, rollback will not write 
+any changes to the datastore. The persistent-nontransactional-dirty 
+instances will transition according to the RestoreValues flag. ] 
+ */
+
+public class NontransactionalWriteDatastoreRollback 
+        extends NontransactionalWriteTest {
+
+    /** */
+    protected static final String ASSERTION_FAILED = 
+        "Assertion A5.6.2-6 (NontransactionalWriteDatastoreRollback) 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(NontransactionalWriteDatastoreRollback.class);
+    }
+
+    /** 
+     * Create a nontransactional dirty instance, begin and rollback
+     * a datastore transaction, and check that the instance in
+     * the datastore has the original value.
+     */
+    public void testDatastoreRollback() {
+        if (!checkNontransactionalFeaturesSupported(false)) 
+            return;
+        createAndModifyVersionedPCPoint();
+        beginAndRollbackTransaction(false);
+        checkXValue(ASSERTION_FAILED + "after datastore rollback",
+                originalXValue);
+        failOnError();
+    }
+
+}
\ No newline at end of file

Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticCommit.java
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticCommit.java?rev=386502&view=auto
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticCommit.java
(added)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticCommit.java
Thu Mar 16 17:13:10 2006
@@ -0,0 +1,89 @@
+/*
+ * 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.lifecycle;
+
+import javax.jdo.JDOUnsupportedOptionException;
+import javax.jdo.PersistenceManager;
+
+import org.apache.jdo.tck.JDO_Test;
+
+import org.apache.jdo.tck.pc.mylib.VersionedPCPoint;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> TestNontransactionalWriteOptimisticCommit
+ *<BR>
+ *<B>Keywords:</B> NontransactionalWrite optimistic commit
+ *<BR>
+ *<B>Assertion ID:</B> A5.6.2-4, A5.6.2-6, A5.6.2-8, A5.6.2-10.
+ *<BR>
+ *<B>Assertion Description: </B>
+A5.6.2-4 [If a datastore transaction is begun, commit will write 
+the changes to the datastore with no checking as to 
+the current state of the instances in the datastore. 
+That is, the changes made outside the transaction 
+together with any changes made inside the transaction 
+will overwrite the current state of the datastore.] 
+
+A5.6.2-6 [If a datastore transaction is begun, rollback will not write 
+any changes to the datastore.] 
+
+A5.6.2-8 [If an optimistic transaction is begun, commit will write 
+the changes to the datastore after checking as to the current state 
+of the instances in the datastore. The changes made outside 
+the transaction together with any changes made inside the transaction 
+will update the current state of the datastore if the version 
+checking is successful.] 
+
+A5.6.2-10 [If an optimistic transaction is begun, rollback will not write 
+any changes to the datastore. The persistent-nontransactional-dirty 
+instances will transition according to the RestoreValues flag. ] 
+ */
+
+public class NontransactionalWriteOptimisticCommit 
+        extends NontransactionalWriteTest {
+
+    /** */
+    protected static final String ASSERTION_FAILED = 
+        "Assertion A5.6.2-8 (NontransactionalWriteOptimisticCommit) 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(NontransactionalWriteOptimisticCommit.class);
+    }
+
+    /** 
+     * Create a nontransactional dirty instance, begin and commit 
+     * an optimistic transaction, and check that the instance in 
+     * the datastore has the value as changed by the transaction.
+     */
+    public void testOptimisticCommit() {
+        if (!checkNontransactionalFeaturesSupported(true)) 
+            return;
+        createAndModifyVersionedPCPoint();
+        beginAndCommitTransaction(true);
+        checkXValue(ASSERTION_FAILED + "after optimistic commit",
+                newXValue);
+        failOnError();
+    }
+
+}
\ No newline at end of file

Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticCommitConflict.java
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticCommitConflict.java?rev=386502&view=auto
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticCommitConflict.java
(added)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticCommitConflict.java
Thu Mar 16 17:13:10 2006
@@ -0,0 +1,93 @@
+/*
+ * 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.lifecycle;
+
+import javax.jdo.JDOUnsupportedOptionException;
+import javax.jdo.PersistenceManager;
+
+import org.apache.jdo.tck.JDO_Test;
+
+import org.apache.jdo.tck.pc.mylib.VersionedPCPoint;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Test NontransactionalWriteOptimisticCommitConflict
+ *<BR>
+ *<B>Keywords:</B> NontransactionalWrite optimistic
+ *<BR>
+ *<B>Assertion ID:</B> A5.6.2-4, A5.6.2-6, A5.6.2-8, A5.6.2-10.
+ *<BR>
+ *<B>Assertion Description: </B>
+A5.6.2-4 [If a datastore transaction is begun, commit will write 
+the changes to the datastore with no checking as to 
+the current state of the instances in the datastore. 
+That is, the changes made outside the transaction 
+together with any changes made inside the transaction 
+will overwrite the current state of the datastore.] 
+
+A5.6.2-6 [If a datastore transaction is begun, rollback will not write 
+any changes to the datastore.] 
+
+A5.6.2-8 [If an optimistic transaction is begun, commit will write 
+the changes to the datastore after checking as to the current state 
+of the instances in the datastore. The changes made outside 
+the transaction together with any changes made inside the transaction 
+will update the current state of the datastore if the version 
+checking is successful.] 
+
+A5.6.2-10 [If an optimistic transaction is begun, rollback will not write 
+any changes to the datastore. The persistent-nontransactional-dirty 
+instances will transition according to the RestoreValues flag. ] 
+ */
+
+public class NontransactionalWriteOptimisticCommitConflict 
+        extends NontransactionalWriteTest {
+
+    /** */
+    protected static final String ASSERTION_FAILED = 
+        "Assertion A5.6.2-8 " +
+            "(NontransactionalWriteOptimisticCommitConflict) 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
+                (NontransactionalWriteOptimisticCommitConflict.class);
+    }
+
+    /** 
+     * Create a nontransactional dirty instance, begin and commit
+     * a conflicting transaction, begin and commit an optimistic
+     * transaction and check that the instance in the datastore
+     * has the value as changed by the conflicting transaction.
+     */
+    public void testOptimisticCommitConflict() {
+        if (!checkNontransactionalFeaturesSupported(true)) 
+            return;
+        createAndModifyVersionedPCPoint();
+        conflictingUpdate();
+        beginAndCommitTransactionFails(true);
+        checkXValue(ASSERTION_FAILED + "after optimistic commit with conflict",
+                conflictXValue);
+        failOnError();
+    }
+
+}
\ No newline at end of file

Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticRollback.java
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticRollback.java?rev=386502&view=auto
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticRollback.java
(added)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticRollback.java
Thu Mar 16 17:13:10 2006
@@ -0,0 +1,89 @@
+/*
+ * 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.lifecycle;
+
+import javax.jdo.JDOUnsupportedOptionException;
+import javax.jdo.PersistenceManager;
+
+import org.apache.jdo.tck.JDO_Test;
+
+import org.apache.jdo.tck.pc.mylib.VersionedPCPoint;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Test NontransactionalWriteOptimisticRollback
+ *<BR>
+ *<B>Keywords:</B> NontransactionalWrite optimistic rollback
+ *<BR>
+ *<B>Assertion ID:</B> A5.6.2-4, A5.6.2-6, A5.6.2-8, A5.6.2-10.
+ *<BR>
+ *<B>Assertion Description: </B>
+A5.6.2-4 [If a datastore transaction is begun, commit will write 
+the changes to the datastore with no checking as to 
+the current state of the instances in the datastore. 
+That is, the changes made outside the transaction 
+together with any changes made inside the transaction 
+will overwrite the current state of the datastore.] 
+
+A5.6.2-6 [If a datastore transaction is begun, rollback will not write 
+any changes to the datastore.] 
+
+A5.6.2-8 [If an optimistic transaction is begun, commit will write 
+the changes to the datastore after checking as to the current state 
+of the instances in the datastore. The changes made outside 
+the transaction together with any changes made inside the transaction 
+will update the current state of the datastore if the version 
+checking is successful.] 
+
+A5.6.2-10 [If an optimistic transaction is begun, rollback will not write 
+any changes to the datastore. The persistent-nontransactional-dirty 
+instances will transition according to the RestoreValues flag. ] 
+ */
+
+public class NontransactionalWriteOptimisticRollback 
+        extends NontransactionalWriteTest {
+
+    /** */
+    protected static final String ASSERTION_FAILED = 
+        "Assertion A5.6.2-10 (NontransactionalWriteOptimisticRollback) 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(NontransactionalWriteOptimisticRollback.class);
+    }
+
+    /** 
+     * Create a nontransactional dirty instance, begin and rollback
+     * a transaction, and check that the instance in the datastore
+     * has not been changed.
+     */
+    public void testOptimisticRollback() {
+        if (!checkNontransactionalFeaturesSupported(true)) 
+            return;
+        createAndModifyVersionedPCPoint();
+        beginAndRollbackTransaction(true);
+        checkXValue(ASSERTION_FAILED + "after optimistic rollback",
+                originalXValue);
+        failOnError();
+    }
+
+}
\ No newline at end of file

Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteTest.java
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteTest.java?rev=386502&view=auto
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteTest.java
(added)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteTest.java
Thu Mar 16 17:13:10 2006
@@ -0,0 +1,264 @@
+/*
+ * 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.lifecycle;
+
+import javax.jdo.JDOOptimisticVerificationException;
+import javax.jdo.JDOUnsupportedOptionException;
+
+import javax.jdo.PersistenceManager;
+
+import org.apache.jdo.tck.JDO_Test;
+
+import org.apache.jdo.tck.pc.mylib.VersionedPCPoint;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Test NontransactionalWrite
+ *<BR>
+ *<B>Keywords:</B> NontransactionalWrite
+ *<BR>
+ *<B>Assertion ID:</B> A5.6.2-4, A5.6.2-6, A5.6.2-8, A5.6.2-10.
+ *<BR>
+ *<B>Assertion Description: </B>
+A5.6.2-4 [If a datastore transaction is begun, commit will write 
+the changes to the datastore with no checking as to 
+the current state of the instances in the datastore. 
+That is, the changes made outside the transaction 
+together with any changes made inside the transaction 
+will overwrite the current state of the datastore.] 
+
+A5.6.2-6 [If a datastore transaction is begun, rollback will not write 
+any changes to the datastore.] 
+
+A5.6.2-8 [If an optimistic transaction is begun, commit will write 
+the changes to the datastore after checking as to the current state 
+of the instances in the datastore. The changes made outside 
+the transaction together with any changes made inside the transaction 
+will update the current state of the datastore if the version 
+checking is successful.] 
+
+A5.6.2-10 [If an optimistic transaction is begun, rollback will not write 
+any changes to the datastore. The persistent-nontransactional-dirty 
+instances will transition according to the RestoreValues flag. ] 
+ */
+
+public class NontransactionalWriteTest extends JDO_Test {
+
+    /** */
+    protected static final String ASSERTION_FAILED = 
+        "Assertion A5.6.2-4 (NontransactionalWriteTest) 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(NontransactionalWriteTest.class);
+    }
+
+    /** 
+     * The ObjectId of the pc instance, set by method
+     * createAndModifyInstance. 
+     */ 
+    protected Object oid;
+
+    /**
+     * The original value of the X field of the pc instance, 
+     * set by method createAndModifyInstance. 
+     */
+    protected int originalXValue = 100;
+    protected int newXValue = 999;
+    protected int conflictXValue = 555;
+
+    /**
+     * Create a new VersionedPCPoint instance,modify its X value,
+     * and store its oid in the test class oid. The persistence manager
+     * referenced by the pm field (in the superclass) manages the
+     * nontransactional dirty instance.
+     * This method is only executed if the
+     * JDO implementation supports the required features, otherwise
+     * this method would be localSetUp.
+     */
+    protected VersionedPCPoint createAndModifyVersionedPCPoint() {
+        addTearDownClass(VersionedPCPoint.class);
+        getPM().currentTransaction().begin();
+        pm.currentTransaction().setNontransactionalWrite(true);
+        pm.currentTransaction().setNontransactionalRead(true);
+        pm.currentTransaction().setRetainValues(true);
+        VersionedPCPoint instance =  new VersionedPCPoint(originalXValue, 200);
+        oid = pm.getObjectId(instance);
+        pm.currentTransaction().commit();
+        instance.setX(newXValue);
+        return instance;
+    }
+
+    /** 
+     * Begin and rollback a transaction using the persistence manager
+     * that manages the nontransactional dirty instance. 
+     * @param optimistic use optimistic transaction
+     */
+    protected void beginAndRollbackTransaction(boolean optimistic) {
+        getPM().currentTransaction().setOptimistic(optimistic);
+        pm.currentTransaction().begin();
+        pm.currentTransaction().rollback();
+    }
+
+    /** 
+     * Begin and commit a transaction using the persistence manager
+     * that manages the nontransactional dirty instance. 
+     * @param optimistic use optimistic transaction
+     */
+    protected void beginAndCommitTransaction(boolean optimistic) {
+        getPM().currentTransaction().setOptimistic(optimistic);
+        pm.currentTransaction().begin();
+        pm.currentTransaction().commit();
+    }
+
+    /** 
+     * Begin and commit a transaction using the persistence manager
+     * that manages the nontransactional dirty instance. This 
+     * transaction must fail due to a conflicting update.
+     * @param optimistic use optimistic transaction
+     */
+    protected void beginAndCommitTransactionFails(boolean optimistic) {
+        getPM().currentTransaction().setOptimistic(optimistic);
+        pm.currentTransaction().begin();
+        try {
+            pm.currentTransaction().commit();
+        } catch (JDOOptimisticVerificationException ex) {
+            // good catch; return
+            return;
+        }
+        appendMessage(ASSERTION_FAILED + "transaction succeeded but" +
+                " should not succeed.");
+    }
+
+    /**
+     * Check the x value of the persistent instance referenced 
+     * by the oid. Use a new persistence manager and check the
+     * value in a new transaction so there is no interference 
+     * with the persistence manager that managed the nontransactional
+     * dirty instance.
+     */
+    protected void checkXValue(String location, int expectedXValue) {
+        PersistenceManager pmCheck = pmf.getPersistenceManager();
+        pmCheck.currentTransaction().begin();
+        VersionedPCPoint instance = 
+                (VersionedPCPoint)pmCheck.getObjectById(oid, true);
+        int actualXValue = instance.getX();
+        pmCheck.currentTransaction().commit();
+        cleanupPM(pmCheck);
+        if (expectedXValue != actualXValue) {
+            appendMessage(location + NL + 
+                    "expected: " + expectedXValue + NL +
+                    "  actual: " + actualXValue);
+        }
+    }
+
+    /**
+     * Perform a conflicting transaction that updates the same field
+     * as the nontransactional dirty instance. The field value is
+     * conflictXValue. This conflicting transaction uses a new 
+     * persistence manager.
+     */
+    protected void conflictingUpdate() {
+        PersistenceManager pmConflict = pmf.getPersistenceManager();
+        pmConflict.currentTransaction().setOptimistic(false);
+        VersionedPCPoint instance = 
+                (VersionedPCPoint)pmConflict.getObjectById(oid);
+        instance.setX(conflictXValue);
+        pmConflict.currentTransaction().commit();
+        cleanupPM(pmConflict);
+    }
+
+    /** 
+     * Check that all Nontransactional features are supported.
+     * @param optimistic check for whether Optimistic is supported as well.
+     */
+    protected boolean checkNontransactionalFeaturesSupported
+            (boolean optimistic) {
+        if (!checkNontransactionalWriteSupported()
+                || !checkNontransactionalReadSupported()
+                || !checkRetainValuesSupported()) 
+            return false;
+        if (optimistic) {
+            if (!checkOptimisticSupported()) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * Check if NontransactionalWrite is supported, and log a debug
+     * message if it is not.
+     */
+    protected boolean checkNontransactionalWriteSupported() {
+        if (!isNontransactionalWriteSupported()) {
+            printUnsupportedOptionalFeatureNotTested(
+                    getClass().getName(), 
+                    "javax.jdo.option.NontransactionalWrite");
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Check if NontransactionalRead is supported, and log a debug
+     * message if it is not.
+     */
+    protected boolean checkNontransactionalReadSupported() {
+        if (!isNontransactionalReadSupported()) {
+            printUnsupportedOptionalFeatureNotTested(
+                    getClass().getName(), 
+                    "javax.jdo.option.NontransactionalRead");
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Check if Optimistic is supported, and log a debug
+     * message if it is not.
+     */
+    protected boolean checkOptimisticSupported() {
+        if (!isOptimisticSupported()) {
+            printUnsupportedOptionalFeatureNotTested(
+                    getClass().getName(), 
+                    "javax.jdo.option.Optimistic");
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Check if RetainValues is supported, and log a debug
+     * message if it is not.
+     */
+    protected boolean checkRetainValuesSupported() {
+        if (!isRetainValuesSupported()) {
+            printUnsupportedOptionalFeatureNotTested(
+                    getClass().getName(), 
+                    "javax.jdo.option.RetainValues");
+            return false;
+        }
+        return true;
+    }
+
+}
\ No newline at end of file

Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteThrows.java
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteThrows.java?rev=386502&view=auto
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteThrows.java
(added)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteThrows.java
Thu Mar 16 17:13:10 2006
@@ -0,0 +1,93 @@
+/*
+ * 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.lifecycle;
+
+import javax.jdo.JDOUnsupportedOptionException;
+import javax.jdo.PersistenceManager;
+
+import org.apache.jdo.tck.JDO_Test;
+
+import org.apache.jdo.tck.pc.mylib.VersionedPCPoint;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Test NontransactionalWriteThrows
+ *<BR>
+ *<B>Keywords:</B> NontransactionalWrite
+ *<BR>
+ *<B>Assertion ID:</B> A5.6.2-4, A5.6.2-6, A5.6.2-8, A5.6.2-10.
+ *<BR>
+ *<B>Assertion Description: </B>
+A5.6.2-4 [If a datastore transaction is begun, commit will write 
+the changes to the datastore with no checking as to 
+the current state of the instances in the datastore. 
+That is, the changes made outside the transaction 
+together with any changes made inside the transaction 
+will overwrite the current state of the datastore.] 
+
+A5.6.2-6 [If a datastore transaction is begun, rollback will not write 
+any changes to the datastore.] 
+
+A5.6.2-8 [If an optimistic transaction is begun, commit will write 
+the changes to the datastore after checking as to the current state 
+of the instances in the datastore. The changes made outside 
+the transaction together with any changes made inside the transaction 
+will update the current state of the datastore if the version 
+checking is successful.] 
+
+A5.6.2-10 [If an optimistic transaction is begun, rollback will not write 
+any changes to the datastore. The persistent-nontransactional-dirty 
+instances will transition according to the RestoreValues flag. ] 
+ */
+
+public class NontransactionalWriteThrows extends NontransactionalWriteTest {
+
+    /** */
+    protected static final String ASSERTION_FAILED = 
+        "Assertion A5.6.2 (NontransactionalWriteThrows) 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(NontransactionalWriteThrows.class);
+    }
+
+    /**
+     * Make sure that if NontransactionalWrite is not supported,
+     * an exception is thrown when setting NontransactionalWrite.
+     */
+    public void testNontransactionalWriteThrows() {
+        if (!checkNontransactionalWriteSupported()) {
+            try {
+                getPM().currentTransaction().setNontransactionalWrite(true);
+            } catch (JDOUnsupportedOptionException ex) {
+                return; // good catch
+            } catch (Exception ex) {
+                // threw wrong exception
+            appendMessage (ASSERTION_FAILED + "threw wrong exception " + ex);
+            }
+            appendMessage (ASSERTION_FAILED + "failed to throw " +
+                    "JDOUnsupportedOptionException");
+        }
+        failOnError();
+    }
+
+}
\ No newline at end of file



Mime
View raw message