use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.
the class JaxWsInvocationTest 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);
}
use of org.apache.openejb.jee.EjbJar$JAXB 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.EjbJar$JAXB in project tomee by apache.
the class ScheduleTest method testSchedule.
public void testSchedule() 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();
// Configure schedule by deployment plan
final StatelessBean subBeanA = new StatelessBean(SubBeanA.class);
final Timer subBeanATimer = new Timer();
subBeanATimer.setTimeoutMethod(new NamedMethod("subBeanA", "javax.ejb.Timer"));
final TimerSchedule timerScheduleA = new TimerSchedule();
timerScheduleA.setSecond("2");
timerScheduleA.setMinute("*");
timerScheduleA.setHour("*");
subBeanATimer.setSchedule(timerScheduleA);
subBeanATimer.setInfo("SubBeanAInfo");
subBeanA.getTimer().add(subBeanATimer);
ejbJar.addEnterpriseBean(subBeanA);
// Configure schedule by annotation
final StatelessBean subBeanB = new StatelessBean(SubBeanB.class);
ejbJar.addEnterpriseBean(subBeanB);
// Override aroundTimeout annotation by deployment plan
final StatelessBean subBeanC = new StatelessBean(SubBeanC.class);
final Timer subBeanCTimer = new Timer();
subBeanCTimer.setTimeoutMethod(new NamedMethod("subBeanC", "javax.ejb.Timer"));
final TimerSchedule timerScheduleC = new TimerSchedule();
timerScheduleC.setSecond("2");
timerScheduleC.setMinute("*");
timerScheduleC.setHour("*");
subBeanCTimer.setSchedule(timerScheduleC);
subBeanCTimer.setInfo("SubBeanCInfo");
subBeanC.getTimer().add(subBeanCTimer);
ejbJar.addEnterpriseBean(subBeanC);
final StatefulBean subBeanM = new StatefulBean(SubBeanM.class);
ejbJar.addEnterpriseBean(subBeanM);
final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
assembler.createApplication(ejbJarInfo);
countDownLatch.await(1L, TimeUnit.MINUTES);
// A better way for validation ?
int beforeAroundInvocationCount = 0;
int afterAroundInvocationCount = 0;
int timeoutInvocationCount = 0;
final int size;
synchronized (result) {
size = result.size();
for (final Call call : result) {
switch(call) {
case BEAN_BEFORE_AROUNDTIMEOUT:
beforeAroundInvocationCount++;
break;
case BEAN_AFTER_AROUNDTIMEOUT:
afterAroundInvocationCount++;
break;
case TIMEOUT:
timeoutInvocationCount++;
break;
}
}
}
assertEquals(3, beforeAroundInvocationCount);
assertEquals(3, afterAroundInvocationCount);
assertEquals(3, timeoutInvocationCount);
assertEquals(9, size);
}
use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.
the class DynamicEJBImplTest method app.
@Module
public EjbJar app() throws Exception {
final EjbJar ejbJar = new EjbJar("dynamic");
ejbJar.addEnterpriseBean(new SingletonBean(UtilBean.class));
ejbJar.addEnterpriseBean(new SingletonBean(DynamicCustomProxy.class));
ejbJar.addEnterpriseBean(new StatelessBean(UserDAO.class));
ejbJar.addEnterpriseBean(new StatelessBean(UserDAOChild.class));
return ejbJar;
}
use of org.apache.openejb.jee.EjbJar$JAXB 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