Search in sources :

Example 26 with AppModule

use of org.apache.openejb.config.AppModule in project tomee by apache.

the class CheckPersistenceContextUsageTest method noUnitName.

@Keys({ @Key(value = "persistenceContextRef.noUnitName"), @Key(value = "persistenceContextRef.noMatches") })
public AppModule noUnitName() {
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean(FooStatelessOne.class));
    final EjbModule ejbModule = new EjbModule(ejbJar);
    final AppModule appModule = new AppModule(ejbModule.getClassLoader(), ejbModule.getJarLocation());
    appModule.getEjbModules().add(ejbModule);
    final PersistenceUnit pu = new PersistenceUnit("fooUnit");
    final PersistenceUnit pu1 = new PersistenceUnit("fooUnit1");
    final PersistenceUnit pu2 = new PersistenceUnit("fooUnit");
    final org.apache.openejb.jee.jpa.unit.Persistence p = new org.apache.openejb.jee.jpa.unit.Persistence(pu, pu1, pu2);
    final PersistenceModule pm = new PersistenceModule("foo", p);
    appModule.addPersistenceModule(pm);
    return appModule;
}
Also used : AppModule(org.apache.openejb.config.AppModule) EjbModule(org.apache.openejb.config.EjbModule) PersistenceModule(org.apache.openejb.config.PersistenceModule) PersistenceUnit(org.apache.openejb.jee.jpa.unit.PersistenceUnit) StatelessBean(org.apache.openejb.jee.StatelessBean) EjbJar(org.apache.openejb.jee.EjbJar)

Example 27 with AppModule

use of org.apache.openejb.config.AppModule in project tomee by apache.

the class CheckPersistenceContextUsageTest method vagueMatches.

@Keys({ @Key(value = "persistenceContextRef.vagueMatches") })
public AppModule vagueMatches() {
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean(FooStatelessTwo.class));
    final EjbModule ejbModule = new EjbModule(ejbJar);
    final AppModule appModule = new AppModule(ejbModule.getClassLoader(), ejbModule.getJarLocation());
    appModule.getEjbModules().add(ejbModule);
    final PersistenceUnit pu = new PersistenceUnit("fooUnit");
    final org.apache.openejb.jee.jpa.unit.Persistence p = new org.apache.openejb.jee.jpa.unit.Persistence(pu);
    final PersistenceModule pm = new PersistenceModule("foo", p);
    appModule.getPersistenceModules().add(pm);
    final PersistenceUnit pu1 = new PersistenceUnit("fooUnit");
    final org.apache.openejb.jee.jpa.unit.Persistence p1 = new org.apache.openejb.jee.jpa.unit.Persistence(pu1);
    final PersistenceModule pm1 = new PersistenceModule("foo1", p1);
    appModule.addPersistenceModule(pm1);
    return appModule;
}
Also used : AppModule(org.apache.openejb.config.AppModule) EjbModule(org.apache.openejb.config.EjbModule) PersistenceModule(org.apache.openejb.config.PersistenceModule) PersistenceUnit(org.apache.openejb.jee.jpa.unit.PersistenceUnit) StatelessBean(org.apache.openejb.jee.StatelessBean) EjbJar(org.apache.openejb.jee.EjbJar)

Example 28 with AppModule

use of org.apache.openejb.config.AppModule in project tomee by apache.

the class CheckPersistenceUnitUsageTest method vagueMatches.

@Keys({ @Key(value = "persistenceUnitRef.vagueMatches") })
public AppModule vagueMatches() {
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean(FooStatelessTwo.class));
    final EjbModule ejbModule = new EjbModule(ejbJar);
    final AppModule appModule = new AppModule(ejbModule.getClassLoader(), ejbModule.getJarLocation());
    appModule.getEjbModules().add(ejbModule);
    final PersistenceUnit pu = new PersistenceUnit("fooUnit");
    final org.apache.openejb.jee.jpa.unit.Persistence p = new org.apache.openejb.jee.jpa.unit.Persistence(pu);
    final PersistenceModule pm = new PersistenceModule("foo", p);
    appModule.getPersistenceModules().add(pm);
    final PersistenceUnit pu1 = new PersistenceUnit("fooUnit");
    final org.apache.openejb.jee.jpa.unit.Persistence p1 = new org.apache.openejb.jee.jpa.unit.Persistence(pu1);
    final PersistenceModule pm1 = new PersistenceModule("foo1", p1);
    appModule.addPersistenceModule(pm1);
    return appModule;
}
Also used : AppModule(org.apache.openejb.config.AppModule) EjbModule(org.apache.openejb.config.EjbModule) PersistenceModule(org.apache.openejb.config.PersistenceModule) PersistenceUnit(org.apache.openejb.jee.jpa.unit.PersistenceUnit) StatelessBean(org.apache.openejb.jee.StatelessBean) EjbJar(org.apache.openejb.jee.EjbJar)

Example 29 with AppModule

use of org.apache.openejb.config.AppModule in project tomee by apache.

the class InvokeMethod method evaluate.

