arminw 2005/08/31 10:40:47
Modified: src/test/org/apache/ojb/broker/locking
CommonsLockTestCommittedReads.java
CommonsLockTestRepeatableReads.java
CommonsLockTestSerializable.java
CommonsLockTestUncommittedReads.java
LockTestCommitedReads.java
LockTestRepeatableReads.java
LockTestSerializable.java
LockTestUncommitedReads.java
src/test/org/apache/ojb/broker/metadata MetadataTest.java
src/test/org/apache/ojb/broker/sequence
NativeIdentifierTest.java
src/test/org/apache/ojb/otm CopyTest.java
Added: src/test/org/apache/ojb/broker/locking
IsolationLevelTest.java
Log:
(re-)introduce typesafe isolation level handling, use commons-lang enums
instead of int values, minor test improvements
Revision Changes Path
1.3 +2 -2
db-ojb/src/test/org/apache/ojb/broker/locking/CommonsLockTestCommittedReads.java
Index: CommonsLockTestCommittedReads.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/test/org/apache/ojb/broker/locking/CommonsLockTestCommittedReads.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CommonsLockTestCommittedReads.java 27 Aug 2005 12:41:20 -0000
1.2
+++ CommonsLockTestCommittedReads.java 31 Aug 2005 17:40:46 -0000
1.3
@@ -11,7 +11,7 @@
*/
public class CommonsLockTestCommittedReads extends OJBTestCase
{
- final int testIsoLevel = LockManager.IL_READ_COMMITTED;
+ final IsolationLevels testIsoLevel = IsolationLevels.READ_COMMITTED;
public static void main(String[] args)
{
@@ -28,7 +28,7 @@
Object tx2;
Article obj;
LockManager lockManager;
- int oldIsolationLevel;
+ IsolationLevels oldIsolationLevel;
ClassDescriptor cld;
public void setUp() throws Exception
1.3 +2 -2
db-ojb/src/test/org/apache/ojb/broker/locking/CommonsLockTestRepeatableReads.java
Index: CommonsLockTestRepeatableReads.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/test/org/apache/ojb/broker/locking/CommonsLockTestRepeatableReads.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CommonsLockTestRepeatableReads.java 27 Aug 2005 12:41:20 -0000
1.2
+++ CommonsLockTestRepeatableReads.java 31 Aug 2005 17:40:46 -0000
1.3
@@ -11,7 +11,7 @@
*/
public class CommonsLockTestRepeatableReads extends OJBTestCase
{
- final int testIsoLevel = LockManager.IL_REPEATABLE_READ;
+ final IsolationLevels testIsoLevel = IsolationLevels.REPEATABLE_READ;
public static void main(String[] args)
{
@@ -28,7 +28,7 @@
Object tx2;
Article obj;
LockManager lockManager;
- int oldIsolationLevel;
+ IsolationLevels oldIsolationLevel;
ClassDescriptor cld;
public void setUp() throws Exception
1.3 +2 -2
db-ojb/src/test/org/apache/ojb/broker/locking/CommonsLockTestSerializable.java
Index: CommonsLockTestSerializable.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/test/org/apache/ojb/broker/locking/CommonsLockTestSerializable.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CommonsLockTestSerializable.java 27 Aug 2005 12:41:20 -0000 1.2
+++ CommonsLockTestSerializable.java 31 Aug 2005 17:40:46 -0000 1.3
@@ -11,7 +11,7 @@
*/
public class CommonsLockTestSerializable extends OJBTestCase
{
- final int testIsoLevel = LockManager.IL_SERIALIZABLE;
+ final IsolationLevels testIsoLevel = IsolationLevels.SERIALIZABLE;
public static void main(String[] args)
{
@@ -28,7 +28,7 @@
Object tx2;
Article obj;
LockManager lockManager;
- int oldIsolationLevel;
+ IsolationLevels oldIsolationLevel;
ClassDescriptor cld;
public void setUp() throws Exception
1.3 +2 -2
db-ojb/src/test/org/apache/ojb/broker/locking/CommonsLockTestUncommittedReads.java
Index: CommonsLockTestUncommittedReads.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/test/org/apache/ojb/broker/locking/CommonsLockTestUncommittedReads.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CommonsLockTestUncommittedReads.java 27 Aug 2005 12:41:20 -0000
1.2
+++ CommonsLockTestUncommittedReads.java 31 Aug 2005 17:40:46 -0000
1.3
@@ -11,7 +11,7 @@
*/
public class CommonsLockTestUncommittedReads extends OJBTestCase
{
- final int testIsoLevel = LockManager.IL_READ_UNCOMMITTED;
+ final IsolationLevels testIsoLevel = IsolationLevels.READ_UNCOMMITTED;
public static void main(String[] args)
{
@@ -28,7 +28,7 @@
Object tx2;
Article obj;
LockManager lockManager;
- int oldIsolationLevel;
+ IsolationLevels oldIsolationLevel;
ClassDescriptor cld;
public void setUp() throws Exception
1.4 +2 -2
db-ojb/src/test/org/apache/ojb/broker/locking/LockTestCommitedReads.java
Index: LockTestCommitedReads.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/test/org/apache/ojb/broker/locking/LockTestCommitedReads.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LockTestCommitedReads.java 27 Aug 2005 12:41:20 -0000 1.3
+++ LockTestCommitedReads.java 31 Aug 2005 17:40:46 -0000 1.4
@@ -12,7 +12,7 @@
*/
public class LockTestCommitedReads extends OJBTestCase
{
- final int testIsoLevel = LockManager.IL_READ_COMMITTED;
+ final IsolationLevels testIsoLevel = IsolationLevels.READ_COMMITTED;
public static void main(String[] args)
{
@@ -29,7 +29,7 @@
Object tx2;
Article obj;
LockManager lockManager;
- int oldIsolationLevel;
+ IsolationLevels oldIsolationLevel;
ClassDescriptor cld;
public void setUp() throws Exception
1.4 +2 -2
db-ojb/src/test/org/apache/ojb/broker/locking/LockTestRepeatableReads.java
Index: LockTestRepeatableReads.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/test/org/apache/ojb/broker/locking/LockTestRepeatableReads.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LockTestRepeatableReads.java 27 Aug 2005 12:41:20 -0000 1.3
+++ LockTestRepeatableReads.java 31 Aug 2005 17:40:46 -0000 1.4
@@ -12,7 +12,7 @@
*/
public class LockTestRepeatableReads extends OJBTestCase
{
- final int testIsoLevel = LockManager.IL_REPEATABLE_READ;
+ final IsolationLevels testIsoLevel = IsolationLevels.REPEATABLE_READ;
public static void main(String[] args)
{
@@ -29,7 +29,7 @@
Object tx2;
Article obj;
LockManager lockManager;
- int oldIsolationLevel;
+ IsolationLevels oldIsolationLevel;
ClassDescriptor cld;
public void setUp() throws Exception
1.4 +2 -2
db-ojb/src/test/org/apache/ojb/broker/locking/LockTestSerializable.java
Index: LockTestSerializable.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/test/org/apache/ojb/broker/locking/LockTestSerializable.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LockTestSerializable.java 27 Aug 2005 12:41:20 -0000 1.3
+++ LockTestSerializable.java 31 Aug 2005 17:40:46 -0000 1.4
@@ -12,7 +12,7 @@
*/
public class LockTestSerializable extends OJBTestCase
{
- final int testIsoLevel = LockManager.IL_SERIALIZABLE;
+ final IsolationLevels testIsoLevel = IsolationLevels.SERIALIZABLE;
public static void main(String[] args)
{
@@ -29,7 +29,7 @@
Object tx2;
Article obj;
LockManager lockManager;
- int oldIsolationLevel;
+ IsolationLevels oldIsolationLevel;
ClassDescriptor cld;
public void setUp() throws Exception
1.4 +2 -2
db-ojb/src/test/org/apache/ojb/broker/locking/LockTestUncommitedReads.java
Index: LockTestUncommitedReads.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/test/org/apache/ojb/broker/locking/LockTestUncommitedReads.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LockTestUncommitedReads.java 27 Aug 2005 12:41:20 -0000 1.3
+++ LockTestUncommitedReads.java 31 Aug 2005 17:40:46 -0000 1.4
@@ -12,7 +12,7 @@
*/
public class LockTestUncommitedReads extends OJBTestCase
{
- final int testIsoLevel = LockManager.IL_READ_UNCOMMITTED;
+ final IsolationLevels testIsoLevel = IsolationLevels.READ_UNCOMMITTED;
public static void main(String[] args)
{
@@ -29,7 +29,7 @@
Object tx2;
Article obj;
LockManager lockManager;
- int oldIsolationLevel;
+ IsolationLevels oldIsolationLevel;
ClassDescriptor cld;
public void setUp() throws Exception
1.1
db-ojb/src/test/org/apache/ojb/broker/locking/IsolationLevelTest.java
Index: IsolationLevelTest.java
===================================================================
package org.apache.ojb.broker.locking;
import org.apache.ojb.junit.OJBTestCase;
/**
* This is the TestSuite that checks the ODMG locking strategies.
* It performs 17 testMethods as defined in the Locking documentation.
*
* @author Thomas Mahler
*/
public class IsolationLevelTest extends OJBTestCase
{
public static void main(String[] args)
{
String[] arr = {IsolationLevelTest.class.getName()};
junit.textui.TestRunner.main(arr);
}
public IsolationLevelTest(String name)
{
super(name);
}
public void setUp() throws Exception
{
super.setUp();
}
public void tearDown() throws Exception
{
super.tearDown();
}
public void testIsolation()
{
assertEquals(IsolationLevels.READ_COMMITTED,
IsolationLevels.getEnum(IsolationLevels.IL_READ_COMMITTED));
assertEquals(IsolationLevels.READ_COMMITTED,
IsolationLevels.getEnum(IsolationLevels.LITERAL_IL_READ_COMMITTED));
assertFalse(IsolationLevels.READ_COMMITTED.ignoreForLock());
assertEquals(IsolationLevels.READ_UNCOMMITTED,
IsolationLevels.getEnum(IsolationLevels.IL_READ_UNCOMMITTED));
assertEquals(IsolationLevels.READ_UNCOMMITTED,
IsolationLevels.getEnum(IsolationLevels.LITERAL_IL_READ_UNCOMMITTED));
assertFalse(IsolationLevels.READ_UNCOMMITTED.ignoreForLock());
assertEquals(IsolationLevels.REPEATABLE_READ,
IsolationLevels.getEnum(IsolationLevels.IL_REPEATABLE_READ));
assertEquals(IsolationLevels.REPEATABLE_READ,
IsolationLevels.getEnum(IsolationLevels.LITERAL_IL_REPEATABLE_READ));
assertFalse(IsolationLevels.REPEATABLE_READ.ignoreForLock());
assertEquals(IsolationLevels.SERIALIZABLE,
IsolationLevels.getEnum(IsolationLevels.IL_SERIALIZABLE));
assertEquals(IsolationLevels.SERIALIZABLE,
IsolationLevels.getEnum(IsolationLevels.LITERAL_IL_SERIALIZABLE));
assertFalse(IsolationLevels.SERIALIZABLE.ignoreForLock());
assertEquals(IsolationLevels.NO_LOCKING,
IsolationLevels.getEnum(IsolationLevels.IL_NO_LOCKING));
assertEquals(IsolationLevels.NO_LOCKING,
IsolationLevels.getEnum(IsolationLevels.LITERAL_IL_NO_LOCKING));
assertTrue(IsolationLevels.NO_LOCKING.ignoreForLock());
assertEquals(IsolationLevels.OPTIMISTIC,
IsolationLevels.getEnum(IsolationLevels.IL_OPTIMISTIC));
assertEquals(IsolationLevels.OPTIMISTIC,
IsolationLevels.getEnum(IsolationLevels.LITERAL_IL_OPTIMISTIC));
assertTrue(IsolationLevels.OPTIMISTIC.ignoreForLock());
assertEquals(IsolationLevels.USE_GLOBAL,
IsolationLevels.getEnum(IsolationLevels.IL_USE_GLOBAL));
assertEquals(IsolationLevels.USE_GLOBAL,
IsolationLevels.getEnum(IsolationLevels.LITERAL_IL_USE_GLOBAL));
assertTrue(IsolationLevels.USE_GLOBAL.ignoreForLock());
}
}
1.25 +1 -1
db-ojb/src/test/org/apache/ojb/broker/metadata/MetadataTest.java
Index: MetadataTest.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/test/org/apache/ojb/broker/metadata/MetadataTest.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- MetadataTest.java 27 Aug 2005 12:39:54 -0000 1.24
+++ MetadataTest.java 31 Aug 2005 17:40:46 -0000 1.25
@@ -314,7 +314,7 @@
public void testLookupDatabase() throws Exception
{
String queryStr = "select allArticle from " + TEST_CLASS.getName();
- Implementation odmg = OJB.getInstance();
+ Implementation odmg = ojb.instanceODMG();
Transaction tx;
Database db = odmg.newDatabase();
db.open(TestHelper.DEF_JCD_ALIAS, Database.OPEN_READ_WRITE);
1.23 +4 -4
db-ojb/src/test/org/apache/ojb/broker/sequence/NativeIdentifierTest.java
Index: NativeIdentifierTest.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/test/org/apache/ojb/broker/sequence/NativeIdentifierTest.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- NativeIdentifierTest.java 27 Aug 2005 12:39:54 -0000 1.22
+++ NativeIdentifierTest.java 31 Aug 2005 17:40:46 -0000 1.23
@@ -348,7 +348,7 @@
MainObject obj_2 = new MainObject(null, name);
MainObject obj_3 = new MainObject(null, name);
- Implementation odmg = OJB.getInstance();
+ Implementation odmg = ojb.instanceODMG();
Database db = odmg.newDatabase();
db.open(TestHelper.DEF_DATABASE_NAME, Database.OPEN_READ_WRITE);
@@ -589,7 +589,7 @@
SingleReference s_ref_4 = new SingleReference(nameSingleRef);
obj_2.setSingleReference(s_ref_4);
- Implementation odmg = OJB.getInstance();
+ Implementation odmg = ojb.instanceODMG();
Database db = odmg.newDatabase();
db.open(TestHelper.DEF_DATABASE_NAME, Database.OPEN_READ_WRITE);
@@ -765,7 +765,7 @@
obj_1.setSingleReference(s_ref_3);
obj_2.setSingleReference(s_ref_4);
- Implementation odmg = OJB.getInstance();
+ Implementation odmg = ojb.instanceODMG();
Database db = odmg.newDatabase();
db.open(TestHelper.DEF_DATABASE_NAME, Database.OPEN_READ_WRITE);
1.14 +33 -24 db-ojb/src/test/org/apache/ojb/otm/CopyTest.java
Index: CopyTest.java
===================================================================
RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/otm/CopyTest.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- CopyTest.java 27 Aug 2005 12:44:02 -0000 1.13
+++ CopyTest.java 31 Aug 2005 17:40:47 -0000 1.14
@@ -211,30 +211,39 @@
{
Transaction tx = _kit.getTransaction(_conn);
tx.begin();
- Zoo zoo = new Zoo();
- zoo.setZooId(1234);
- Identity oid = _conn.getIdentity(zoo);
- zoo = (Zoo) _conn.getObjectByIdentity(oid);
- if (zoo == null)
- {
- zoo = new Zoo();
- zoo.setZooId(1234);
- _conn.makePersistent(zoo);
- Mammal mammal = new Mammal();
- mammal.setName("molly");
- mammal.setNumLegs(4);
- mammal.setAge(55);
- zoo.addAnimal(mammal);
- _conn.makePersistent(mammal);
- Reptile reptile = new Reptile();
- reptile.setColor("green");
- reptile.setName("hubert");
- reptile.setAge(51);
- zoo.addAnimal(reptile);
- _conn.makePersistent(reptile);
- }
- tx.commit();
- m_zoo = zoo;
+ Zoo zoo;
+ try
+ {
+ zoo = new Zoo();
+ zoo.setZooId(1234);
+ Identity oid = _conn.getIdentity(zoo);
+ zoo = (Zoo) _conn.getObjectByIdentity(oid);
+ if (zoo == null)
+ {
+ zoo = new Zoo();
+ zoo.setZooId(1234);
+ _conn.makePersistent(zoo);
+ Mammal mammal = new Mammal();
+ mammal.setName("molly");
+ mammal.setNumLegs(4);
+ mammal.setAge(55);
+ zoo.addAnimal(mammal);
+ _conn.makePersistent(mammal);
+ Reptile reptile = new Reptile();
+ reptile.setColor("green");
+ reptile.setName("hubert");
+ reptile.setAge(51);
+ zoo.addAnimal(reptile);
+ _conn.makePersistent(reptile);
+ }
+ tx.commit();
+ }
+ catch(RuntimeException e)
+ {
+ tx.rollback();
+ throw e;
+ }
+ m_zoo = zoo;
return m_zoo;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]