db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1369257 - /db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/oid/IDBrokerTest.java
Date Sat, 04 Aug 2012 03:46:17 GMT
Author: tfischer
Date: Sat Aug  4 03:46:17 2012
New Revision: 1369257

URL: http://svn.apache.org/viewvc?rev=1369257&view=rev
Log:
use Transaction.begin() and Transaction.commit() instead of Torque.getConnection() and Connection.close()

Modified:
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/oid/IDBrokerTest.java

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/oid/IDBrokerTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/oid/IDBrokerTest.java?rev=1369257&r1=1369256&r2=1369257&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/oid/IDBrokerTest.java
(original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/oid/IDBrokerTest.java
Sat Aug  4 03:46:17 2012
@@ -27,6 +27,7 @@ import org.apache.commons.configuration.
 import org.apache.torque.BaseDatabaseTestCase;
 import org.apache.torque.Torque;
 import org.apache.torque.test.AuthorPeer;
+import org.apache.torque.util.Transaction;
 
 /**
  * Tests methods in the adapters
@@ -42,12 +43,12 @@ public class IDBrokerTest extends BaseDa
     {
         super.setUp();
         idBroker = new IDBroker(Torque.getDatabase(Torque.getDefaultDB()));
-        Connection connection = Torque.getConnection();
+        Connection connection = Transaction.begin();
         idBroker.updateQuantity(
                 connection,
                 AuthorPeer.TABLE_NAME,
                 new BigDecimal("10"));
-        connection.close();
+        Transaction.commit(connection);
     }
 
     @Override
@@ -65,7 +66,7 @@ public class IDBrokerTest extends BaseDa
     public void testRestartIdBroker() throws Exception
     {
         idBroker.start();
-        Connection connection = Torque.getConnection();
+        Connection connection = Transaction.begin();
         int id = idBroker.getIdAsInt(connection, AuthorPeer.TABLE_NAME);
         idBroker.stop();
         while (idBroker.isThreadRunning()) {
@@ -75,6 +76,7 @@ public class IDBrokerTest extends BaseDa
         int nextId = idBroker.getIdAsInt(connection, AuthorPeer.TABLE_NAME);
         // assuming quantity > 1
         assertTrue(nextId > id + 1);
+        Transaction.commit(connection);
     }
 
     /**
@@ -85,11 +87,12 @@ public class IDBrokerTest extends BaseDa
     public void testInitialQuantityValue() throws Exception
     {
         idBroker.start();
-        Connection connection = Torque.getConnection();
+        Connection connection = Transaction.begin();
         idBroker.getIdAsInt(connection, AuthorPeer.TABLE_NAME);
         assertEquals(
                 new BigDecimal(10),
                 idBroker.getQuantity(AuthorPeer.TABLE_NAME));
+        Transaction.commit(connection);
     }
 
     /**
@@ -104,13 +107,14 @@ public class IDBrokerTest extends BaseDa
         configuration.setProperty("idbroker.clever.quantity", "true");
         idBroker.start();
         idBroker.setConfiguration(configuration);
-        Connection connection = Torque.getConnection();
+        Connection connection = Transaction.begin();
         for (int i = 1 ; i <= 11; ++i)
         {
             idBroker.getIdAsInt(connection, AuthorPeer.TABLE_NAME);
         }
         assertTrue(new BigDecimal("10").compareTo(
                 idBroker.getQuantity(AuthorPeer.TABLE_NAME)) < 0);
+        Transaction.commit(connection);
     }
 
     /**
@@ -125,12 +129,13 @@ public class IDBrokerTest extends BaseDa
         configuration.setProperty("idbroker.clever.quantity.max", "14");
         idBroker.start();
         idBroker.setConfiguration(configuration);
-        Connection connection = Torque.getConnection();
+        Connection connection = Transaction.begin();
         for (int i = 1 ; i <= 11; ++i)
         {
             idBroker.getIdAsInt(connection, AuthorPeer.TABLE_NAME);
         }
         assertTrue(new BigDecimal("14").compareTo(
                 idBroker.getQuantity(AuthorPeer.TABLE_NAME)) == 0);
+        Transaction.commit(connection);
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message