use of org.jboss.ejb.client.StatelessEJBLocator in project wildfly by wildfly.
the class SimpleApplicationClientTestCase method descriptorBasedAppClientTest.
/**
* Tests an app client with a deployment descriptor, that injects an env-entry and an EJB.
*
* @throws Exception
*/
@Test
public void descriptorBasedAppClientTest() throws Exception {
final StatelessEJBLocator<AppClientSingletonRemote> locator = new StatelessEJBLocator(AppClientSingletonRemote.class, APP_NAME, MODULE_NAME, AppClientStateSingleton.class.getSimpleName(), "");
final AppClientSingletonRemote remote = EJBClient.createProxy(locator);
remote.reset();
final AppClientWrapper wrapper = new AppClientWrapper(archive, "--host=" + managementClient.getRemoteEjbURL(), "client-dd.jar", "");
try {
final String result = remote.awaitAppClientCall();
assertTrue("App client call failed. App client output: " + wrapper.readAllUnformated(1000), result != null);
assertEquals("EnvEntry", result);
} finally {
wrapper.quit();
}
}
use of org.jboss.ejb.client.StatelessEJBLocator in project wildfly by wildfly.
the class SimpleApplicationClientTestCase method testAppClientJBossDescriptor.
/**
* Tests an app client with a deployment descriptor, that injects an env-entry and an EJB.
*
* @throws Exception
*/
@Test
public void testAppClientJBossDescriptor() throws Exception {
final StatelessEJBLocator<AppClientSingletonRemote> locator = new StatelessEJBLocator(AppClientSingletonRemote.class, APP_NAME, MODULE_NAME, AppClientStateSingleton.class.getSimpleName(), "");
final AppClientSingletonRemote remote = EJBClient.createProxy(locator);
remote.reset();
URL props = getClass().getClassLoader().getResource("jboss-ejb-client.properties");
final AppClientWrapper wrapper = new AppClientWrapper(archive, " -Dnode0=" + managementClient.getMgmtAddress() + " --ejb-client-properties=" + props, "client-override.jar", "");
try {
final String result = remote.awaitAppClientCall();
assertTrue("App client call failed. App client output: " + wrapper.readAllUnformated(1000), result != null);
assertEquals("OverridenEnvEntry", result);
} finally {
wrapper.quit();
}
}
use of org.jboss.ejb.client.StatelessEJBLocator in project wildfly by wildfly.
the class EJBClientAPIUsageTestCase method testNonSerializableResponse.
/**
* AS7-3402
*
* Tests that a NonSerializableException does not break the channel
*
*/
@Test
public void testNonSerializableResponse() throws InterruptedException, ExecutionException {
final StatelessEJBLocator<NonSerialiazableResponseRemote> locator = new StatelessEJBLocator(NonSerialiazableResponseRemote.class, APP_NAME, MODULE_NAME, NonSerializableResponseEjb.class.getSimpleName(), "");
final NonSerialiazableResponseRemote proxy = EJBClient.createProxy(locator);
Callable<Object> task = new Callable<Object>() {
@Override
public Object call() throws Exception {
try {
proxy.nonSerializable();
Assert.fail();
} catch (Exception e) {
logger.trace("expected " + e);
}
Thread.sleep(1000);
Assert.assertEquals("hello", proxy.serializable());
return null;
}
};
final ExecutorService executor = Executors.newFixedThreadPool(10);
try {
final List<Future> tasks = new ArrayList<Future>();
for (int i = 0; i < 100; ++i) {
tasks.add(executor.submit(task));
}
for (Future result : tasks) {
result.get();
}
} finally {
executor.shutdown();
}
}
use of org.jboss.ejb.client.StatelessEJBLocator in project wildfly by wildfly.
the class HTTPEJBClientUserTransactionTestCase method testMandatoryTxOnSLSB.
/**
* Tests a call to a bean method with a Mandatory tx attribute, by initiating a UserTransaction on the
* remote client side. This test ensures that the tx is propagated to the server during the bean invocation
*
* @throws Exception
*/
@Test
public void testMandatoryTxOnSLSB() throws Exception {
final StatelessEJBLocator<CMTRemote> cmtRemoteBeanLocator = new StatelessEJBLocator<CMTRemote>(CMTRemote.class, APP_NAME, MODULE_NAME, CMTBean.class.getSimpleName(), "", Affinity.forUri(getHttpUri()));
final CMTRemote cmtRemoteBean = EJBClient.createProxy(cmtRemoteBeanLocator);
final UserTransaction userTransaction = getUserTransaction();
userTransaction.begin();
cmtRemoteBean.mandatoryTxOp();
userTransaction.commit();
}
use of org.jboss.ejb.client.StatelessEJBLocator in project wildfly by wildfly.
the class EjbIIOPService method referenceForLocator.
/**
* Returns a corba reference for the given locator
*
* @param locator The locator
* @return The corba reference
*/
public org.omg.CORBA.Object referenceForLocator(final EJBLocator<?> locator) {
final EJBComponent ejbComponent = ejbComponentInjectedValue.getValue();
try {
final String earApplicationName = ejbComponent.getEarApplicationName() == null ? "" : ejbComponent.getEarApplicationName();
if (locator.getBeanName().equals(ejbComponent.getComponentName()) && locator.getAppName().equals(earApplicationName) && locator.getModuleName().equals(ejbComponent.getModuleName()) && locator.getDistinctName().equals(ejbComponent.getDistinctName())) {
if (locator instanceof EJBHomeLocator) {
return (org.omg.CORBA.Object) ejbHome;
} else if (locator instanceof StatelessEJBLocator) {
return beanReferenceFactory.createReference(beanRepositoryIds[0]);
} else if (locator instanceof StatefulEJBLocator) {
final Marshaller marshaller = factory.createMarshaller(configuration);
final ByteArrayOutputStream stream = new ByteArrayOutputStream();
marshaller.start(new OutputStreamByteOutput(stream));
marshaller.writeObject(((StatefulEJBLocator<?>) locator).getSessionId());
marshaller.finish();
return beanReferenceFactory.createReferenceWithId(stream.toByteArray(), beanRepositoryIds[0]);
} else if (locator instanceof EntityEJBLocator) {
final Marshaller marshaller = factory.createMarshaller(configuration);
final ByteArrayOutputStream stream = new ByteArrayOutputStream();
marshaller.start(new OutputStreamByteOutput(stream));
marshaller.writeObject(((EntityEJBLocator<?>) locator).getPrimaryKey());
marshaller.finish();
return beanReferenceFactory.createReferenceWithId(stream.toByteArray(), beanRepositoryIds[0]);
}
throw EjbLogger.ROOT_LOGGER.unknownEJBLocatorType(locator);
} else {
throw EjbLogger.ROOT_LOGGER.incorrectEJBLocatorForBean(locator, ejbComponent.getComponentName());
}
} catch (Exception e) {
throw EjbLogger.ROOT_LOGGER.couldNotCreateCorbaObject(e, locator);
}
}
Aggregations