jtolentino    2005/09/22 04:48:42

  Added:       
m2/unit-tests/openejb-builder/src/test/java/org/openejb/deployment
                        AbstractDeploymentTest.java
                        CMPEntityBuilderTest.java EarDeploymentTest.java
                        EjbJarModuleDeploymentTest.java
                        PlanParsingTest.java
                        UnpackedModuleDeploymentTest.java
  Log:

  Forgot that cvs does not automatically recurse addition of new directories. 
Committing repository and unit-tests directories. unit-tests: Modified unit 
tests with hard-coded references to directories based on base dir. repository: 
Artifacts that are generated by building Geronimo or exists in Maven 1 remote 
repo but not in Maven 2.
  
  Revision  Changes    Path
  1.1                  
openejb/m2/unit-tests/openejb-builder/src/test/java/org/openejb/deployment/AbstractDeploymentTest.java
  
  Index: AbstractDeploymentTest.java
  ===================================================================
  /* ====================================================================
   * Redistribution and use of this software and associated documentation
   * ("Software"), with or without modification, are permitted provided
   * that the following conditions are met:
   *
   * 1. Redistributions of source code must retain copyright
   *    statements and notices.  Redistributions must also contain a
   *    copy of this document.
   *
   * 2. Redistributions in binary form must reproduce this list of
   *    conditions and the following disclaimer in the documentation
   *    and/or other materials provided with the distribution.
   *
   * 3. The name "OpenEJB" must not be used to endorse or promote
   *    products derived from this Software without prior written
   *    permission of The OpenEJB Group.  For written permission,
   *    please contact [EMAIL PROTECTED]
   *
   * 4. Products derived from this Software may not be called "OpenEJB"
   *    nor may "OpenEJB" appear in their names without prior written
   *    permission of The OpenEJB Group. OpenEJB is a registered
   *    trademark of The OpenEJB Group.
   *
   * 5. Due credit should be given to the OpenEJB Project
   *    (http://openejb.org/).
   *
   * THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
   * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
   * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
   * THE OPENEJB GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
   * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the OpenEJB Project.  For more information
   * please see <http://openejb.org/>.
   *
   * ====================================================================
   */
  package org.openejb.deployment;
  
  import java.util.Set;
  import java.net.URLClassLoader;
  import java.net.URL;
  import java.io.File;
  import javax.ejb.EJBHome;
  import javax.management.ObjectName;
  
  import junit.framework.TestCase;
  import org.apache.geronimo.kernel.Kernel;
  import org.apache.geronimo.kernel.jmx.JMXUtil;
  import org.apache.geronimo.kernel.management.State;
  import org.openejb.proxy.EJBProxyReference;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2005/09/22 08:48:42 $
   */
  public abstract class AbstractDeploymentTest extends TestCase implements 
