use of org.apache.openejb.jee.SingletonBean in project tomee by apache.
the class TransactionRollbackCauseTest method test.
public void test() throws Exception {
final Map<String, Object> map = new HashMap<String, Object>();
map.put(EJBContainer.MODULES, new SingletonBean(Orange.class));
EJBContainer.createEJBContainer(map).getContext().bind("inject", this);
userTransaction.begin();
orange.exceptionRollback();
try {
userTransaction.commit();
fail("transaction should have been rolled back");
} catch (final RollbackException e) {
final Throwable throwable = e.getCause();
assertTrue(throwable instanceof UserException);
}
}
use of org.apache.openejb.jee.SingletonBean in project tomee by apache.
the class VagueEnvEntriesMatchTest method foo.
@Module
public SingletonBean foo() {
final SingletonBean singletonBean = new SingletonBean(Blue.class);
singletonBean.getEnvEntry().add(new EnvEntry().name("one").type(String.class).value("hello"));
singletonBean.getEnvEntry().add(new EnvEntry().name("two").type(String.class).value("false"));
singletonBean.getEnvEntry().add(new EnvEntry().name(Blue.class.getName() + "/two").type(String.class).value("true"));
return singletonBean;
}
use of org.apache.openejb.jee.SingletonBean in project tomee by apache.
the class CheckInvalidCallbacksTest method test.
@Keys({ @Key(value = "ignoredMethodAnnotation", count = 10, type = KeyType.WARNING), @Key("callback.invalidArguments"), @Key("callback.badReturnType"), @Key("callback.badModifier"), @Key("callback.invalidArguments"), @Key("aroundInvoke.missing"), @Key("callback.missing"), @Key(value = "callback.sessionSynchronization.invalidUse", count = 2) })
public EjbJar test() throws Exception {
final EjbJar ejbJar = new EjbJar();
final StatelessBean testBean = ejbJar.addEnterpriseBean(new StatelessBean("TestStateless", TestBean.class));
testBean.addAroundInvoke("wrongMethod");
testBean.addPostConstruct("wrongMethod");
ejbJar.addEnterpriseBean(new SingletonBean("TestSingleton", TestBean.class));
ejbJar.addEnterpriseBean(new StatefulBean("FooStateful", FooBean.class));
ejbJar.addEnterpriseBean(new StatefulBean("BarStateful", BarBean.class));
final StatefulBean starBean = ejbJar.addEnterpriseBean(new StatefulBean("StarStateful", StarBean.class));
starBean.setAfterBeginMethod(new NamedMethod("myAfterBegin"));
starBean.setBeforeCompletionMethod(new NamedMethod("myBeforeCompletion"));
starBean.setAfterCompletionMethod(new NamedMethod("myAfterCompletion"));
return ejbJar;
}
use of org.apache.openejb.jee.SingletonBean in project tomee by apache.
the class CheckInvalidConcurrencyAttributeTest method test.
@Keys({ @Key(value = "ann.invalidConcurrencyAttribute", type = KeyType.WARNING), @Key(value = "aroundInvoke.invalidArguments") })
public EjbJar test() throws Exception {
System.setProperty("openejb.validation.output.level", "VERBOSE");
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new SingletonBean(TestBean.class));
return ejbJar;
}
use of org.apache.openejb.jee.SingletonBean in project tomee by apache.
the class SystemApps method getSystemModule.
public static EjbModule getSystemModule() {
final EjbModule module = new EjbModule(new EjbJar("openejb"), new OpenejbJar());
final OpenejbJar openejbJar = module.getOpenejbJar();
final EjbJar ejbJar = module.getEjbJar();
//
//
// DONT MODIFY IT WITHOUT VALIDATING org.apache.openejb.config.SystemAppInfo.preComputedInfo()
//
//
ejbJar.addEnterpriseBean(singleton(DeployerEjb.class));
ejbJar.addEnterpriseBean(singleton(ConfigurationInfoEjb.class));
ejbJar.addEnterpriseBean(singleton(MEJBBean.class));
ejbJar.addInterceptor(new Interceptor(InternalSecurityInterceptor.class));
ejbJar.getAssemblyDescriptor().addInterceptorBinding(new InterceptorBinding("*", InternalSecurityInterceptor.class.getName()));
module.getMbeans().add(JMXDeployer.class.getName());
final SingletonBean bean = ejbJar.addEnterpriseBean(new SingletonBean("openejb/WebappDeployer", "org.apache.tomee.catalina.deployer.WebappDeployer"));
final EjbDeployment deployment = openejbJar.addEjbDeployment(bean);
deployment.getProperties().put("openejb.jndiname.format", "{deploymentId}{interfaceType.annotationName}");
final SingletonBean exceptionManager = ejbJar.addEnterpriseBean(new SingletonBean("openejb/ExceptionManagerFacade", "org.apache.tomee.catalina.facade.ExceptionManagerFacadeBean"));
final EjbDeployment exceptionMgr = openejbJar.addEjbDeployment(exceptionManager);
exceptionMgr.getProperties().put("openejb.jndiname.format", "{deploymentId}{interfaceType.annotationName}");
openejbJar.getProperties().put("openejb.deploymentId.format", "{ejbName}");
openejbJar.getProperties().put("openejb.jndiname.format", "{deploymentId}{interfaceType.openejbLegacyName}");
return module;
}
Aggregations