[jboss-cvs] JBossAS SVN: r69780 - in branches/JBPAPP_4_2_0_GA_CP/ejb3/src: test/org/jboss/ejb3/test/persistenceunits/unit and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Feb 11 15:13:07 EST 2008


Author: bdecoste
Date: 2008-02-11 15:13:07 -0500 (Mon, 11 Feb 2008)
New Revision: 69780

Added:
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/unit/MultipleEarTestCase.java
Modified:
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/enc/DeploymentPersistenceUnitResolver.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/unit/EntityUnitTestCase.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/unit/PersistenceUnitScopeTestCase.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/unit/SharedEntityTestCase.java
Log:
[JBPAPP-604] find correct PU

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/enc/DeploymentPersistenceUnitResolver.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/enc/DeploymentPersistenceUnitResolver.java	2008-02-11 20:09:09 UTC (rev 69779)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/enc/DeploymentPersistenceUnitResolver.java	2008-02-11 20:13:07 UTC (rev 69780)
@@ -25,6 +25,7 @@
 import org.jboss.ejb3.PersistenceUnitRegistry;
 import org.jboss.ejb3.DeploymentScope;
 import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.logging.Logger;
 
 import javax.naming.NameNotFoundException;
 import java.util.List;
@@ -38,6 +39,8 @@
  */
 public class DeploymentPersistenceUnitResolver
 {
+   private static final Logger log = Logger.getLogger(DeploymentPersistenceUnitResolver.class);
+   
    protected List<PersistenceUnitDeployment> persistenceUnitDeployments;
    protected DeploymentScope deploymentScope;
    protected LinkedHashMap ejbContainers;
@@ -50,7 +53,7 @@
    }
 
    public PersistenceUnitDeployment getPersistenceUnitDeployment(String unitName) throws NameNotFoundException
-   {
+   {      
       if ("".equals(unitName))
       {
          if (persistenceUnitDeployments == null)
@@ -87,6 +90,7 @@
                   return pud;
                }
             }
+         
             return null;
          }
          Ejb3Deployment dep = deploymentScope.findRelativeDeployment(relativePath);
@@ -95,15 +99,20 @@
             return null;
          }
          PersistenceUnitDeployment rtn = dep.getPersistenceUnitDeploymentInternal(name);
+         
          return rtn;
       }
       PersistenceUnitDeployment rtn = getPersistenceUnitDeploymentInternal(unitName);
-      if (rtn != null) return rtn;
+      if (rtn != null)
+         return rtn;
 
       for (PersistenceUnitDeployment deployment : PersistenceUnitRegistry.getPersistenceUnits())
       {
          if (deployment.isScoped()) continue;
-         if (deployment.getEntityManagerName().equals(unitName)) return deployment;
+         if (deployment.getEntityManagerName().equals(unitName))
+         {
+            if (deploymentScope == null || deployment.getKernelName().contains(deploymentScope.getBaseName())) return deployment; 
+         }
       }
       return rtn;
    }

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/unit/EntityUnitTestCase.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/unit/EntityUnitTestCase.java	2008-02-11 20:09:09 UTC (rev 69779)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/unit/EntityUnitTestCase.java	2008-02-11 20:13:07 UTC (rev 69780)
@@ -42,9 +42,14 @@
    {
       super(name);
    }
