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 2005/09/27 10:26:36 UTC

svn commit: r291857 - in /incubator/jdo/trunk/tck20/test: conf/alltests.conf java/org/apache/jdo/tck/transactions/AfterSetRollbackOnlyCommitFails.java java/org/apache/jdo/tck/transactions/GetRollbackOnlyReturnsFalseUntilSet.java

Author: clr
Date: Tue Sep 27 01:26:28 2005
New Revision: 291857

URL: http://svn.apache.org/viewcvs?rev=291857&view=rev
Log:
JDO-140 Add new tests for get/setRollbackOnly

Added:
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/transactions/AfterSetRollbackOnlyCommitFails.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/transactions/GetRollbackOnlyReturnsFalseUntilSet.java
Modified:
    incubator/jdo/trunk/tck20/test/conf/alltests.conf

Modified: incubator/jdo/trunk/tck20/test/conf/alltests.conf
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/conf/alltests.conf?rev=291857&r1=291856&r2=291857&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/conf/alltests.conf (original)
+++ incubator/jdo/trunk/tck20/test/conf/alltests.conf Tue Sep 27 01:26:28 2005
@@ -333,11 +333,13 @@
 org.apache.jdo.tck.query.result.ImmutableQueryResult \
 org.apache.jdo.tck.transactions.AfterCompletionMethodCalledWhenCommitted \
 org.apache.jdo.tck.transactions.AfterCompletionMethodCalledWhenRolledback \
+org.apache.jdo.tck.transactions.AfterSetRollbackOnlyCommitFails \
 org.apache.jdo.tck.transactions.BeforeCompletionMethodCalled \
 org.apache.jdo.tck.transactions.BeforeCompletionMethodNotCalledBeforeRollback \
 org.apache.jdo.tck.transactions.Commit \
 org.apache.jdo.tck.transactions.GetPersistenceManager \
 org.apache.jdo.tck.transactions.GetRetainValues \
+org.apache.jdo.tck.transactions.GetRollbackOnlyReturnsFalseUntilSet \
 org.apache.jdo.tck.transactions.GetSynchronization \
 org.apache.jdo.tck.transactions.IsActive \
 org.apache.jdo.tck.transactions.IsActiveUntilAfterCompletionMethodCalled \

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/transactions/AfterSetRollbackOnlyCommitFails.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/transactions/AfterSetRollbackOnlyCommitFails.java?rev=291857&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/transactions/AfterSetRollbackOnlyCommitFails.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/transactions/AfterSetRollbackOnlyCommitFails.java Tue Sep 27 01:26:28 2005
@@ -0,0 +1,68 @@
+/*
+ * 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.transactions;
+
+import javax.jdo.JDOFatalDataStoreException;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Test AfterSetRollbackOnlyCommitFails
+ *<BR>
+ *<B>Keywords:</B> rollback commit setRollbackOnly
+ *<BR>
+ *<B>Assertion IDs:</B> A13.4.5-1 
+
+ *<BR>
+ *<B>Assertion Description: </B>
+ Once a transaction has been marked for rollback via setRollbackOnly, 
+ the commit method will always fail with JDOFatalDataStoreException. 
+ */
+
+public class AfterSetRollbackOnlyCommitFails extends JDO_Test {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A13.4.5-1 (AfterSetRollbackOnlyCommitFails) 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(AfterSetRollbackOnlyCommitFails.class);
+    }
+
+    /** */
+    public void test() {
+        getPM();
+        Transaction tx = pm.currentTransaction();
+        tx.begin();
+        tx.setRollbackOnly();
+        try {
+            tx.commit();
+            fail(ASSERTION_FAILED,
+                    "Failed to catch expected JDOFatalDataStoreException.");
+       } catch (JDOFatalDataStoreException ex) {
+            // Good catch!
+        }
+    }
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/transactions/GetRollbackOnlyReturnsFalseUntilSet.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/transactions/GetRollbackOnlyReturnsFalseUntilSet.java?rev=291857&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/transactions/GetRollbackOnlyReturnsFalseUntilSet.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/transactions/GetRollbackOnlyReturnsFalseUntilSet.java Tue Sep 27 01:26:28 2005
@@ -0,0 +1,74 @@
+/*
+ * 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.transactions;
+
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+
+/**
+ *<B>Title:</B> Test GetRollbackOnlyReturnsFalseUntilSet
+ *<BR>
+ *<B>Keywords:</B> commit setRollbackOnly getRollbackOnly
+ *<BR>
+ *<B>Assertion IDs:</B> A13.4.5-2 
+ *<BR>
+ *<B>Assertion Description: </B>
+When a transaction is not active, and after a transaction is begun, 
+getRollbackOnly will return false. Once setRollbackOnly has been called, 
+it will return true until commit or rollback is called.
+ */
+
+public class GetRollbackOnlyReturnsFalseUntilSet extends JDO_Test {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A13.4.5-2 (GetRollbackOnlyReturnsFalseUntilSet) 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(GetRollbackOnlyReturnsFalseUntilSet.class);
+    }
+
+    /** */
+    public void test() {
+        getPM();
+        Transaction tx = pm.currentTransaction();
+        assertFalse(ASSERTION_FAILED + 
+                "getRollbackOnly returned true before transaction begin.",
+                tx.getRollbackOnly());
+        tx.begin();
+        assertFalse(ASSERTION_FAILED + 
+                "getRollbackOnly returned true before setRollbackOnly.",
+                tx.getRollbackOnly());
+        tx.setRollbackOnly();
+        assertTrue(ASSERTION_FAILED + 
+                "getRollbackOnly returned false after setRollbackOnly.",
+                tx.getRollbackOnly());
+        tx.rollback();
+        assertFalse(ASSERTION_FAILED + 
+                "getRollbackOnly returned true after transaction rollback.",
+                tx.getRollbackOnly());
+    }
+}