use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.
the class StatefulTest method setUp.
@Override
protected void setUp() throws Exception {
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatefulBean(MyBean.class));
assembler.createApplication(config.configureApplication(ejbJar));
}
use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.
the class StatefulTransactionAttributesTest method test.
public void test() throws Exception {
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
final Assembler assembler = new Assembler();
final ConfigurationFactory config = new ConfigurationFactory();
assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatefulBean(Color.class));
ejbJar.addEnterpriseBean(new StatefulBean(Red.class));
ejbJar.addEnterpriseBean(new StatefulBean(Crimson.class));
ejbJar.addEnterpriseBean(new StatefulBean(Scarlet.class));
final List<ContainerTransaction> declared = ejbJar.getAssemblyDescriptor().getContainerTransaction();
declared.add(new ContainerTransaction(TransAttribute.REQUIRED, "*", "Crimson", "*"));
declared.add(new ContainerTransaction(TransAttribute.REQUIRES_NEW, "*", "Crimson", "create"));
final ContainerTransaction o = new ContainerTransaction(TransAttribute.SUPPORTS, "*", "Crimson", "create");
o.getMethod().get(0).setMethodIntf(MethodIntf.HOME);
declared.add(o);
declared.add(new ContainerTransaction(TransAttribute.REQUIRES_NEW, "*", "Crimson", "remove"));
declared.add(new ContainerTransaction(TransAttribute.REQUIRES_NEW, Color.class.getName(), "Scarlet", "*"));
declared.add(new ContainerTransaction(TransAttribute.NEVER, Red.class.getName(), "Scarlet", "red"));
declared.add(new ContainerTransaction(TransAttribute.REQUIRED, "Scarlet", Scarlet.class.getMethod("scarlet")));
final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
assembler.createApplication(ejbJarInfo);
final InitialContext context = new InitialContext();
{
final ColorLocal color = (ColorLocal) context.lookup("ColorLocal");
assertEquals("Never", color.color());
assertEquals("RequiresNew", color.color((Object) null));
assertEquals("Supports", color.color((String) null));
assertEquals("Supports", color.color((Boolean) null));
assertEquals("Supports", color.color((Integer) null));
}
{
final ColorRemote color = (ColorRemote) context.lookup("ColorRemote");
assertEquals("Never", color.color());
assertEquals("RequiresNew", color.color((Object) null));
assertEquals("Supports", color.color((String) null));
assertEquals("Supports", color.color((Boolean) null));
assertEquals("Supports", color.color((Integer) null));
}
{
final ColorEjbLocalHome home = (ColorEjbLocalHome) context.lookup("ColorLocalHome");
final ColorEjbLocalObject color = home.create("Supports");
assertEquals("Never", color.color());
assertEquals("RequiresNew", color.color((Object) null));
assertEquals("Supports", color.color((String) null));
assertEquals("Supports", color.color((Boolean) null));
assertEquals("Supports", color.color((Integer) null));
expected.set("Supports");
color.remove();
}
{
final ColorEjbHome home = (ColorEjbHome) context.lookup("ColorRemoteHome");
final ColorEjbObject color = home.create("Supports");
assertEquals("Never", color.color());
assertEquals("RequiresNew", color.color((Object) null));
assertEquals("Supports", color.color((String) null));
assertEquals("Supports", color.color((Boolean) null));
assertEquals("Supports", color.color((Integer) null));
expected.set("Supports");
color.remove();
}
{
final RedLocal red = (RedLocal) context.lookup("RedLocal");
assertEquals("Never", red.color());
assertEquals("Required", red.color((Object) null));
assertEquals("Supports", red.color((String) null));
assertEquals("Supports", red.color((Boolean) null));
assertEquals("Supports", red.color((Integer) null));
assertEquals("RequiresNew", red.red());
assertEquals("Required", red.red((Object) null));
assertEquals("Required", red.red((String) null));
}
{
final RedRemote red = (RedRemote) context.lookup("RedRemote");
assertEquals("Never", red.color());
assertEquals("Required", red.color((Object) null));
assertEquals("Supports", red.color((String) null));
assertEquals("Supports", red.color((Boolean) null));
assertEquals("Supports", red.color((Integer) null));
assertEquals("RequiresNew", red.red());
assertEquals("Required", red.red((Object) null));
assertEquals("Required", red.red((String) null));
}
{
final RedEjbLocalHome home = (RedEjbLocalHome) context.lookup("RedLocalHome");
final RedEjbLocalObject red = home.create("Supports");
assertEquals("Never", red.color());
assertEquals("Required", red.color((Object) null));
assertEquals("Supports", red.color((String) null));
assertEquals("Supports", red.color((Boolean) null));
assertEquals("Supports", red.color((Integer) null));
assertEquals("RequiresNew", red.red());
assertEquals("Required", red.red((Object) null));
assertEquals("Required", red.red((String) null));
expected.set("Supports");
red.remove();
}
{
final RedEjbHome home = (RedEjbHome) context.lookup("RedRemoteHome");
final RedEjbObject red = home.create("Supports");
assertEquals("Never", red.color());
assertEquals("Required", red.color((Object) null));
assertEquals("Supports", red.color((String) null));
assertEquals("Supports", red.color((Boolean) null));
assertEquals("Supports", red.color((Integer) null));
assertEquals("RequiresNew", red.red());
assertEquals("Required", red.red((Object) null));
assertEquals("Required", red.red((String) null));
expected.set("Supports");
red.remove();
}
{
final CrimsonLocal crimson = (CrimsonLocal) context.lookup("CrimsonLocal");
assertEquals("Required", crimson.color());
assertEquals("Required", crimson.color((Object) null));
assertEquals("Required", crimson.color((String) null));
assertEquals("Required", crimson.color((Boolean) null));
assertEquals("Required", crimson.color((Integer) null));
assertEquals("RequiresNew", crimson.red());
assertEquals("Required", crimson.red((Object) null));
assertEquals("Required", crimson.red((String) null));
assertEquals("RequiresNew", crimson.crimson());
assertEquals("Required", crimson.crimson((String) null));
}
{
final CrimsonRemote crimson = (CrimsonRemote) context.lookup("CrimsonRemote");
assertEquals("Required", crimson.color());
assertEquals("Required", crimson.color((Object) null));
assertEquals("Required", crimson.color((String) null));
assertEquals("Required", crimson.color((Boolean) null));
assertEquals("Required", crimson.color((Integer) null));
assertEquals("RequiresNew", crimson.red());
assertEquals("Required", crimson.red((Object) null));
assertEquals("Required", crimson.red((String) null));
assertEquals("RequiresNew", crimson.crimson());
assertEquals("Required", crimson.crimson((String) null));
}
{
final CrimsonEjbLocalHome home = (CrimsonEjbLocalHome) context.lookup("CrimsonLocalHome");
final CrimsonEjbLocalObject crimson = home.create("RequiresNew");
assertEquals("Required", crimson.color());
assertEquals("Required", crimson.color((Object) null));
assertEquals("Required", crimson.color((String) null));
assertEquals("Required", crimson.color((Boolean) null));
assertEquals("Required", crimson.color((Integer) null));
assertEquals("RequiresNew", crimson.red());
assertEquals("Required", crimson.red((Object) null));
assertEquals("Required", crimson.red((String) null));
assertEquals("RequiresNew", crimson.crimson());
assertEquals("Required", crimson.crimson((String) null));
expected.set("RequiresNew");
crimson.remove();
}
{
final CrimsonEjbHome home = (CrimsonEjbHome) context.lookup("CrimsonRemoteHome");
final CrimsonEjbObject crimson = home.create("Supports");
assertEquals("Required", crimson.color());
assertEquals("Required", crimson.color((Object) null));
assertEquals("Required", crimson.color((String) null));
assertEquals("Required", crimson.color((Boolean) null));
assertEquals("Required", crimson.color((Integer) null));
assertEquals("RequiresNew", crimson.red());
assertEquals("Required", crimson.red((Object) null));
assertEquals("Required", crimson.red((String) null));
assertEquals("RequiresNew", crimson.crimson());
assertEquals("Required", crimson.crimson((String) null));
expected.set("RequiresNew");
crimson.remove();
}
{
final ScarletLocal scarlet = (ScarletLocal) context.lookup("ScarletLocal");
assertEquals("Never", scarlet.color());
assertEquals("Required", scarlet.color((Object) null));
assertEquals("RequiresNew", scarlet.color((String) null));
assertEquals("RequiresNew", scarlet.color((Boolean) null));
assertEquals("RequiresNew", scarlet.color((Integer) null));
assertEquals("RequiresNew", scarlet.red());
assertEquals("Never", scarlet.red((Object) null));
assertEquals("Never", scarlet.red((String) null));
assertEquals("Required", scarlet.scarlet());
assertEquals("NotSupported", scarlet.scarlet((String) null));
}
{
final ScarletRemote scarlet = (ScarletRemote) context.lookup("ScarletRemote");
assertEquals("Never", scarlet.color());
assertEquals("Required", scarlet.color((Object) null));
assertEquals("RequiresNew", scarlet.color((String) null));
assertEquals("RequiresNew", scarlet.color((Boolean) null));
assertEquals("RequiresNew", scarlet.color((Integer) null));
assertEquals("RequiresNew", scarlet.red());
assertEquals("Never", scarlet.red((Object) null));
assertEquals("Never", scarlet.red((String) null));
assertEquals("Required", scarlet.scarlet());
assertEquals("NotSupported", scarlet.scarlet((String) null));
}
{
final ScarletEjbLocalHome home = (ScarletEjbLocalHome) context.lookup("ScarletLocalHome");
final ScarletEjbLocalObject scarlet = home.create("RequiresNew");
assertEquals("Never", scarlet.color());
assertEquals("Required", scarlet.color((Object) null));
assertEquals("RequiresNew", scarlet.color((String) null));
assertEquals("RequiresNew", scarlet.color((Boolean) null));
assertEquals("RequiresNew", scarlet.color((Integer) null));
assertEquals("RequiresNew", scarlet.red());
assertEquals("Never", scarlet.red((Object) null));
assertEquals("Never", scarlet.red((String) null));
assertEquals("Required", scarlet.scarlet());
assertEquals("NotSupported", scarlet.scarlet((String) null));
}
{
final ScarletEjbHome home = (ScarletEjbHome) context.lookup("ScarletRemoteHome");
final ScarletEjbObject scarlet = home.create("RequiresNew");
assertEquals("Never", scarlet.color());
assertEquals("Required", scarlet.color((Object) null));
assertEquals("RequiresNew", scarlet.color((String) null));
assertEquals("RequiresNew", scarlet.color((Boolean) null));
assertEquals("RequiresNew", scarlet.color((Integer) null));
assertEquals("RequiresNew", scarlet.red());
assertEquals("Never", scarlet.red((Object) null));
assertEquals("Never", scarlet.red((String) null));
assertEquals("Required", scarlet.scarlet());
assertEquals("NotSupported", scarlet.scarlet((String) null));
}
}
use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.
the class StatefulTransactionLockingTest method setUp.
@Override
protected void setUp() throws Exception {
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
final StatefulSessionContainerInfo statefulContainerInfo = config.configureService(StatefulSessionContainerInfo.class);
statefulContainerInfo.properties.setProperty("AccessTimeout", "0 milliseconds");
// containers
assembler.createContainer(statefulContainerInfo);
// Setup the descriptor information
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatelessBean(BlueStatelessBean.class));
ejbJar.addEnterpriseBean(new StatefulBean(RedStatefulBean.class));
ejbJar.addEnterpriseBean(new StatefulBean(LegacyStatefulBean.class));
assembler.createApplication(config.configureApplication(ejbJar));
}
use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.
the class CrossClassLoaderProxyTest method setUp.
protected void setUp() throws Exception {
super.setUp();
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
// containers
final StatelessSessionContainerInfo statelessContainerInfo = config.configureService(StatelessSessionContainerInfo.class);
statelessContainerInfo.properties.setProperty("TimeOut", "10");
statelessContainerInfo.properties.setProperty("MaxSize", "0");
statelessContainerInfo.properties.setProperty("StrictPooling", "false");
assembler.createContainer(statelessContainerInfo);
// Setup the descriptor information
final StatelessBean bean = new StatelessBean(WidgetBean.class);
bean.addBusinessLocal(Widget.class.getName());
bean.addBusinessRemote(RemoteWidget.class.getName());
bean.setHomeAndRemote(WidgetHome.class, WidgetRemote.class);
bean.addPostConstruct("init");
bean.addPreDestroy("destroy");
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(bean);
assembler.createApplication(config.configureApplication(ejbJar));
WidgetBean.lifecycle.clear();
}
use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.
the class JaxRpcInvocationTest method buildTestApp.
public EjbModule buildTestApp() {
final EjbJar ejbJar = new EjbJar();
final StatelessBean bean = ejbJar.addEnterpriseBean(new StatelessBean(EchoBean.class));
bean.setServiceEndpoint(EchoServiceEndpoint.class.getName());
return new EjbModule(this.getClass().getClassLoader(), this.getClass().getSimpleName(), "test", ejbJar, null);
}
Aggregations