tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r1004198 - in /openejb/branches/openejb-3.1.x/container/openejb-core: ./ src/main/java/org/apache/openejb/config/ src/main/java/org/apache/openejb/junit/ src/test/java/org/apache/openejb/ src/test/java/org/apache/openejb/config/ src/test/ja...
Date Mon, 04 Oct 2010 11:14:31 GMT
Author: dblevins
Date: Mon Oct  4 11:14:30 2010
New Revision: 1004198

URL: http://svn.apache.org/viewvc?rev=1004198&view=rev
Log:
OPENEJB-1364: @RunWith(ApplicationComposer.class) test runner allows for programmatic creation
of apps

Added:
    openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/junit/
      - copied from r1004172, openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/junit/
    openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/junit/ApplicationComposer.java
      - copied, changed from r1004172, openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/junit/ApplicationComposer.java
    openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/junit/Configuration.java
      - copied unchanged from r1004172, openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/junit/Configuration.java
    openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/junit/Module.java
      - copied unchanged from r1004172, openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/junit/Module.java
Modified:
    openejb/branches/openejb-3.1.x/container/openejb-core/pom.xml
    openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
    openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
    openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/JndiEncInfoBuilder.java
    openejb/branches/openejb-3.1.x/container/openejb-core/src/test/java/org/apache/openejb/DependenceValidationTest.java
    openejb/branches/openejb-3.1.x/container/openejb-core/src/test/java/org/apache/openejb/config/BusinessInterfacesTest.java
  (props changed)
    openejb/branches/openejb-3.1.x/container/openejb-core/src/test/java/org/apache/openejb/config/rules/InvalidEjbRefTest.java
    openejb/branches/openejb-3.1.x/container/openejb-core/src/test/java/org/apache/openejb/config/rules/InvalidInterfacesTest.java
    openejb/branches/openejb-3.1.x/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessContainerTest.java

Modified: openejb/branches/openejb-3.1.x/container/openejb-core/pom.xml
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/container/openejb-core/pom.xml?rev=1004198&r1=1004197&r2=1004198&view=diff
==============================================================================
--- openejb/branches/openejb-3.1.x/container/openejb-core/pom.xml (original)
+++ openejb/branches/openejb-3.1.x/container/openejb-core/pom.xml Mon Oct  4 11:14:30 2010
@@ -336,6 +336,7 @@
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
+      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>hsqldb</groupId>

