Title: [2592] branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr: Re-enable some unreliable CMR tests.

Diff

Modified: branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/AbstractCMRTest.java (2591 => 2592)

--- branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/AbstractCMRTest.java	2006-04-02 02:06:49 UTC (rev 2591)
+++ branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/AbstractCMRTest.java	2006-04-02 06:03:02 UTC (rev 2592)
@@ -49,6 +49,7 @@
 
 
 import java.io.File;
+import java.io.IOException;
 import java.sql.Connection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -67,6 +68,8 @@
 import org.apache.geronimo.kernel.config.ConfigurationManager;
 import org.apache.geronimo.kernel.config.ConfigurationModuleType;
 import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.geronimo.kernel.config.NoSuchConfigException;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.Dependency;
 import org.apache.geronimo.kernel.repository.Environment;
@@ -176,9 +179,11 @@
 
             FrontEndCacheDelegate cacheDelegate = new FrontEndCacheDelegate();
 
-            setUpContainer(ejbSchema.getEJB("A"), getA().bean, getA().home, getA().local, C_NAME_A, transactionManager, cacheDelegate);
-            setUpContainer(ejbSchema.getEJB("B"), getB().bean, getB().home, getB().local, C_NAME_B, transactionManager, cacheDelegate);
+            GBeanData gBeanA = buildGBeanData(ejbSchema.getEJB("A"), getA().bean, getA().home, getA().local, C_NAME_A, transactionManager, cacheDelegate);
+            GBeanData gBeanB = buildGBeanData(ejbSchema.getEJB("B"), getB().bean, getB().home, getB().local, C_NAME_B, transactionManager, cacheDelegate);
 
+            buildAndStartConfiguration("testEJBModule", new GBeanData[] {gBeanA, gBeanB});
+            
             ahome = kernel.getAttribute(C_NAME_A, "ejbLocalHome");
             bhome = kernel.getAttribute(C_NAME_B, "ejbLocalHome");
         } finally {
@@ -187,7 +192,7 @@
     }
 
 
-    private void setUpContainer(EJB ejb, Class beanClass, Class homeClass, Class localClass, AbstractName containerName, TransactionManager transactionManager, FrontEndCacheDelegate cacheDelegate) throws Exception {
+    private GBeanData buildGBeanData(EJB ejb, Class beanClass, Class homeClass, Class localClass, AbstractName containerName, TransactionManager transactionManager, FrontEndCacheDelegate cacheDelegate) throws Exception {
         CMPContainerBuilder builder = new CMPContainerBuilder();
         builder.setClassLoader(this.getClass().getClassLoader());
         builder.setContainerId(containerName.toURI().toString());
@@ -224,10 +229,16 @@
         container.setReferencePattern("Timer", txTimerName);
         container.setAbstractName(containerName);
 
+        return container;
+    }
+
+    private void buildAndStartConfiguration(String name, GBeanData containers[]) throws NoSuchConfigException, IOException, InvalidConfigException {
         // Wrap the GBeanData in a configuration
-        ConfigurationData config = new ConfigurationData(new Artifact("test", ejb.getName(), "42", "car"), kernel.getNaming());
+        ConfigurationData config = new ConfigurationData(new Artifact("test", name, "42", "car"), kernel.getNaming());
         config.getEnvironment().addDependency(new Dependency(baseId, ImportType.ALL));
-        config.addGBean(container);
+        for (int i = 0; i < containers.length; i++) {
+            config.addGBean(containers[i]);
+        }
 
         // Start the configuration
         ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);

Modified: branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/onetomany/OneToManyCompoundPKTest.java (2591 => 2592)

--- branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/onetomany/OneToManyCompoundPKTest.java	2006-04-02 02:06:49 UTC (rev 2591)
+++ branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/onetomany/OneToManyCompoundPKTest.java	2006-04-02 06:03:02 UTC (rev 2592)
@@ -254,16 +254,15 @@
         c.close();
     }
 
-// todo not reliable
-//    public void testASetBExistingANewB() throws Exception {
-//        TransactionContext ctx = prepareExistingANewB();
-//        Set bSet = a.getB();
-//        bSet.add(b);
-//        ctx.commit();
-//
-//        assertStateExistingANewB();
-//    }
+    public void testASetBExistingANewB() throws Exception {
+        TransactionContext ctx = prepareExistingANewB();
+        Set bSet = a.getB();
+        bSet.add(b);
+        ctx.commit();
 
+        assertStateExistingANewB();
+    }
+
     public void testBSetAExistingANewB() throws Exception {
         TransactionContext ctx = prepareExistingANewB();
         b.setA(a);

Modified: branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/onetomany/OneToManyTest.java (2591 => 2592)

--- branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/onetomany/OneToManyTest.java	2006-04-02 02:06:49 UTC (rev 2591)
+++ branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/onetomany/OneToManyTest.java	2006-04-02 06:03:02 UTC (rev 2592)
@@ -249,16 +249,15 @@
         c.close();
     }
 
-// todo not reliable
-//    public void testASetBExistingANewB() throws Exception {
-//        TransactionContext ctx = prepareExistingANewB();
-//        Set bSet = a.getB();
-//        bSet.add(b);
-//        ctx.commit();
-//
-//        assertStateExistingANewB();
-//    }
+    public void testASetBExistingANewB() throws Exception {
+        TransactionContext ctx = prepareExistingANewB();
+        Set bSet = a.getB();
+        bSet.add(b);
+        ctx.commit();
 
+        assertStateExistingANewB();
+    }
+
     public void testBSetAExistingANewB() throws Exception {
         TransactionContext ctx = prepareExistingANewB();
         b.setA(a);

Modified: branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/onetoone/OneToOneCompoundPKTest.java (2591 => 2592)

--- branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/onetoone/OneToOneCompoundPKTest.java	2006-04-02 02:06:49 UTC (rev 2591)
+++ branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/onetoone/OneToOneCompoundPKTest.java	2006-04-02 06:03:02 UTC (rev 2592)
@@ -150,15 +150,14 @@
         c.close();
     }
 
-// todo not reliable
-//    public void testASetBNewAB() throws Exception {
-//        TransactionContext ctx = prepareNewAB();
-//        a.setB(b);
-//        ctx.commit();
-//
-//        assertStateNewAB();
-//    }
+    public void testASetBNewAB() throws Exception {
+        TransactionContext ctx = prepareNewAB();
+        a.setB(b);
+        ctx.commit();
 
+        assertStateNewAB();
+    }
+
     public void testBSetANewAB() throws Exception {
         TransactionContext ctx = prepareNewAB();
         b.setA(a);

Modified: branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/onetoone/OneToOneTest.java (2591 => 2592)

--- branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/onetoone/OneToOneTest.java	2006-04-02 02:06:49 UTC (rev 2591)
+++ branches/v2_1/openejb2/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/onetoone/OneToOneTest.java	2006-04-02 06:03:02 UTC (rev 2592)
@@ -148,15 +148,15 @@
         c.close();
     }
 
-// todo not reliable
-//    public void testASetBNewAB() throws Exception {
-//        TransactionContext ctx = prepareNewAB();
-//        a.setB(b);
-//        ctx.commit();
-//
-//        assertStateNewAB();
-//    }
+    
+    public void testASetBNewAB() throws Exception {
+        TransactionContext ctx = prepareNewAB();
+        a.setB(b);
+        ctx.commit();
 
+        assertStateNewAB();
+    }
+
     public void testBSetANewAB() throws Exception {
         TransactionContext ctx = prepareNewAB();
         b.setA(a);

Reply via email to