DeploymentTestContants {
      private final ObjectName STATELESS_BEAN_NAME = 
JMXUtil.getObjectName(DOMAIN_NAME + 
":j2eeType=StatelessSessionBean,J2EEServer=" + SERVER_NAME + 
",J2EEApplication=" + getJ2eeApplicationName() + ",EJBModule=" + 
getJ2eeModuleName() + ",name=SimpleStatelessSession");
  
      public abstract Kernel getKernel();
      public abstract ClassLoader getApplicationClassLoader();
      public abstract String getJ2eeApplicationName();
      public abstract String getJ2eeModuleName();
  
      public void testEJBModuleObject() throws Exception {
          ObjectName moduleName = ObjectName.getInstance(DOMAIN_NAME + 
":j2eeType=EJBModule,J2EEServer=" + SERVER_NAME + ",J2EEApplication=" + 
getJ2eeApplicationName() + ",name=" + getJ2eeModuleName());
          assertRunning(getKernel(), moduleName);
      }
  
      public void testApplicationObject() throws Exception {
          ObjectName applicationObjectName = ObjectName.getInstance(DOMAIN_NAME 
+ ":j2eeType=J2EEApplication,name=" + getJ2eeApplicationName() + ",J2EEServer=" 
+ SERVER_NAME);
          if (!getJ2eeApplicationName().equals("null")) {
              assertRunning(getKernel(), applicationObjectName);
          } else {
              Set applications = getKernel().listGBeans(applicationObjectName);
              assertTrue("No application object should be registered for a 
standalone module", applications.isEmpty());
          }
      }
  
      public void testStatelessContainer() throws Exception {
          assertRunning(getKernel(), STATELESS_BEAN_NAME);
  
          // use reflection to invoke a method on the stateless bean, because 
we don't have access to the classes here
          Object statelessHome = getKernel().getAttribute(STATELESS_BEAN_NAME, 
"ejbHome");
          assertTrue("Home is not an instance of EJBHome", statelessHome 
instanceof EJBHome);
          Object stateless = statelessHome.getClass().getMethod("create", 
null).invoke(statelessHome, null);
          assertEquals("TestResult", stateless.getClass().getMethod("echo", new 
Class[]{String.class}).invoke(stateless, new Object[]{"TestResult"}));
          Object statelessLocalHome = 
getKernel().getAttribute(STATELESS_BEAN_NAME, "ejbLocalHome");
          Object statelessLocal = 
statelessLocalHome.getClass().getMethod("create", 
null).invoke(statelessLocalHome, null);
          statelessLocal.getClass().getMethod("startTimer", 
null).invoke(statelessLocal, null);
          Thread.sleep(200L);
          assertEquals(new Integer(1), 
statelessLocal.getClass().getMethod("getTimeoutCount", 
null).invoke(statelessLocal, null));
      }
  
      public void testInClassLoaderInvoke() throws Exception {
          Object statelessHome;
          Object stateless;
          EJBProxyReference proxyReference = 
EJBProxyReference.createRemote(STATELESS_BEAN_NAME.getCanonicalName(),
                          true,
                  "org.openejb.test.simple.slsb.SimpleStatelessSessionHome", 
"org.openejb.test.simple.slsb.SimpleStatelessSession");
          proxyReference.setKernel(getKernel());
          proxyReference.setClassLoader(getApplicationClassLoader());
          statelessHome = proxyReference.getContent();
          assertTrue("Home is not an instance of EJBHome", statelessHome 
instanceof EJBHome);
          stateless = statelessHome.getClass().getMethod("create", 
null).invoke(statelessHome, null);
          assertEquals("TestResult", stateless.getClass().getMethod("echo", new 
Class[]{String.class}).invoke(stateless, new Object[]{"TestResult"}));
      }
  
      public void testCrossClassLoaderInvoke() throws Exception {
          Object statelessHome;
          Object stateless;
          EJBProxyReference proxyReference = 
EJBProxyReference.createRemote(STATELESS_BEAN_NAME.getCanonicalName(),
                          true,
                  "org.openejb.test.simple.slsb.SimpleStatelessSessionHome", 
"org.openejb.test.simple.slsb.SimpleStatelessSession");
          proxyReference.setKernel(getKernel());
          proxyReference.setClassLoader(new URLClassLoader(new URL[] {new 
File(System.getProperty( "basedir", System.getProperty( "user.dir" ) ), 
"target/test-ejb-jar.jar").toURL()}, getClass().getClassLoader()));
          statelessHome = proxyReference.getContent();
          assertTrue("Home is not an instance of EJBHome", statelessHome 
instanceof EJBHome);
          stateless = statelessHome.getClass().getMethod("create", 
null).invoke(statelessHome, null);
          assertEquals("TestResult", stateless.getClass().getMethod("echo", new 
Class[]{String.class}).invoke(stateless, new Object[]{"TestResult"}));
      }
  
      public void testStatefulContainer() throws Exception {
          ObjectName statefulBeanName = ObjectName.getInstance(DOMAIN_NAME + 
":j2eeType=StatefulSessionBean,J2EEServer=" + SERVER_NAME + ",J2EEApplication=" 
+ getJ2eeApplicationName() + ",EJBModule=" + getJ2eeModuleName() + 
",name=SimpleStatefulSession");
          assertRunning(getKernel(), statefulBeanName);
  
          Object statefulHome = getKernel().getAttribute(statefulBeanName, 
"ejbHome");
          assertTrue("Home is not an instance of EJBHome", statefulHome 
instanceof EJBHome);
          Object stateful = statefulHome.getClass().getMethod("create", 
null).invoke(statefulHome, null);
          stateful.getClass().getMethod("setValue", new 
Class[]{String.class}).invoke(stateful, new Object[]{"SomeValue"});
          assertEquals("SomeValue", stateful.getClass().getMethod("getValue", 
null).invoke(stateful, null));
      }
  
      public void testBMPContainer() throws Exception {
          ObjectName bmpBeanName = ObjectName.getInstance(DOMAIN_NAME + 
":j2eeType=EntityBean,J2EEServer=" + SERVER_NAME + ",J2EEApplication=" + 
getJ2eeApplicationName() + ",EJBModule=" + getJ2eeModuleName() + 
",name=SimpleBMPEntity");
          assertRunning(getKernel(), bmpBeanName);
  
          Object bmpHome = getKernel().getAttribute(bmpBeanName, "ejbHome");
          assertTrue("Home is not an instance of EJBHome", bmpHome instanceof 
EJBHome);
          Object bmp = bmpHome.getClass().getMethod("create", 
null).invoke(bmpHome, null);
          bmp.getClass().getMethod("setName", new 
Class[]{String.class}).invoke(bmp, new Object[]{"MyNameValue"});
          assertEquals("MyNameValue", bmp.getClass().getMethod("getName", 
null).invoke(bmp, null));
      }
  
      public void testCMPContainer() throws Exception {
          ObjectName cmpBeanName = ObjectName.getInstance(DOMAIN_NAME + 
":j2eeType=EntityBean,J2EEServer=" + SERVER_NAME + ",J2EEApplication=" + 
getJ2eeApplicationName() + ",EJBModule=" + getJ2eeModuleName() + 
",name=SimpleCMPEntity");
          assertRunning(getKernel(), cmpBeanName);
  
          Object cmpHome = getKernel().getAttribute(cmpBeanName, "ejbHome");
          assertTrue("Home is not an instance of EJBHome", cmpHome instanceof 
EJBHome);
          Object cmp = cmpHome.getClass().getMethod("create", new 
Class[]{Integer.class}).invoke(cmpHome, new Object[]{new Integer(42)});
  
          cmp.getClass().getMethod("setFirstName", new 
Class[]{String.class}).invoke(cmp, new Object[]{"MyFistName"});
          assertEquals("MyFistName", cmp.getClass().getMethod("getFirstName", 
null).invoke(cmp, null));
      }
  
      public void testPKGenCustomDBName() throws Exception {
          ObjectName cmpBeanName = ObjectName.getInstance(DOMAIN_NAME + 
":j2eeType=EntityBean,J2EEServer=" + SERVER_NAME + ",J2EEApplication=" + 
getJ2eeApplicationName() + ",EJBModule=" + getJ2eeModuleName() + 
",name=PKGenCMPEntity");
          assertRunning(getKernel(), cmpBeanName);
          assertRunning(getKernel(), new 
ObjectName("geronimo.server:name=CMPPKGenerator"));
  
          Object cmpHome = getKernel().getAttribute(cmpBeanName, "ejbHome");
          assertTrue("Home is not an instance of EJBHome", cmpHome instanceof 
EJBHome);
          Object cmp = cmpHome.getClass().getMethod("create", new 
Class[]{}).invoke(cmpHome, new Object[]{});
  
          cmp.getClass().getMethod("setFirstName", new 
Class[]{String.class}).invoke(cmp, new Object[]{"MyFirstName"});
          assertEquals("MyFirstName", cmp.getClass().getMethod("getFirstName", 
null).invoke(cmp, null));
      }
  
      public void testPKGenCustomDBParts() throws Exception {
          ObjectName cmpBeanName = ObjectName.getInstance(DOMAIN_NAME + 
":j2eeType=EntityBean,J2EEServer=" + SERVER_NAME + ",J2EEApplication=" + 
getJ2eeApplicationName() + ",EJBModule=" + getJ2eeModuleName() + 
",name=PKGenCMPEntity2");
          assertRunning(getKernel(), cmpBeanName);
          assertRunning(getKernel(), new 
ObjectName("geronimo.server:name=CMPPKGenerator2"));
  
          Object cmpHome = getKernel().getAttribute(cmpBeanName, "ejbHome");
          assertTrue("Home is not an instance of EJBHome", cmpHome instanceof 
EJBHome);
          Object cmp = cmpHome.getClass().getMethod("create", new 
Class[]{}).invoke(cmpHome, new Object[]{});
  
          cmp.getClass().getMethod("setFirstName", new 
Class[]{String.class}).invoke(cmp, new Object[]{"MyFirstName"});
          assertEquals("MyFirstName", cmp.getClass().getMethod("getFirstName", 
null).invoke(cmp, null));
      }
  
      public void testPKGenSequence() throws Exception {
          ObjectName cmpBeanName = ObjectName.getInstance(DOMAIN_NAME + 
":j2eeType=EntityBean,J2EEServer=" + SERVER_NAME + ",J2EEApplication=" + 
getJ2eeApplicationName() + ",EJBModule=" + getJ2eeModuleName() + 
",name=PKGenCMPEntity3");
          assertRunning(getKernel(), cmpBeanName);
  
          Object cmpHome = getKernel().getAttribute(cmpBeanName, "ejbHome");
          assertTrue("Home is not an instance of EJBHome", cmpHome instanceof 
EJBHome);
          Object cmp = cmpHome.getClass().getMethod("create", new 
Class[]{}).invoke(cmpHome, new Object[]{});
  
          cmp.getClass().getMethod("setFirstName", new 
Class[]{String.class}).invoke(cmp, new Object[]{"MyFirstName"});
          assertEquals("MyFirstName", cmp.getClass().getMethod("getFirstName", 
null).invoke(cmp, null));
      }
  /* Axion JDBC driver doesn't supoort returning generated keys -- try this 
again with a different DB
      public void testPKGenAutoIncrement() throws Exception {
          ObjectName cmpBeanName = ObjectName.getInstance(DOMAIN_NAME + 
":j2eeType=EntityBean,J2EEServer=" + SERVER_NAME + ",J2EEApplication=" + 
getJ2eeApplicationName() + ",EJBModule=" + getJ2eeModuleName() + 
",name=PKGenCMPEntity4");
          assertRunning(getKernel(), cmpBeanName);
  
          Object cmpHome = getKernel().getAttribute(cmpBeanName, "ejbHome");
          assertTrue("Home is not an instance of EJBHome", cmpHome instanceof 
EJBHome);
          Object cmp = cmpHome.getClass().getMethod("create", new 
Class[]{}).invoke(cmpHome, new Object[]{});
  
          cmp.getClass().getMethod("setFirstName", new 
Class[]{String.class}).invoke(cmp, new Object[]{"MyFirstName"});
          assertEquals("MyFirstName", cmp.getClass().getMethod("getFirstName", 
null).invoke(cmp, null));
      }
  */
      public void testPKGenSQL() throws Exception {
          ObjectName cmpBeanName = ObjectName.getInstance(DOMAIN_NAME + 
":j2eeType=EntityBean,J2EEServer=" + SERVER_NAME + ",J2EEApplication=" + 
getJ2eeApplicationName() + ",EJBModule=" + getJ2eeModuleName() + 
",name=PKGenCMPEntity5");
          assertRunning(getKernel(), cmpBeanName);
  
          Object cmpHome = getKernel().getAttribute(cmpBeanName, "ejbHome");
          assertTrue("Home is not an instance of EJBHome", cmpHome instanceof 
EJBHome);
          Object cmp = cmpHome.getClass().getMethod("create", new 
Class[]{}).invoke(cmpHome, new Object[]{});
  
          cmp.getClass().getMethod("setFirstName", new 
Class[]{String.class}).invoke(cmp, new Object[]{"MyFirstName"});
          assertEquals("MyFirstName", cmp.getClass().getMethod("getFirstName", 
null).invoke(cmp, null));
      }
  
      public void testMDBContainer() throws Exception {
          ObjectName mdbBeanName = ObjectName.getInstance(DOMAIN_NAME + 
":j2eeType=MessageDrivenBean,J2EEServer=" + SERVER_NAME + ",J2EEApplication=" + 
getJ2eeApplicationName() + ",EJBModule=" + getJ2eeModuleName() + 
",name=SimpleMessageDriven");
          assertRunning(getKernel(), mdbBeanName);
      }
  
      public static void assertRunning(Kernel kernel, ObjectName objectName) 
throws Exception {
          assertEquals("should be running: " + objectName, State.RUNNING_INDEX, 
kernel.getGBeanState(objectName));
      }
  }
  
  
  
  1.1                  
openejb/m2/unit-tests/openejb-builder/src/test/java/org/openejb/deployment/CMPEntityBuilderTest.java
  
  Index: CMPEntityBuilderTest.java
  ===================================================================
  /* ====================================================================
   * Redistribution and use of this software and associated documentation
   * ("Software"), with or without modification, are permitted provided
   * that the following conditions are met:
   *
   * 1. Redistributions of source code must retain copyright
   *    statements and notices.  Redistributions must also contain a
   *    copy of this document.
   *
   * 2. Redistributions in binary form must reproduce this list of
   *    conditions and the following disclaimer in the documentation
   *    and/or other materials provided with the distribution.
   *
   * 3. The name "OpenEJB" must not be used to endorse or promote
   *    products derived from this Software without prior written
   *    permission of The OpenEJB Group.  For written permission,
   *    please contact [EMAIL PROTECTED]
   *
   * 4. Products derived from this Software may not be called "OpenEJB"
   *    nor may "OpenEJB" appear in their names without prior written
   *    permission of The OpenEJB Group. OpenEJB is a registered
   *    trademark of The OpenEJB Group.
   *
   * 5. Due credit should be given to the OpenEJB Project
   *    (http://openejb.org/).
   *
   * THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
   * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
   * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
   * THE OPENEJB GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
   * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the OpenEJB Project.  For more information
   * please see <http://openejb.org/>.
   *
   * ====================================================================
   */
  
  package org.openejb.deployment;
  
  import java.io.File;
  import java.net.URI;
  import java.util.Iterator;
  import java.util.LinkedHashMap;
  import java.util.List;
  import java.util.Map;
  
  import javax.management.ObjectName;
  
  import junit.framework.TestCase;
  
  import org.apache.geronimo.common.DeploymentException;
  import org.apache.geronimo.deployment.util.DeploymentUtil;
  import org.apache.geronimo.j2ee.deployment.EARContext;
  import org.apache.geronimo.j2ee.j2eeobjectnames.J2eeContext;
  import org.apache.geronimo.j2ee.j2eeobjectnames.J2eeContextImpl;
  import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
  import org.apache.geronimo.kernel.Kernel;
  import org.apache.geronimo.kernel.config.ConfigurationModuleType;
  import org.apache.geronimo.kernel.repository.Repository;
  import org.apache.geronimo.xbeans.j2ee.EjbJarDocument;
  import org.apache.geronimo.xbeans.j2ee.EjbJarType;
  import org.apache.xmlbeans.XmlObject;
  import org.openejb.deployment.pkgen.TranQLPKGenBuilder;
  import org.openejb.xbeans.ejbjar.OpenejbOpenejbJarDocument;
  import org.openejb.xbeans.ejbjar.OpenejbOpenejbJarType;
  import org.tranql.cache.GlobalSchema;
  import org.tranql.ejb.EJBSchema;
  import org.tranql.schema.Association;
  import org.tranql.schema.AssociationEnd;
  import org.tranql.schema.Attribute;
  import org.tranql.schema.Entity;
  import org.tranql.schema.FKAttribute;
  import org.tranql.schema.Association.JoinDefinition;
  import org.tranql.sql.Table;
  import org.tranql.sql.sql92.SQL92Schema;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2005/09/22 08:48:42 $
   *
   * */
  public class CMPEntityBuilderTest extends TestCase {
      private ObjectName listener = null;
      private Repository repository = null;
      private Kernel kernel = null;
  
      private static final File basedir = new 
File(System.getProperty("basedir", System.getProperty("user.dir")));
  
      protected void setUp() throws Exception {
          kernel = KernelHelper.getPreparedKernel();
      }
  
      protected void tearDown() throws Exception {
          kernel.shutdown();
      }
  
      public void testOneToOne() throws Exception {
          executeOneToOne("src/test/test-cmp/onetoone/simplepk/ejb-jar.xml", 
"src/test/test-cmp/onetoone/simplepk/openejb-jar.xml");
      }
  
      public void testOneToOneUnidirectional() throws Exception {
          executeOneToOne("src/test/test-cmp/onetoone/simplepk/ejb-jar.xml", 
"src/test/test-cmp/onetoone/simplepk/unidirectional-openejb-jar.xml");
      }
  
      public void testOneToOneRoleNameMappingOK() throws Exception {
          executeOneToOne("src/test/test-cmp/cmr-mapping/ejb-jar.xml", 
"src/test/test-cmp/cmr-mapping/names-ok-openejb-jar.xml");
      }
  
      public void testOneToOneRoleNameMappingWrongCMRName() throws Exception {
          try {
              executeOneToOne("src/test/test-cmp/cmr-mapping/ejb-jar.xml", 
"src/test/test-cmp/cmr-mapping/cmr-name-nok-openejb-jar.xml");
              fail();
          } catch (DeploymentException e) {
          }
      }
  
      public void testOneToOneRoleNameMappingWrongSourceName() throws Exception 
{
          try {
              executeOneToOne("src/test/test-cmp/cmr-mapping/ejb-jar.xml", 
"src/test/test-cmp/cmr-mapping/source-name-nok-openejb-jar.xml");
              fail();
          } catch (DeploymentException e) {
          }
      }
  
      private void executeOneToOne(String ejbJarFileName, String 
openejbJarFileName) throws Exception {
          File ejbJarFile = new File(basedir, ejbJarFileName);
          File openejbJarFile = new File(basedir, openejbJarFileName);
          EjbJarType ejbJarType = ((EjbJarDocument) 
XmlObject.Factory.parse(ejbJarFile)).getEjbJar();
          OpenejbOpenejbJarType openejbJarType = ((OpenejbOpenejbJarDocument) 
XmlObject.Factory.parse(openejbJarFile)).getOpenejbJar();
  
          OpenEJBModuleBuilder moduleBuilder = new 
OpenEJBModuleBuilder(KernelHelper.DEFAULT_PARENTID_ARRAY, listener, null, null, 
repository, kernel);
          CMPEntityBuilder builder = new CMPEntityBuilder(moduleBuilder);
          TranQLPKGenBuilder pkGen = new TranQLPKGenBuilder();
  
          GlobalSchema globalSchema = new GlobalSchema("Test");
          EJBSchema ejbSchema = new EJBSchema("Test");
          SQL92Schema sqlSchema = new SQL92Schema("Test", null, null);
  
          File tempDir = DeploymentUtil.createTempDir();
          try {
              EARContext earContext = new EARContext(tempDir,
                      new URI("test"),
                      ConfigurationModuleType.EJB,
                      KernelHelper.DEFAULT_PARENTID_LIST,
                      kernel,
                      "null",
                      null,
                      null,
                      null,
                      null,
                      null, null);
              J2eeContext moduleJ2eeContext = new 
J2eeContextImpl("geronimo.server", "TestGeronimoServer", "null", 
NameFactory.EJB_MODULE, "MockModule", null, null);
              ClassLoader cl = Thread.currentThread().getContextClassLoader();
              builder.buildCMPSchema(earContext, moduleJ2eeContext, ejbJarType, 
openejbJarType, cl, ejbSchema, sqlSchema, globalSchema, pkGen, null);
  
              assertOneToOneEntity(ejbSchema.getEntity("A"), 
ejbSchema.getEntity("B"));
              assertOneToOneEntity(sqlSchema.getEntity("A"), 
sqlSchema.getEntity("B"));
          } finally {
              DeploymentUtil.recursiveDelete(tempDir);
          }
      }
  
      public void testOneToMany() throws Exception {
          executeOneToMany("src/test/test-cmp/onetomany/simplepk/ejb-jar.xml", 
"src/test/test-cmp/onetomany/simplepk/openejb-jar.xml");
      }
  
      public void testOneToManyUnidirectional() throws Exception {
          executeOneToMany("src/test/test-cmp/onetomany/simplepk/ejb-jar.xml", 
"src/test/test-cmp/onetomany/simplepk/unidirectional-openejb-jar.xml");
      }
  
      public void executeOneToMany(String ejbJarFileName, String 
openejbJarFileName) throws Exception {
          File ejbJarFile = new File(basedir, ejbJarFileName);
          File openejbJarFile = new File(basedir, openejbJarFileName);
          EjbJarType ejbJarType = ((EjbJarDocument) 
XmlObject.Factory.parse(ejbJarFile)).getEjbJar();
          OpenejbOpenejbJarType openejbJarType = ((OpenejbOpenejbJarDocument) 
XmlObject.Factory.parse(openejbJarFile)).getOpenejbJar();
  
          OpenEJBModuleBuilder moduleBuilder = new 
OpenEJBModuleBuilder(KernelHelper.DEFAULT_PARENTID_ARRAY, listener, null, null, 
repository, kernel);
          CMPEntityBuilder builder = new CMPEntityBuilder(moduleBuilder);
          TranQLPKGenBuilder pkGen = new TranQLPKGenBuilder();
  
          GlobalSchema globalSchema = new GlobalSchema("Test");
          EJBSchema ejbSchema = new EJBSchema("Test");
          SQL92Schema sqlSchema = new SQL92Schema("Test", null, null);
  
          File tempDir = DeploymentUtil.createTempDir();
          try {
              EARContext earContext = new EARContext(tempDir,
                      new URI("test"),
                      ConfigurationModuleType.EJB,
                      KernelHelper.DEFAULT_PARENTID_LIST,
                      kernel,
                      "null",
                      null,
                      null,
                      null,
                      null,
                      null, null);
  
              J2eeContext moduleJ2eeContext = new 
J2eeContextImpl("geronimo.server", "TestGeronimoServer", "null", 
NameFactory.EJB_MODULE, "MockModule", null, null);
               ClassLoader cl = Thread.currentThread().getContextClassLoader();
              builder.buildCMPSchema(earContext, moduleJ2eeContext, ejbJarType, 
openejbJarType, cl, ejbSchema, sqlSchema, globalSchema, pkGen, null);
  
              assertOneToManyEntity(ejbSchema.getEntity("A"), 
ejbSchema.getEntity("B"));
              assertOneToManyEntity(sqlSchema.getEntity("A"), 
sqlSchema.getEntity("B"));
          } finally {
              DeploymentUtil.recursiveDelete(tempDir);
          }
      }
  
      public void testManyToMany() throws Exception {
          
executeManyToMany("src/test/test-cmp/manytomany/simplepk/ejb-jar.xml", 
"src/test/test-cmp/manytomany/simplepk/openejb-jar.xml");
      }
  
      public void testManyToManyUnidirectional() throws Exception {
          
executeManyToMany("src/test/test-cmp/manytomany/simplepk/ejb-jar.xml", 
"src/test/test-cmp/manytomany/simplepk/unidirectional-openejb-jar.xml");
      }
  
      public void executeManyToMany(String ejbJarFileName, String 
openejbJarFileName) throws Exception {
          File ejbJarFile = new File(basedir, ejbJarFileName);
          File openejbJarFile = new File(basedir, openejbJarFileName);
          EjbJarType ejbJarType = ((EjbJarDocument) 
XmlObject.Factory.parse(ejbJarFile)).getEjbJar();
          OpenejbOpenejbJarType openejbJarType = ((OpenejbOpenejbJarDocument) 
XmlObject.Factory.parse(openejbJarFile)).getOpenejbJar();
  
          OpenEJBModuleBuilder moduleBuilder = new 
OpenEJBModuleBuilder(KernelHelper.DEFAULT_PARENTID_ARRAY, listener, null, null, 
repository, kernel);
          CMPEntityBuilder builder = new CMPEntityBuilder(moduleBuilder);
          TranQLPKGenBuilder pkGen = new TranQLPKGenBuilder();
  
          GlobalSchema globalSchema = new GlobalSchema("Test");
          EJBSchema ejbSchema = new EJBSchema("Test");
          SQL92Schema sqlSchema = new SQL92Schema("Test", null, null);
  
          File tempDir = DeploymentUtil.createTempDir();
          try {
              EARContext earContext = new EARContext(tempDir,
                      new URI("test"),
                      ConfigurationModuleType.EJB,
                      KernelHelper.DEFAULT_PARENTID_LIST,
                      kernel,
                      "null",
                      null,
                      null,
                      null,
                      null,
                      null, null);
  
              J2eeContext moduleJ2eeContext = new 
J2eeContextImpl("geronimo.server", "TestGeronimoServer", "null", 
NameFactory.EJB_MODULE, "MockModule", null, null);
               ClassLoader cl = Thread.currentThread().getContextClassLoader();
              builder.buildCMPSchema(earContext, moduleJ2eeContext, ejbJarType, 
openejbJarType, cl, ejbSchema, sqlSchema, globalSchema, pkGen, null);
  
              assertManyToManyEntity(ejbSchema.getEntity("A"), 
ejbSchema.getEntity("B"));
              assertManyToManyEntity(sqlSchema.getEntity("A"), 
sqlSchema.getEntity("B"));
          } finally {
              DeploymentUtil.recursiveDelete(tempDir);
          }
      }
  
      private void assertEntity(Entity leftEntity, Entity rightEntity) {
          List attributes = leftEntity.getAttributes();
          assertEquals(2, attributes.size());
          for (Iterator iter = attributes.iterator(); iter.hasNext();) {
              Attribute att = (Attribute) iter.next();
              if ( leftEntity instanceof Table ) {
                  if ( att.getName().equals("field1") ) {
                      assertTrue(att.getPhysicalName().equals("a1"));
                      assertTrue(att.isIdentity());
                  } else if ( att.getName().equals("field2") ) {
                      assertTrue(att.getPhysicalName().equals("a2"));
                  } else {
                      fail("Unknow field.");
                  }
              } else {
                  if ( att.getName().equals("field1") ) {
                      assertTrue(att.getPhysicalName().equals("field1"));
                      assertTrue(att.isIdentity());
                  } else if ( att.getName().equals("field2") ) {
                      assertTrue(att.getPhysicalName().equals("field2"));
                  } else {
                      fail("Unknow field.");
                  }
              }
          }
          attributes = rightEntity.getAttributes();
          assertEquals(3, attributes.size());
          for (Iterator iter = attributes.iterator(); iter.hasNext();) {
              Attribute att = (Attribute) iter.next();
              if ( rightEntity instanceof Table ) {
                  if ( att.getName().equals("field1") ) {
                      assertTrue(att.getPhysicalName().equals("b1"));
                      assertTrue(att.isIdentity());
                  } else if ( att.getName().equals("field2") ) {
                      assertTrue(att.getPhysicalName().equals("b2"));
                  } else if ( att.getName().equals("field3") ) {
                      assertTrue(att.getPhysicalName().equals("fka1"));
                  } else {
                      fail("Unknow field.");
                  }
              } else {
                  if ( att.getName().equals("field1") ) {
                      assertTrue(att.getPhysicalName().equals("field1"));
                      assertTrue(att.isIdentity());
                  } else if ( att.getName().equals("field2") ) {
                      assertTrue(att.getPhysicalName().equals("field2"));
                  } else if ( att.getName().equals("field3") ) {
                      assertTrue(att.getPhysicalName().equals("field3"));
                  } else if ( att.getName().equals("field4") ) {
                      assertTrue(att.getPhysicalName().equals("field4"));
                  } else {
                      fail("Unknow field.");
                  }
              }
          }
  
          List pkEnds = leftEntity.getAssociationEnds();
          List fkEnds = rightEntity.getAssociationEnds();
          assertEquals(1, pkEnds.size());
          assertEquals(1, fkEnds.size());
          AssociationEnd pkEnd = (AssociationEnd) pkEnds.get(0);
          AssociationEnd fkEnd = (AssociationEnd) fkEnds.get(0);
          assertEquals("b", pkEnd.getName());
          assertEquals("a", fkEnd.getName());
          assertEquals(rightEntity, pkEnd.getEntity());
          assertEquals(leftEntity, fkEnd.getEntity());
  
          Association association = pkEnd.getAssociation();
          assertTrue(association == fkEnd.getAssociation());
      }
  
      private void assertOneToOneEntity(Entity pkEntity, Entity fkEntity) {
          assertEntity(pkEntity, fkEntity);
  
          List pkEnds = pkEntity.getAssociationEnds();
          List fkEnds = fkEntity.getAssociationEnds();
          AssociationEnd pkEnd = (AssociationEnd) pkEnds.get(0);
          assertTrue(pkEnd.isSingle());
          AssociationEnd fkEnd = (AssociationEnd) fkEnds.get(0);
          assertTrue(fkEnd.isSingle());
  
          Association association = pkEnd.getAssociation();
          assertTrue(pkEnd.isOneToOne());
          JoinDefinition joinDefinition = association.getJoinDefinition();
          assertEquals(pkEntity, joinDefinition.getPKEntity());
          assertEquals(fkEntity, joinDefinition.getFKEntity());
          LinkedHashMap linkedHashMap = joinDefinition.getPKToFKMapping();
          for (Iterator iter = linkedHashMap.entrySet().iterator(); 
iter.hasNext();) {
              Map.Entry entry = (Map.Entry) iter.next();
              if ( pkEntity instanceof Table ) {
                  assertEquals("a1", ((Attribute) 
entry.getKey()).getPhysicalName());
              } else {
                  assertEquals("field1", ((Attribute) 
entry.getKey()).getPhysicalName());
              }
              assertEquals("fka1", ((FKAttribute) 
entry.getValue()).getPhysicalName());
          }
      }
  
      private void assertOneToManyEntity(Entity pkEntity, Entity fkEntity) {
          assertEntity(pkEntity, fkEntity);
  
          List pkEnds = pkEntity.getAssociationEnds();
          List fkEnds = fkEntity.getAssociationEnds();
          AssociationEnd pkEnd = (AssociationEnd) pkEnds.get(0);
          assertTrue(pkEnd.isMulti());
          AssociationEnd fkEnd = (AssociationEnd) fkEnds.get(0);
          assertTrue(fkEnd.isSingle());
  
          Association association = pkEnd.getAssociation();
          assertTrue(pkEnd.isOneToMany());
          assertTrue(fkEnd.isManyToOne());
          JoinDefinition joinDefinition = association.getJoinDefinition();
          assertEquals(pkEntity, joinDefinition.getPKEntity());
          assertEquals(fkEntity, joinDefinition.getFKEntity());
          LinkedHashMap linkedHashMap = joinDefinition.getPKToFKMapping();
          for (Iterator iter = linkedHashMap.entrySet().iterator(); 
iter.hasNext();) {
              Map.Entry entry = (Map.Entry) iter.next();
              if ( pkEntity instanceof Table ) {
                  assertEquals("a1", ((Attribute) 
entry.getKey()).getPhysicalName());
              } else {
                  assertEquals("field1", ((Attribute) 
entry.getKey()).getPhysicalName());
              }
              assertEquals("fka1", ((FKAttribute) 
entry.getValue()).getPhysicalName());
          }
      }
  
      private void assertManyToManyEntity(Entity leftEntity, Entity 
rightEntity) {
          assertEntity(leftEntity, rightEntity);
  
          List leftEnds = leftEntity.getAssociationEnds();
          List rightEnds = rightEntity.getAssociationEnds();
          AssociationEnd leftEnd = (AssociationEnd) leftEnds.get(0);
          assertTrue(leftEnd.isMulti());
          AssociationEnd rightEnd = (AssociationEnd) rightEnds.get(0);
          assertTrue(rightEnd.isMulti());
  
          Association association = leftEnd.getAssociation();
          Entity mtmEntity = association.getManyToManyEntity();
          assertTrue(leftEnd.isManyToMany());
          assertNotNull(mtmEntity);
          assertEquals("MTM", mtmEntity.getName());
          JoinDefinition joinDefinition = association.getLeftJoinDefinition();
          boolean isMappedToFKA1 = false, isMappedToFKB1 = false; // we must be 
able to map both entities to the MTM table
          if ( leftEntity == joinDefinition.getPKEntity() ) {
              LinkedHashMap linkedHashMap = joinDefinition.getPKToFKMapping();
              for (Iterator iter = linkedHashMap.entrySet().iterator(); 
iter.hasNext();) {
                  Map.Entry entry = (Map.Entry) iter.next();
                  if ( leftEntity instanceof Table ) {
                      assertEquals("a1", ((Attribute) 
entry.getKey()).getPhysicalName());
                  } else {
                      assertEquals("field1", ((Attribute) 
entry.getKey()).getPhysicalName());
                  }
                  assertEquals("fka1", ((FKAttribute) 
entry.getValue()).getPhysicalName());
                  isMappedToFKA1 = true;
              }
          } else if ( rightEntity == joinDefinition.getPKEntity() ) {
              LinkedHashMap linkedHashMap = joinDefinition.getPKToFKMapping();
              for (Iterator iter = linkedHashMap.entrySet().iterator(); 
iter.hasNext();) {
                  Map.Entry entry = (Map.Entry) iter.next();
                  if ( rightEntity instanceof Table ) {
                      assertEquals("b1", ((Attribute) 
entry.getKey()).getPhysicalName());
                  } else {
                      assertEquals("field1", ((Attribute) 
entry.getKey()).getPhysicalName());
                  }
                  assertEquals("fkb1", ((FKAttribute) 
entry.getValue()).getPhysicalName());
                  isMappedToFKB1 = true;
              }
          } else {
              fail("JoinDefinitions are misconfigured.");
          }
          joinDefinition = association.getRightJoinDefinition();
          if ( leftEntity == joinDefinition.getPKEntity() ) {
              LinkedHashMap linkedHashMap = joinDefinition.getPKToFKMapping();
              for (Iterator iter = linkedHashMap.entrySet().iterator(); 
iter.hasNext();) {
                  Map.Entry entry = (Map.Entry) iter.next();
                  if ( leftEntity instanceof Table ) {
                      assertEquals("a1", ((Attribute) 
entry.getKey()).getPhysicalName());
                  } else {
                      assertEquals("field1", ((Attribute) 
entry.getKey()).getPhysicalName());
                  }
                  assertEquals("fka1", ((FKAttribute) 
entry.getValue()).getPhysicalName());
                  isMappedToFKA1 = true;
              }
          } else if ( rightEntity == joinDefinition.getPKEntity() ) {
              LinkedHashMap linkedHashMap = joinDefinition.getPKToFKMapping();
              for (Iterator iter = linkedHashMap.entrySet().iterator(); 
iter.hasNext();) {
                  Map.Entry entry = (Map.Entry) iter.next();
                  if ( rightEntity instanceof Table ) {
                      assertEquals("b1", ((Attribute) 
entry.getKey()).getPhysicalName());
                  } else {
                      assertEquals("field1", ((Attribute) 
entry.getKey()).getPhysicalName());
                  }
                  assertEquals("fkb1", ((FKAttribute) 
entry.getValue()).getPhysicalName());
                  isMappedToFKB1 = true;
              }
          } else {
              fail("JoinDefinitions are misconfigured.");
          }
          if(!isMappedToFKA1) {
              fail("No mapping present from A.a1 to MTM.fka1");
          }
          if(!isMappedToFKB1) {
              fail("No mapping present from B.b1 to MTM.fkb1");
          }
      }
  }
  
  
  1.1                  
openejb/m2/unit-tests/openejb-builder/src/test/java/org/openejb/deployment/EarDeploymentTest.java
  
  Index: EarDeploymentTest.java
  ===================================================================
  /* ====================================================================
   * Redistribution and use of this software and associated documentation
   * ("Software"), with or without modification, are permitted provided
   * that the following conditions are met:
   *
   * 1. Redistributions of source code must retain copyright
   *    statements and notices.  Redistributions must also contain a
   *    copy of this document.
   *
   * 2. Redistributions in binary form must reproduce this list of
   *    conditions and the following disclaimer in the documentation
   *    and/or other materials provided with the distribution.
   *
   * 3. The name "OpenEJB" must not be used to endorse or promote
   *    products derived from this Software without prior written
   *    permission of The OpenEJB Group.  For written permission,
   *    please contact [EMAIL PROTECTED]
   *
   * 4. Products derived from this Software may not be called "OpenEJB"
   *    nor may "OpenEJB" appear in their names without prior written
   *    permission of The OpenEJB Group. OpenEJB is a registered
   *    trademark of The OpenEJB Group.
   *
   * 5. Due credit should be given to the OpenEJB Project
   *    (http://openejb.org/).
   *
   * THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
   * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
   * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
   * THE OPENEJB GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
   * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the OpenEJB Project.  For more information
   * please see <http://openejb.org/>.
   *
   * ====================================================================
   */
  package org.openejb.deployment;
  
  import java.io.File;
  
  import junit.framework.Test;
  import org.apache.geronimo.kernel.Kernel;
  import org.apache.geronimo.kernel.Kernel;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2005/09/22 08:48:42 $
   */
  public class EarDeploymentTest extends AbstractDeploymentTest {
  
      private static final DeploymentTestSuite SUITE =
              new DeploymentTestSuite(EarDeploymentTest.class, new File( 
System.getProperty( "basedir", System.getProperty( "user.dir" ) ), 
"target/test-ear.ear"));
  
      public static Test suite() {
          return SUITE;
      }
  
      public String getJ2eeApplicationName() {
          return "org/apache/geronimo/j2ee/deployment/test";
      }
  
      public String getJ2eeModuleName() {
          return "test-ejb-jar.jar";
      }
  
      public Kernel getKernel() {
          return SUITE.getKernel();
      }
  
      public ClassLoader getApplicationClassLoader() {
          return SUITE.getApplicationClassLoader();
      }    
  }
  
  
  
  1.1                  
openejb/m2/unit-tests/openejb-builder/src/test/java/org/openejb/deployment/EjbJarModuleDeploymentTest.java
  
  Index: EjbJarModuleDeploymentTest.java
  ===================================================================
  /* ====================================================================
   * Redistribution and use of this software and associated documentation
   * ("Software"), with or without modification, are permitted provided
   * that the following conditions are met:
   *
   * 1. Redistributions of source code must retain copyright
   *    statements and notices.  Redistributions must also contain a
   *    copy of this document.
   *
   * 2. Redistributions in binary form must reproduce this list of
   *    conditions and the following disclaimer in the documentation
   *    and/or other materials provided with the distribution.
   *
   * 3. The name "OpenEJB" must not be used to endorse or promote
   *    products derived from this Software without prior written
   *    permission of The OpenEJB Group.  For written permission,
   *    please contact [EMAIL PROTECTED]
   *
   * 4. Products derived from this Software may not be called "OpenEJB"
   *    nor may "OpenEJB" appear in their names without prior written
   *    permission of The OpenEJB Group. OpenEJB is a registered
   *    trademark of The OpenEJB Group.
   *
   * 5. Due credit should be given to the OpenEJB Project
   *    (http://openejb.org/).
   *
   * THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
   * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
   * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
   * THE OPENEJB GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
   * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the OpenEJB Project.  For more information
   * please see <http://openejb.org/>.
   *
   * ====================================================================
   */
  package org.openejb.deployment;
  
  import java.io.File;
  
  import junit.framework.Test;
  import org.apache.geronimo.kernel.Kernel;
  import org.apache.geronimo.kernel.Kernel;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2005/09/22 08:48:42 $
   */
  public class EjbJarModuleDeploymentTest extends AbstractDeploymentTest {
      private static final DeploymentTestSuite SUITE =
              new DeploymentTestSuite(EjbJarModuleDeploymentTest.class, new 
File(System.getProperty( "basedir", System.getProperty( "user.dir" ) ), 
"target/test-ejb-jar.jar"));
  
      public static Test suite() {
          return SUITE;
      }
  
      public String getJ2eeApplicationName() {
          return "null";
      }
  
      public String getJ2eeModuleName() {
          return "org/openejb/deployment/test";
      }
  
      public Kernel getKernel() {
          return SUITE.getKernel();
      }
  
      public ClassLoader getApplicationClassLoader() {
          return SUITE.getApplicationClassLoader();
      }    
  }
  
  
  
  1.1                  
openejb/m2/unit-tests/openejb-builder/src/test/java/org/openejb/deployment/PlanParsingTest.java
  
  Index: PlanParsingTest.java
  ===================================================================
  package org.openejb.deployment;
  
  import java.io.File;
  
  import junit.framework.TestCase;
  import org.openejb.xbeans.ejbjar.OpenejbOpenejbJarType;
  import org.apache.geronimo.kernel.Kernel;
  import org.apache.geronimo.kernel.repository.Repository;
  
  /**
   */
  public class PlanParsingTest extends TestCase {
      private Repository repository = null;
  
      private OpenEJBModuleBuilder builder;
      File basedir = new File(System.getProperty("basedir", "."));
  
      protected void setUp() throws Exception {
          builder = new OpenEJBModuleBuilder(null, null, null, null, 
repository, null);
      }
  
      public void testResourceRef() throws Exception {
          File resourcePlan = new File(basedir, 
"src/test/test-resources/plans/plan1.xml");
          assertTrue(resourcePlan.exists());
          OpenejbOpenejbJarType openejbJar = 
builder.getOpenejbJar(resourcePlan, null, true, null, null);
          assertEquals(1, 
openejbJar.getEnterpriseBeans().getSessionArray()[0].getResourceRefArray().length);
          System.out.println(openejbJar.toString());
      }
  
  }
  
  
  
  1.1                  
openejb/m2/unit-tests/openejb-builder/src/test/java/org/openejb/deployment/UnpackedModuleDeploymentTest.java
  
  Index: UnpackedModuleDeploymentTest.java
  ===================================================================
  /* ====================================================================
   * Redistribution and use of this software and associated documentation
   * ("Software"), with or without modification, are permitted provided
   * that the following conditions are met:
   *
   * 1. Redistributions of source code must retain copyright
   *    statements and notices.  Redistributions must also contain a
   *    copy of this document.
   *
   * 2. Redistributions in binary form must reproduce this list of
   *    conditions and the following disclaimer in the documentation
   *    and/or other materials provided with the distribution.
   *
   * 3. The name "OpenEJB" must not be used to endorse or promote
   *    products derived from this Software without prior written
   *    permission of The OpenEJB Group.  For written permission,
   *    please contact [EMAIL PROTECTED]
   *
   * 4. Products derived from this Software may not be called "OpenEJB"
   *    nor may "OpenEJB" appear in their names without prior written
   *    permission of The OpenEJB Group. OpenEJB is a registered
   *    trademark of The OpenEJB Group.
   *
   * 5. Due credit should be given to the OpenEJB Project
   *    (http://openejb.org/).
   *
   * THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
   * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
   * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
   * THE OPENEJB GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
   * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the OpenEJB Project.  For more information
   * please see <http://openejb.org/>.
   *
   * ====================================================================
   */
  package org.openejb.deployment;
  
  import java.io.File;
  
  import junit.framework.Test;
  import org.apache.geronimo.kernel.Kernel;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2005/09/22 08:48:42 $
   */
  public class UnpackedModuleDeploymentTest extends AbstractDeploymentTest {
      private static final DeploymentTestSuite SUITE =
              new DeploymentTestSuite(UnpackedModuleDeploymentTest.class, new 
File(System.getProperty( "basedir", System.getProperty( "user.dir" ) ), 
"target/test-ejb-jar"));
  
      public static Test suite() {
          return SUITE;
      }
  
      public String getJ2eeApplicationName() {
          return "null";
      }
  
      public String getJ2eeModuleName() {
          return "org/openejb/deployment/test";
      }
  
      public Kernel getKernel() {
          return SUITE.getKernel();
      }
  
      public ClassLoader getApplicationClassLoader() {
          return SUITE.getApplicationClassLoader();
      }
  }
  
  
  

Reply via email to