Modified: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java?rev=1004198&r1=1004197&r2=1004198&view=diff
==============================================================================
--- openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
(original)
+++ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
Mon Oct  4 11:14:30 2010
@@ -2446,24 +2446,34 @@ public class AnnotationDeployer implemen
         }
 
         private boolean isLocalBean(Class clazz) {
-            DeploymentModule module = getModule();
-            if (module instanceof EjbModule) {
-                Set<String> localbeans = new HashSet<String>();
-                EjbModule ejbModule = (EjbModule) module;
-                for (EnterpriseBean bean : ejbModule.getEjbJar().getEnterpriseBeans()) {
-                    if (bean instanceof SessionBean) {
-                        if (((SessionBean) bean).getLocalBean() != null) {
-                            localbeans.add(bean.getEjbClass());
-                        }
-                    }
-                }
+            if (clazz.isAnnotation()) return false;
+            if (clazz.isArray()) return false;
+            if (clazz.isEnum()) return false;
+            if (clazz.isInterface()) return false;
+            if (clazz.isPrimitive()) return false;
+            if (Modifier.isAbstract(clazz.getModifiers())) return false;
+            if (Modifier.isFinal(clazz.getModifiers())) return false;
 
-                if (localbeans.contains(clazz.getName())) {
-                    return true;
-                }
-            }
-
-            return false;
+            return true;
+//            // This limits @LocalBean references to things in the same module
+//            DeploymentModule module = getModule();
+//            if (module instanceof EjbModule) {
+//                Set<String> localbeans = new HashSet<String>();
+//                EjbModule ejbModule = (EjbModule) module;
+//                for (EnterpriseBean bean : ejbModule.getEjbJar().getEnterpriseBeans())
{
+//                    if (bean instanceof SessionBean) {
+//                        if (((SessionBean) bean).getLocalBean() != null) {
+//                            localbeans.add(bean.getEjbClass());
+//                        }
+//                    }
+//                }
+//
+//                if (localbeans.contains(clazz.getName())) {
+//                    return true;
+//                }
+//            }
+//
+//            return false;
         }
 
         private boolean isValidEjbInterface(String b, Class clazz, String refName) {

Modified: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java?rev=1004198&r1=1004197&r2=1004198&view=diff
==============================================================================
--- openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
(original)
+++ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
Mon Oct  4 11:14:30 2010
@@ -406,7 +406,11 @@ public class ConfigurationFactory implem
         }
 
 
-        return sys;
+        final OpenEjbConfiguration finished = sys;
+        sys = null;
+        openejb = null;
+        return finished;
+//        return sys;
     }
 
     public ContainerInfo createContainerInfo(Container container) throws OpenEJBException
{

Modified: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/JndiEncInfoBuilder.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/JndiEncInfoBuilder.java?rev=1004198&r1=1004197&r2=1004198&view=diff
==============================================================================
--- openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/JndiEncInfoBuilder.java
(original)
+++ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/config/JndiEncInfoBuilder.java
Mon Oct  4 11:14:30 2010
@@ -429,7 +429,7 @@ public class JndiEncInfoBuilder {
     private EnterpriseBeanInfo getInterfaceBeanInfo(String moduleId, String interfaceClassName)
{
         List<EjbJarInfo> ejbJars = appInfo.ejbJars;
         for (EjbJarInfo ejbJar : ejbJars) {
-            if (!ejbJar.moduleId.equals(moduleId)) continue;
+//            if (!ejbJar.moduleId.equals(moduleId)) continue;
 
             List<EnterpriseBeanInfo> enterpriseBeans = ejbJar.enterpriseBeans;
             for (EnterpriseBeanInfo enterpriseBean : enterpriseBeans) {

Copied: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/junit/ApplicationComposer.java
(from r1004172, openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/junit/ApplicationComposer.java)
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/junit/ApplicationComposer.java?p2=openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/junit/ApplicationComposer.java&p1=openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/junit/ApplicationComposer.java&r1=1004172&r2=1004198&rev=1004198&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/junit/ApplicationComposer.java
(original)
+++ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/junit/ApplicationComposer.java
Mon Oct  4 11:14:30 2010
@@ -16,7 +16,7 @@
  */
 package org.apache.openejb.junit;
 
-import org.apache.openejb.BeanContext;
+import org.apache.openejb.DeploymentInfo;
 import org.apache.openejb.InjectionProcessor;
 import org.apache.openejb.assembler.classic.AppInfo;
 import org.apache.openejb.assembler.classic.Assembler;
@@ -25,11 +25,11 @@ import org.apache.openejb.config.Configu
 import org.apache.openejb.config.ConnectorModule;
 import org.apache.openejb.config.EjbModule;
 import org.apache.openejb.config.PersistenceModule;
+import org.apache.openejb.core.CoreDeploymentInfo;
 import org.apache.openejb.core.Operation;
 import org.apache.openejb.core.ThreadContext;
 import org.apache.openejb.core.ivm.naming.InitContextFactory;
 import org.apache.openejb.jee.Application;
-import org.apache.openejb.jee.Beans;
 import org.apache.openejb.jee.Connector;
 import org.apache.openejb.jee.EjbJar;
 import org.apache.openejb.jee.EnterpriseBean;
@@ -40,19 +40,17 @@ import org.apache.openejb.jee.oejb3.Open
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.spi.ContainerSystem;
 import org.apache.openejb.util.Join;
-import org.junit.rules.MethodRule;
 import org.junit.runners.BlockJUnit4ClassRunner;
 import org.junit.runners.model.FrameworkMethod;
 import org.junit.runners.model.InitializationError;
 import org.junit.runners.model.Statement;
 import org.junit.runners.model.TestClass;
 
+import javax.naming.Context;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
 
-import static org.apache.openejb.config.DeploymentsResolver.DEPLOYMENTS_CLASSPATH_PROPERTY;
-
 /**
  * @version $Rev$ $Date$
  */
@@ -85,7 +83,7 @@ public class ApplicationComposer extends
 
         int appModules = 0;
         int modules = 0;
-        Class[] moduleTypes = {EjbJar.class, EnterpriseBean.class, Persistence.class, Connector.class,
Beans.class, Application.class};
+        Class[] moduleTypes = {EjbJar.class, EnterpriseBean.class, Persistence.class, Connector.class};
         for (FrameworkMethod method : testClass.getAnnotatedMethods(Module.class)) {
 
             modules++;
@@ -125,14 +123,10 @@ public class ApplicationComposer extends
     }
 
     @Override
-    protected List<MethodRule> rules(Object test) {
-        final List<MethodRule> rules = super.rules(test);
-        rules.add(new MethodRule(){
-            public Statement apply(Statement base, FrameworkMethod method, Object target)
{
-                return new DeployApplication(target, base);
-            }
-        });
-        return rules;
+    protected Statement withAfters(FrameworkMethod method, Object target, Statement statement)
{
+        statement = super.withAfters(method, target, statement);
+        statement = new DeployApplication(target, statement);
+        return statement;
     }
 
     public class DeployApplication extends Statement {
@@ -184,39 +178,19 @@ public class ApplicationComposer extends
                     ejbJar.addEnterpriseBean(bean);
                     appModule.getEjbModules().add(new EjbModule(ejbJar));
 
-                } else if (obj instanceof Application) {
-
-                    application = (Application) obj;
-
                 } else if (obj instanceof Connector) {
 
                     final Connector connector = (Connector) obj;
-                    appModule.getConnectorModules().add(new ConnectorModule(connector));
+                    appModule.getResourceModules().add(new ConnectorModule(connector));
 
                 } else if (obj instanceof Persistence) {
 
                     final Persistence persistence = (Persistence) obj;
                     appModule.getPersistenceModules().add(new PersistenceModule("", persistence));
 
-                } else if (obj instanceof Beans) {
-
-                    final Beans beans = (Beans) obj;
-                    final EjbModule ejbModule = new EjbModule(new EjbJar());
-                    ejbModule.setBeans(beans);
-                    appModule.getEjbModules().add(ejbModule);
                 }
             }
 
-            // Application is final in AppModule, which is fine, so we'll create a new one
and move everything
-            if (application != null) {
-                final AppModule newModule = new AppModule(appModule.getClassLoader(), appModule.getModuleId(),
application, false);
-                newModule.getClientModules().addAll(appModule.getClientModules());
-                newModule.getPersistenceModules().addAll(appModule.getPersistenceModules());
-                newModule.getEjbModules().addAll(appModule.getEjbModules());
-                newModule.getConnectorModules().addAll(appModule.getConnectorModules());
-                appModule = newModule;
-            }
-
             // For the moment we just take the first @Configuration method
             // maybe later we can add something fancy to allow multiple configurations using
a qualifier
             // as a sort of altDD/altConfig concept.  Say for example the altDD prefix might
be "foo",
@@ -226,7 +200,7 @@ public class ApplicationComposer extends
             // anyway, one thing at a time ....
 
             final Properties configuration = new Properties();
-            configuration.put(DEPLOYMENTS_CLASSPATH_PROPERTY, "false");
+            configuration.put("openejb.deployments.classpath", "false");
 
             final List<FrameworkMethod> methods = testClass.getAnnotatedMethods(Configuration.class);
             for (FrameworkMethod method : methods) {
@@ -255,9 +229,11 @@ public class ApplicationComposer extends
 
                 try {
                     final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
-                    final BeanContext context = containerSystem.getBeanContext(javaClass.getName());
+                    final CoreDeploymentInfo context = (CoreDeploymentInfo) containerSystem.getDeploymentInfo(javaClass.getName());
 
-                    InjectionProcessor processor = new InjectionProcessor(testInstance, context.getInjections(),
context.getJndiContext());
+                    Context jndi = (Context) context.getJndiEnc().lookup("comp/env");
+                    
+                    InjectionProcessor processor = new InjectionProcessor(testInstance, context.getInjections(),
jndi);
 
                     processor.createInstance();
 
@@ -271,7 +247,7 @@ public class ApplicationComposer extends
                     }
 
                 } finally {
-                    assembler.destroyApplication(appInfo.path);
+                    assembler.destroyApplication(appInfo.jarPath);
                 }
             } finally {
                 SystemInstance.reset();

Modified: openejb/branches/openejb-3.1.x/container/openejb-core/src/test/java/org/apache/openejb/DependenceValidationTest.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/container/openejb-core/src/test/java/org/apache/openejb/DependenceValidationTest.java?rev=1004198&r1=1004197&r2=1004198&view=diff
==============================================================================
--- openejb/branches/openejb-3.1.x/container/openejb-core/src/test/java/org/apache/openejb/DependenceValidationTest.java
(original)
+++ openejb/branches/openejb-3.1.x/container/openejb-core/src/test/java/org/apache/openejb/DependenceValidationTest.java
Mon Oct  4 11:14:30 2010
@@ -54,16 +54,16 @@ public class DependenceValidationTest ex
 
         // Nothing may depend on the Assembler except the config code
         String dynamicAssembler = "org.apache.openejb.assembler.dynamic";
-        assertNotDependentOn("org.apache.openejb", "org.apache.openejb.assembler.classic",
"org.apache.openejb.assembler", "org.apache.openejb.config", "org.apache.openejb.assembler.dynamic",
"org.apache.openejb.assembler.classic.cmd");
+        assertNotDependentOn("org.apache.openejb", "org.apache.openejb.assembler.classic",
"org.apache.openejb.assembler", "org.apache.openejb.config", "org.apache.openejb.assembler.dynamic",
"org.apache.openejb.assembler.classic.cmd", "org.apache.openejb.cdi", "org.apache.openejb.junit");
 
         // Nothing may depend on the Dynamic Assembler
         assertNotDependentOn("org.apache.openejb", dynamicAssembler);
 
         // Nothing may depend on the JAXB Tree except the Config code
-        assertNotDependentOn("org.apache.openejb", "org.apache.openejb.jee", "org.apache.openejb.config",
"org.apache.openejb.config.rules", "org.apache.openejb.config.sys");
+        assertNotDependentOn("org.apache.openejb", "org.apache.openejb.jee", "org.apache.openejb.config",
"org.apache.openejb.config.rules", "org.apache.openejb.config.sys", "org.apache.openejb.cdi",
"org.apache.openejb.junit");
 
         // Nothing may depend on the Config code except it's subpackages
-        assertNotDependentOn("org.apache.openejb", "org.apache.openejb.config", "org.apache.openejb.config.rules",
"org.apache.openejb.config.sys", "org.apache.openejb.assembler",  dynamicAssembler);
+        assertNotDependentOn("org.apache.openejb", "org.apache.openejb.config", "org.apache.openejb.config.rules",
"org.apache.openejb.config.sys", "org.apache.openejb.assembler", "org.apache.openejb.cdi",
"org.apache.openejb.junit", dynamicAssembler);
 
         // The assembler may not be dependent on the config factory Implementation
         assertNotDependentOn("org.apache.openejb.assembler.classic", "org.apache.openejb.config");

Propchange: openejb/branches/openejb-3.1.x/container/openejb-core/src/test/java/org/apache/openejb/config/BusinessInterfacesTest.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Oct  4 11:14:30 2010
@@ -1,2 +1,2 @@
 /openejb/branches/openejb-3.1.1/container/openejb-core/src/test/java/org/apache/openejb/config/UberInterfaceTest.java:779593
-/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/BusinessInterfacesTest.java:943472,943862,943965,944757,945989,946399,946485,946489,946705,946792,946805,946814,946861,946863-946864,947010,947017,947042,948022,948241,948548,949014,949233,950391,950801,951611,953191,953196,953556,955104,955496,957463,962382,962750,987030
+/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/BusinessInterfacesTest.java:943472,943862,943965,944757,945989,946399,946485,946489,946705,946792,946805,946814,946861,946863-946864,947010,947017,947042,948022,948241,948548,949014,949233,950391,950801,951611,953191,953196,953556,955104,955496,957463,962382,962750,987030,1004172

Modified: openejb/branches/openejb-3.1.x/container/openejb-core/src/test/java/org/apache/openejb/config/rules/InvalidEjbRefTest.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/container/openejb-core/src/test/java/org/apache/openejb/config/rules/InvalidEjbRefTest.java?rev=1004198&r1=1004197&r2=1004198&view=diff
==============================================================================
--- openejb/branches/openejb-3.1.x/container/openejb-core/src/test/java/org/apache/openejb/config/rules/InvalidEjbRefTest.java
(original)
+++ openejb/branches/openejb-3.1.x/container/openejb-core/src/test/java/org/apache/openejb/config/rules/InvalidEjbRefTest.java
Mon Oct  4 11:14:30 2010
@@ -17,6 +17,7 @@
 package org.apache.openejb.config.rules;
 
 import junit.framework.TestCase;
+import org.apache.openejb.assembler.classic.Assembler;
 import org.apache.openejb.assembler.classic.ContainerSystemInfo;
 import org.apache.openejb.assembler.classic.StatelessSessionContainerInfo;
 import org.apache.openejb.config.ConfigurationFactory;
@@ -40,8 +41,6 @@ import java.util.List;
  */
 public class InvalidEjbRefTest extends TestCase {
 
-    private ConfigurationFactory config;
-
     public void test() throws Exception {
 
         EjbJar ejbJar = new EjbJar();
@@ -63,10 +62,12 @@ public class InvalidEjbRefTest extends T
         List<String> expectedKeys = new ArrayList<String>();
         expectedKeys.add("ann.ejb.ejbObject");
         expectedKeys.add("ann.ejb.ejbLocalObject");
-        expectedKeys.add("ann.ejb.beanClass");
-        expectedKeys.add("ann.ejb.notInterface");
+//        expectedKeys.add("ann.ejb.beanClass");
+//        expectedKeys.add("ann.ejb.notInterface");
 
         try {
+            Assembler assembler = new Assembler();
+            ConfigurationFactory config = new ConfigurationFactory();
             config.configureApplication(ejbJar);
             fail("A ValidationFailedException should have been thrown");
         } catch (ValidationFailedException e) {
@@ -74,12 +75,12 @@ public class InvalidEjbRefTest extends T
         }
     }
 
-    public void setUp() throws Exception {
-        config = new ConfigurationFactory(true);
-        ContainerSystemInfo containerSystem = config.getOpenEjbConfiguration().containerSystem;
-        containerSystem.containers.add(config.configureService(StatelessSessionContainerInfo.class));
-    }
-
+//    public void setUp() throws Exception {
+//        config = new ConfigurationFactory(true);
+//        ContainerSystemInfo containerSystem = config.getOpenEjbConfiguration().containerSystem;
+//        containerSystem.containers.add(config.configureService(StatelessSessionContainerInfo.class));
+//    }
+//
 
     public static class EjbRefBean implements EjbRefBeanLocal {
         // valid because fooBean will be a LocalBean (because it has no interfaces)

Modified: openejb/branches/openejb-3.1.x/container/openejb-core/src/test/java/org/apache/openejb/config/rules/InvalidInterfacesTest.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/container/openejb-core/src/test/java/org/apache/openejb/config/rules/InvalidInterfacesTest.java?rev=1004198&r1=1004197&r2=1004198&view=diff
==============================================================================
--- openejb/branches/openejb-3.1.x/container/openejb-core/src/test/java/org/apache/openejb/config/rules/InvalidInterfacesTest.java
(original)
+++ openejb/branches/openejb-3.1.x/container/openejb-core/src/test/java/org/apache/openejb/config/rules/InvalidInterfacesTest.java
Mon Oct  4 11:14:30 2010
@@ -18,6 +18,7 @@ package org.apache.openejb.config.rules;
 
 import static org.apache.openejb.util.Join.join;
 import junit.framework.TestCase;
+import org.apache.openejb.assembler.classic.Assembler;
 import org.apache.openejb.assembler.classic.ContainerSystemInfo;
 import org.apache.openejb.assembler.classic.StatelessSessionContainerInfo;
 import org.apache.openejb.config.ConfigurationFactory;
@@ -54,6 +55,8 @@ public class InvalidInterfacesTest exten
         bean.addBusinessRemote(FooRemote.class.getName());
 
         try {
+            Assembler assembler = new Assembler();
+            ConfigurationFactory config = new ConfigurationFactory();
             config.configureApplication(ejbJar);
         } catch (ValidationFailedException e) {
             for (ValidationFailure failure : e.getFailures()) {
@@ -189,9 +192,8 @@ public class InvalidInterfacesTest exten
     }
 
     public void setUp() throws Exception {
-        config = new ConfigurationFactory(true);
-        ContainerSystemInfo containerSystem = config.getOpenEjbConfiguration().containerSystem;
-        containerSystem.containers.add(config.configureService(StatelessSessionContainerInfo.class));
+        Assembler assembler = new Assembler();
+        config = new ConfigurationFactory();
     }
 
     public static class FooBean {

Modified: openejb/branches/openejb-3.1.x/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessContainerTest.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessContainerTest.java?rev=1004198&r1=1004197&r2=1004198&view=diff
==============================================================================
--- openejb/branches/openejb-3.1.x/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessContainerTest.java
(original)
+++ openejb/branches/openejb-3.1.x/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessContainerTest.java
Mon Oct  4 11:14:30 2010
@@ -18,41 +18,46 @@
 package org.apache.openejb.core.stateless;
 
 import junit.framework.TestCase;
-import org.apache.openejb.assembler.classic.*;
-import org.apache.openejb.assembler.classic.cmd.Info2Properties;
-import org.apache.openejb.config.ConfigurationFactory;
-import org.apache.openejb.core.ivm.naming.InitContextFactory;
-import org.apache.openejb.jee.EjbJar;
 import org.apache.openejb.jee.EmptyType;
 import org.apache.openejb.jee.StatelessBean;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.junit.Configuration;
+import org.apache.openejb.junit.Module;
+import org.junit.Test;
+import org.junit.runner.RunWith;
 
+import javax.ejb.EJB;
 import javax.ejb.SessionContext;
-import javax.naming.InitialContext;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Properties;
 import java.util.Stack;
 
 /**
  * @version $Revision$ $Date$
  */
+@RunWith(ApplicationComposer.class)
 public class StatelessContainerTest extends TestCase {
 
+    @EJB
+    private WidgetBean localBean;
+
+    @EJB
+    private Widget local;
+
+    @EJB
+    private RemoteWidget remote;
+
+    @Test
     public void testPojoStyleBean() throws Exception {
         List expected = Arrays.asList(Lifecycle.values());
-        InitialContext ctx = new InitialContext();
 
         {
             WidgetBean.lifecycle.clear();
 
-            Object object = ctx.lookup("WidgetBeanLocal");
-
-            assertTrue("instanceof widget", object instanceof Widget);
-
-            Widget widget = (Widget) object;
-
             // Do a business method...
-            Stack<Lifecycle> lifecycle = widget.getLifecycle();
+            Stack<Lifecycle> lifecycle = local.getLifecycle();
             assertNotNull("lifecycle", lifecycle);
             assertSame("lifecycle", lifecycle, WidgetBean.lifecycle);
 
@@ -62,20 +67,13 @@ public class StatelessContainerTest exte
         {
             WidgetBean.lifecycle.clear();
 
-            Object object = ctx.lookup("WidgetBeanLocalBean");
-
-            assertTrue("instanceof widgetbean", object instanceof WidgetBean);
-
-            WidgetBean widget = (WidgetBean) object;
-
             // Do a business method...
-            Stack<Lifecycle> lifecycle = widget.getLifecycle();
+            Stack<Lifecycle> lifecycle = localBean.getLifecycle();
             assertNotNull("lifecycle", lifecycle);
             assertSame("lifecycle", lifecycle, WidgetBean.lifecycle);
 
             // Check the lifecycle of the bean
             List localBeanExpected = new ArrayList();
-            localBeanExpected.add(0, Lifecycle.CONSTRUCTOR);
             localBeanExpected.addAll(expected);
             assertEquals(join("\n", localBeanExpected), join("\n", lifecycle));
         }
@@ -83,57 +81,38 @@ public class StatelessContainerTest exte
 
             WidgetBean.lifecycle.clear();
 
-            Object object = ctx.lookup("WidgetBeanRemote");
-
-            assertTrue("instanceof widget", object instanceof RemoteWidget);
-
-            RemoteWidget remoteWidget = (RemoteWidget) object;
-
             // Do a business method...
-            Stack<Lifecycle> lifecycle = remoteWidget.getLifecycle();
+            Stack<Lifecycle> lifecycle = remote.getLifecycle();
             assertNotNull("lifecycle", lifecycle);
             assertNotSame("lifecycle", lifecycle, WidgetBean.lifecycle);
 
             // Check the lifecycle of the bean
             assertEquals(join("\n", expected), join("\n", lifecycle));
         }
-
-        Info2Properties.printLocalConfig();
     }
 
-    protected void setUp() throws Exception {
-        super.setUp();
-
-        System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
-
-        ConfigurationFactory config = new ConfigurationFactory();
-        Assembler assembler = new Assembler();
+    @Configuration
+    public Properties config() {
+        final Properties properties = new Properties();
+        properties.put("statelessContainer", "new://Container?type=STATELESS");
+        properties.put("statelessContainer.TimeOut", "10");
+        properties.put("statelessContainer.MaxSize", "0");
+        properties.put("statelessContainer.StrictPooling", "false");
 
-        assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
-        assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
-        assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
-
-        // containers
-        StatelessSessionContainerInfo statelessContainerInfo = config.configureService(StatelessSessionContainerInfo.class);
-        statelessContainerInfo.properties.setProperty("TimeOut", "10");
-        statelessContainerInfo.properties.setProperty("MaxSize", "0");
-        statelessContainerInfo.properties.setProperty("StrictPooling", "false");
-        assembler.createContainer(statelessContainerInfo);
+        return properties;
+    }
 
-        // Setup the descriptor information
+    @Module
+    public StatelessBean app() throws Exception {
 
-        StatelessBean bean = new StatelessBean(WidgetBean.class);
+        final StatelessBean bean = new StatelessBean(WidgetBean.class);
         bean.addBusinessLocal(Widget.class.getName());
         bean.addBusinessRemote(RemoteWidget.class.getName());
         bean.addPostConstruct("init");
         bean.addPreDestroy("destroy");
         bean.setLocalBean(new EmptyType());
 
-        EjbJar ejbJar = new EjbJar();
-        ejbJar.addEnterpriseBean(bean);
-
-        assembler.createApplication(config.configureApplication(ejbJar));
-
+        return bean;
     }
 
     private static String join(String delimeter, List items) {



Mime
View raw message