@Override
public void evaluate() throws Throwable {
    final Map<Integer, List<String>> expectedKeys = validateKeys();
    setUp();
    final Object obj = testMethod.invokeExplosively(target);
    final String outputDescriptors = SystemInstance.get().getProperty(OutputGeneratedDescriptors.OUTPUT_DESCRIPTORS, "false");
    try {
        SystemInstance.get().setProperty(OutputGeneratedDescriptors.OUTPUT_DESCRIPTORS, "false");
        ValidationContext vc = null;
        if (obj instanceof EjbJar) {
            final EjbJar ejbJar = (EjbJar) obj;
            final EjbModule ejbModule = new EjbModule(ejbJar);
            vc = ejbModule.getValidation();
            assembler.createApplication(config.configureApplication(ejbModule));
        } else if (obj instanceof EjbModule) {
            final EjbModule ejbModule = (EjbModule) obj;
            vc = ejbModule.getValidation();
            assembler.createApplication(config.configureApplication(ejbModule));
        } else if (obj instanceof AppModule) {
            final AppModule appModule = (AppModule) obj;
            vc = appModule.getValidation();
            assembler.createApplication(config.configureApplication(appModule));
        }
        if (!isEmpty(expectedKeys)) {
            if (vc != null && expectedKeys.get(KeyType.FAILURE).isEmpty() && expectedKeys.get(KeyType.ERROR).isEmpty()) {
                if (!expectedKeys.get(KeyType.WARNING).isEmpty()) {
                    assertWarnings(expectedKeys.get(KeyType.WARNING), new ValidationFailedException("", vc));
                }
            } else {
                fail("A ValidationFailedException should have been thrown");
            }
        }
    } catch (final ValidationFailedException vfe) {
        if (!isEmpty(expectedKeys)) {
            if (!expectedKeys.get(KeyType.FAILURE).isEmpty()) {
                assertFailures(expectedKeys.get(KeyType.FAILURE), vfe);
            }
            if (!expectedKeys.get(KeyType.WARNING).isEmpty()) {
                assertWarnings(expectedKeys.get(KeyType.WARNING), vfe);
            }
            if (!expectedKeys.get(KeyType.ERROR).isEmpty()) {
                assertErrors(expectedKeys.get(KeyType.ERROR), vfe);
            }
        } else {
            for (final ValidationFailure failure : vfe.getFailures()) {
                System.out.println("failure = " + failure.getMessageKey());
            }
            fail("There should be no validation failures");
        }
    } finally {
        SystemInstance.get().setProperty(OutputGeneratedDescriptors.OUTPUT_DESCRIPTORS, outputDescriptors);
    }
    tearDown();
}
Also used : AppModule(org.apache.openejb.config.AppModule) ValidationFailedException(org.apache.openejb.config.ValidationFailedException) EjbModule(org.apache.openejb.config.EjbModule) ArrayList(java.util.ArrayList) List(java.util.List) ValidationContext(org.apache.openejb.config.ValidationContext) EjbJar(org.apache.openejb.jee.EjbJar) ValidationFailure(org.apache.openejb.config.ValidationFailure)

Example 30 with AppModule

use of org.apache.openejb.config.AppModule in project tomee by apache.

the class LocalBeanAnnotatedLocalTest method testWebServiceWithStateful.

@Keys({ @Key(value = "ann.local.forLocalBean", type = KeyType.WARNING) })
public AppModule testWebServiceWithStateful() {
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean(LocalBeanLocal.class));
    final EjbModule ejbModule = new EjbModule(ejbJar);
    ejbModule.setFinder(new AnnotationFinder(new ClassesArchive(LocalBeanLocal.class)));
    return new AppModule(ejbModule);
}
Also used : AppModule(org.apache.openejb.config.AppModule) StatelessBean(org.apache.openejb.jee.StatelessBean) EjbModule(org.apache.openejb.config.EjbModule) ClassesArchive(org.apache.xbean.finder.archive.ClassesArchive) AnnotationFinder(org.apache.xbean.finder.AnnotationFinder) EjbJar(org.apache.openejb.jee.EjbJar)

Aggregations

AppModule (org.apache.openejb.config.AppModule)51 EjbModule (org.apache.openejb.config.EjbModule)41 EjbJar (org.apache.openejb.jee.EjbJar)40 StatelessBean (org.apache.openejb.jee.StatelessBean)18 InitialContext (javax.naming.InitialContext)15 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)15 Properties (java.util.Properties)14 AppInfo (org.apache.openejb.assembler.classic.AppInfo)14 Assembler (org.apache.openejb.assembler.classic.Assembler)14 SingletonBean (org.apache.openejb.jee.SingletonBean)11 Test (org.junit.Test)10 WebModule (org.apache.openejb.config.WebModule)9 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)8 File (java.io.File)7 IOException (java.io.IOException)6 List (java.util.List)6 OpenEJBException (org.apache.openejb.OpenEJBException)6 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)6 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)6 InitContextFactory (org.apache.openejb.core.ivm.naming.InitContextFactory)6