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;
}
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;
}
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;
}
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();
}
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);
}
Aggregations