use of org.apache.openejb.assembler.classic.Assembler in project tomee by apache.
the class DeploymentContextPropertiesTest method testModuleContextProperties.
public void testModuleContextProperties() throws Exception {
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
{
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
}
{
// Setup the descriptor information
final EjbModule ejbModule = new EjbModule(new EjbJar(), new OpenejbJar());
final EjbJar ejbJar = ejbModule.getEjbJar();
final OpenejbJar openejbJar = ejbModule.getOpenejbJar();
openejbJar.getProperties().setProperty("color", "orange");
ejbJar.addEnterpriseBean(new StatelessBean(WidgetBean.class));
final EjbJarInfo moduleInfo = config.configureApplication(ejbModule);
assertProperty(moduleInfo.properties, "color", "orange");
assembler.createApplication(moduleInfo);
}
final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
final BeanContext beanContext = containerSystem.getBeanContext("WidgetBean");
final Properties properties = beanContext.getModuleContext().getProperties();
assertProperty(properties, "color", "orange");
}
use of org.apache.openejb.assembler.classic.Assembler in project tomee by apache.
the class DeploymentContextPropertiesTest method testBeanContextProperties.
public void testBeanContextProperties() throws Exception {
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
{
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
}
{
// Setup the descriptor information
final EjbModule ejbModule = new EjbModule(new EjbJar(), new OpenejbJar());
final EjbJar ejbJar = ejbModule.getEjbJar();
final OpenejbJar openejbJar = ejbModule.getOpenejbJar();
final StatelessBean statelessBean = ejbJar.addEnterpriseBean(new StatelessBean(WidgetBean.class));
final EjbDeployment deployment = openejbJar.addEjbDeployment(statelessBean);
deployment.getProperties().put("color", "orange");
assembler.createApplication(config.configureApplication(ejbModule));
}
final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
final BeanContext beanContext = containerSystem.getBeanContext("WidgetBean");
final Properties properties = beanContext.getProperties();
assertProperty(properties, "color", "orange");
}
use of org.apache.openejb.assembler.classic.Assembler 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.assembler.classic.Assembler in project tomee by apache.
the class JaxRpcInvocationTest method testWebServiceInvocations.
public void testWebServiceInvocations() throws Exception {
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, "PseudoSecurityService", null, "PseudoSecurityService", null));
assembler.createContainer(config.configureService(StatelessSessionContainerInfo.class));
final EjbJarInfo ejbJar = config.configureApplication(buildTestApp());
assembler.createApplication(ejbJar);
final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
final BeanContext beanContext = containerSystem.getBeanContext("EchoBean");
assertNotNull(beanContext);
assertEquals("ServiceEndpointInterface", EchoServiceEndpoint.class, beanContext.getServiceEndpointInterface());
// OK, Now let's fake a web serivce invocation coming from any random
// web service provider. The web serivce provider needs supply
// the MessageContext and an interceptor to do the marshalling as
// the arguments of the standard container.invoke signature.
// So let's create a fake message context.
final MessageContext messageContext = new FakeMessageContext();
// Now let's create a fake interceptor as would be supplied by the
// web service provider. Instead of writing "fake" marshalling
// code that would pull the arguments from the soap message, we'll
// just give it the argument values directly.
final Object wsProviderInterceptor = new FakeWsProviderInterceptor("Hello world");
// Ok, now we have the two arguments expected on a JAX-RPC Web Service
// invocation as per the OpenEJB-specific agreement between OpenEJB
// and the Web Service Provider
final Object[] args = new Object[] { messageContext, wsProviderInterceptor };
// Let's grab the container as the Web Service Provider would do and
// perform an invocation
final RpcContainer container = (RpcContainer) beanContext.getContainer();
final Method echoMethod = EchoServiceEndpoint.class.getMethod("echo", String.class);
final String value = (String) container.invoke("EchoBean", InterfaceType.SERVICE_ENDPOINT, echoMethod.getDeclaringClass(), echoMethod, args, null);
assertCalls(Call.values());
calls.clear();
assertEquals("Hello world", value);
}
use of org.apache.openejb.assembler.classic.Assembler in project tomee by apache.
the class JaxWsInvocationTest method testWsInvocations.
public void testWsInvocations() throws Exception {
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, "PseudoSecurityService", null, "PseudoSecurityService", null));
assembler.createContainer(config.configureService(StatelessSessionContainerInfo.class));
final EjbJarInfo ejbJar = config.configureApplication(buildTestApp());
assembler.createApplication(ejbJar);
final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
final BeanContext beanContext = containerSystem.getBeanContext("EchoBean");
assertNotNull(beanContext);
assertEquals("ServiceEndpointInterface", EchoServiceEndpoint.class, beanContext.getServiceEndpointInterface());
// OK, Now let's fake a web serivce invocation coming from any random
// web service provider. The web serivce provider needs supply
// the MessageContext and an interceptor to do the marshalling as
// the arguments of the standard container.invoke signature.
// So let's create a fake message context.
final MessageContext messageContext = new FakeMessageContext();
// Now let's create a fake interceptor as would be supplied by the
// web service provider. Instead of writing "fake" marshalling
// code that would pull the arguments from the soap message, we'll
// just give it the argument values directly.
final Object wsProviderInterceptor = new FakeWsProviderInterceptor("Hello world");
// Ok, now we have the two arguments expected on a JAX-RPC Web Service
// invocation as per the OpenEJB-specific agreement between OpenEJB
// and the Web Service Provider
final Object[] args = new Object[] { messageContext, wsProviderInterceptor };
// Let's grab the container as the Web Service Provider would do and
// perform an invocation
final RpcContainer container = (RpcContainer) beanContext.getContainer();
final Method echoMethod = EchoServiceEndpoint.class.getMethod("echo", String.class);
final String value = (String) container.invoke("EchoBean", InterfaceType.SERVICE_ENDPOINT, echoMethod.getDeclaringClass(), echoMethod, args, null);
assertCalls(Call.values());
calls.clear();
assertEquals("Hello world", value);
}
Aggregations