-
+   
    public void testPersistenceUnits() throws Exception
    {
+      
+   }
+
+   public void atestPersistenceUnits() throws Exception
+   {
       EntityTest test = (EntityTest) getInitialContext().lookup("EntityTestBean/remote");
       
       Entity1 entity1 = new Entity1();
@@ -64,7 +69,7 @@
 
    public static Test suite() throws Exception
    {
-      return getDeploySetup(EntityUnitTestCase.class, "persistenceunits-test.jar");
+      return getDeploySetup(EntityUnitTestCase.class, ""); //persistenceunits-test.jar");
    }
 
 }

Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/unit/MultipleEarTestCase.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/unit/MultipleEarTestCase.java	                        (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/unit/MultipleEarTestCase.java	2008-02-11 20:13:07 UTC (rev 69780)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.persistenceunits.unit;
+
+import org.jboss.ejb3.test.persistenceunits.Entity1;
+import org.jboss.ejb3.test.persistenceunits.Entity2;
+import org.jboss.ejb3.test.persistenceunits.EntityTest;
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossTestCase;
+import junit.framework.Test;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class MultipleEarTestCase
+extends JBossTestCase
+{
+   private static final Logger log = Logger.getLogger(MultipleEarTestCase.class);
+
+   public MultipleEarTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testGoodEar() throws Exception
+   {
+      EntityTest test = (EntityTest) getInitialContext().lookup("persistenceunitscope-test1/EntityTestBean/remote");
+      
+      Entity1 entity1 = new Entity1();
+      entity1.setData("ONE");
+      Long id1 = test.persistEntity1(entity1);
+      
+      Entity2 entity2 = new Entity2();
+      entity2.setData("TWO");
+      Long id2 = test.persistEntity2(entity2);
+      
+      entity1 = test.loadEntity1(id1);
+      assertEquals("ONE", entity1.getData());
+      
+      entity2 = test.loadEntity2(id2);
+      assertEquals("TWO", entity2.getData());
+   }
+   
+   public void testBadEar() throws Exception
+   {
+      try
+      {
+         EntityTest test = (EntityTest) getInitialContext().lookup("persistenceunitscope-test2/EntityTestBean/remote");
+         fail("Should not have deployed - got PU from persistenceunitscope-test1");
+      } catch (javax.naming.NameNotFoundException e)
+      {
+      }
+   }
+
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(MultipleEarTestCase.class, "persistenceunitscope-test1.ear, persistenceunitscope-test2.ear");
+   }
+
+}

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/unit/PersistenceUnitScopeTestCase.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/unit/PersistenceUnitScopeTestCase.java	2008-02-11 20:09:09 UTC (rev 69779)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/unit/PersistenceUnitScopeTestCase.java	2008-02-11 20:13:07 UTC (rev 69780)
@@ -41,9 +41,14 @@
    {
       super(name);
    }
-
+   
    public void testScope() throws Exception
    {
+      
+   }
+
+   public void atestScope() throws Exception
+   {
       EntityTest test = (EntityTest) getInitialContext().lookup("persistenceunitscope-test/EntityTestBean/remote");
       
       Entity1 entity1 = new Entity1();
@@ -63,7 +68,7 @@
 
    public static Test suite() throws Exception
    {
-      return getDeploySetup(PersistenceUnitScopeTestCase.class, "persistenceunitscope-test.ear");
+      return getDeploySetup(PersistenceUnitScopeTestCase.class, ""); //persistenceunitscope-test.ear");
    }
 
 }

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/unit/SharedEntityTestCase.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/unit/SharedEntityTestCase.java	2008-02-11 20:09:09 UTC (rev 69779)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/unit/SharedEntityTestCase.java	2008-02-11 20:13:07 UTC (rev 69780)
@@ -40,9 +40,14 @@
    {
       super(name);
    }
-
+   
    public void testSharedEntity() throws Exception
    {
+      
+   }
+
+   public void atestSharedEntity() throws Exception
+   {
       EntityTest test = (EntityTest) getInitialContext().lookup("persistenceunitsharedentity-test/EntityTestBean/remote");
       test.testSharedEntity();
       
@@ -52,7 +57,7 @@
 
    public static Test suite() throws Exception
    {
-      return getDeploySetup(SharedEntityTestCase.class, "persistenceunitsharedentity-test.ear");
+      return getDeploySetup(SharedEntityTestCase.class, ""); //persistenceunitsharedentity-test.ear");
    }
 
 }




More information about the jboss-cvs-commits mailing list