use of org.apache.openejb.jee.StatelessBean in project tomee by apache.
the class InvalidInterfacesTest method validate.
private EjbJar validate(final Class interfaceClass) throws OpenEJBException {
final EjbJar ejbJar = new EjbJar();
final StatelessBean bean = ejbJar.addEnterpriseBean(new StatelessBean(FooBean.class));
bean.setHomeAndLocal(interfaceClass, interfaceClass);
bean.setHomeAndRemote(interfaceClass, interfaceClass);
bean.addBusinessLocal(interfaceClass);
bean.addBusinessRemote(interfaceClass);
return ejbJar;
}
use of org.apache.openejb.jee.StatelessBean in project tomee by apache.
the class InvalidInterfacesTest method test.
@Keys({ @Key("ann.notAnInterface"), @Key("xml.businessLocal.notInterface"), @Key("ann.localRemote.conflict"), @Key("ann.remoteOrLocal.ejbHome"), @Key("xml.businessRemote.ejbHome"), @Key("ann.remoteOrLocal.ejbObject"), @Key("xml.businessRemote.ejbObject"), @Key(value = "ann.remoteOrLocal.ejbLocalHome"), @Key(value = "ann.remoteOrLocal.ejbLocalObject"), @Key("xml.businessLocal.ejbLocalHome"), @Key("xml.businessLocal.ejbLocalObject") })
public EjbJar test() throws OpenEJBException {
SystemInstance.get().setProperty("openejb.strict.interface.declaration", "true");
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatelessBean(BBean.class));
ejbJar.addEnterpriseBean(new StatelessBean(CBean.class));
final StatelessBean mybean1 = ejbJar.addEnterpriseBean(new StatelessBean("MyBean1", MyBean.class));
return ejbJar;
}
use of org.apache.openejb.jee.StatelessBean in project tomee by apache.
the class CheckNoBusinessMethodTest method noBusinessMethod.
@Keys({ @Key(value = "no.busines.method.case", count = 4), @Key(value = "no.busines.method.args", count = 4), @Key(value = "no.busines.method", count = 4) })
public EjbJar noBusinessMethod() throws OpenEJBException {
// System.setProperty("openejb.validation.output.level", "VERBOSE");
final EjbJar ejbJar = new EjbJar();
final StatelessBean stateLessLocal = new StatelessBean(FooStatelessSession.class);
stateLessLocal.setLocalHome("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooLocalHome");
stateLessLocal.setLocal("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooLocal");
final StatefulBean statefulLocal = new StatefulBean(FooStatefulSession.class);
statefulLocal.setLocalHome("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooLocalHome");
statefulLocal.setLocal("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooLocal");
final StatelessBean stateLessRemote = new StatelessBean(FooRemoteStatelessSession.class);
stateLessRemote.setHome("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooRemoteHome");
stateLessRemote.setRemote("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooRemote");
final StatefulBean statefulRemote = new StatefulBean(FooRemoteStatefulSession.class);
statefulRemote.setHome("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooRemoteHome");
statefulRemote.setRemote("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooRemote");
ejbJar.addEnterpriseBean(stateLessLocal);
ejbJar.addEnterpriseBean(statefulLocal);
ejbJar.addEnterpriseBean(stateLessRemote);
ejbJar.addEnterpriseBean(statefulRemote);
return ejbJar;
}
use of org.apache.openejb.jee.StatelessBean in project tomee by apache.
the class StatelessConstructorInjectionTest method setUp.
protected void setUp() throws Exception {
super.setUp();
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.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);
assembler.createContainer(statelessContainerInfo);
// Setup the descriptor information
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatelessBean(FooBean.class));
final StatelessBean bean = ejbJar.addEnterpriseBean(new StatelessBean(WidgetBean.class));
bean.getEnvEntry().add(new EnvEntry("count", Integer.class.getName(), "10"));
assembler.createApplication(config.configureApplication(new EjbModule(ejbJar).withCdi()));
}
use of org.apache.openejb.jee.StatelessBean in project tomee by apache.
the class StatelessInvocationStatsTest method testInvocation.
/**
* @throws Exception On error
*/
@Test
public void testInvocation() throws Exception {
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, OpenEJBInitialContextFactory.class.getName());
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
// containers
final StatelessSessionContainerInfo statelessContainerInfo = config.configureService(StatelessSessionContainerInfo.class);
statelessContainerInfo.properties.setProperty("AccessTimeout", "0");
statelessContainerInfo.properties.setProperty("MaxSize", "2");
statelessContainerInfo.properties.setProperty("MinSize", "0");
statelessContainerInfo.properties.setProperty("StrictPooling", "true");
statelessContainerInfo.properties.setProperty("IdleTimeout", "0");
assembler.createContainer(statelessContainerInfo);
// Setup the descriptor information
CounterBean.instances.set(0);
final EjbJar ejbJar = new EjbJar("StatsInvocModule");
ejbJar.addEnterpriseBean(new StatelessBean(CounterBean.class));
assembler.createApplication(config.configureApplication(ejbJar));
final javax.naming.Context context = new InitialContext();
final CounterBean bean = (CounterBean) context.lookup("CounterBeanLocalBean");
// Invoke
bean.waitSecs();
final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
final ObjectName invocationsName = new ObjectName("openejb.management:J2EEServer=openejb,J2EEApplication=<empty>,EJBModule=StatsInvocModule,StatelessSessionBean=CounterBean," + "j2eeType=Invocations,name=CounterBean");
// Grab the mbeanInfo and check the expected attributes exist and have the correct return types and parameters
final MBeanInfo invocationsMBeanInfo = server.getMBeanInfo(invocationsName);
for (final MBeanAttributeInfo info : invocationsMBeanInfo.getAttributes()) {
// System.out.println("//" + info.getName() + " " + server.getAttribute(invocationsName, info.getName()));
if (info.getName().equals("waitSecs().GeometricMean") || info.getName().equals("waitSecs().Max") || info.getName().equals("waitSecs().Mean") || info.getName().equals("waitSecs().Min") || info.getName().equals("waitSecs().Percentile01") || info.getName().equals("waitSecs().Percentile10") || info.getName().equals("waitSecs().Percentile25") || info.getName().equals("waitSecs().Percentile50") || info.getName().equals("waitSecs().Percentile75") || info.getName().equals("waitSecs().Percentile90") || info.getName().equals("waitSecs().Percentile99") || info.getName().equals("waitSecs().Sum")) {
final Double actual = (Double) (server.getAttribute(invocationsName, info.getName()));
Assert.assertTrue("Expected: " + actual + " >= 999", actual >= 999);
}
}
ejbJar.removeEnterpriseBean("StatsInvocModule");
}
Aggregations