use of javax.ejb.EJBObject in project tomee by apache.
the class BmpRmiIiopTests method test52_returnNestedHandle.
public void test52_returnNestedHandle() {
try {
final Object obj = initialContext.lookup("client/tests/entity/bmp/EncBean");
final EncBmpHome home = (EncBmpHome) obj;
assertNotNull("The EJBHome returned from JNDI is null", home);
final EncBmpObject object = home.create("test_52 BmpBean");
assertNotNull("The EJBObject created is null", object);
final Handle expected = object.getHandle();
assertNotNull("The EJBObject Handle returned is null", expected);
assertNotNull("The EJBObject in the Handle is null", expected.getEJBObject());
final ObjectGraph graph = ejbObject.returnObjectGraph(new ObjectGraph(expected));
assertNotNull("The ObjectGraph is null", graph);
final Handle actual = (Handle) graph.getObject();
assertNotNull("The EJBObject Handle returned is null", actual);
assertNotNull("The EJBObject in the Handle is null", actual.getEJBObject());
final EJBObject exp = expected.getEJBObject();
final EJBObject act = actual.getEJBObject();
assertTrue("The EJBObjects in the Handles are not identical", exp.isIdentical(act));
} catch (final Exception e) {
fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
}
use of javax.ejb.EJBObject in project tomee by apache.
the class BmpRmiIiopTests method test54_returnHandleArray.
public void test54_returnHandleArray() {
try {
final Object obj = initialContext.lookup("client/tests/entity/bmp/EncBean");
final EncBmpHome home = (EncBmpHome) obj;
assertNotNull("The EJBHome returned from JNDI is null", home);
final EncBmpObject object = home.create("test_54 BmpBean");
assertNotNull("The EJBObject created is null", object);
final Handle[] expected = new Handle[3];
for (int i = 0; i < expected.length; i++) {
expected[i] = object.getHandle();
assertNotNull("The EJBObject Handle returned is null", expected[i]);
}
final Handle[] actual = (Handle[]) ejbObject.returnHandleArray(expected);
assertNotNull("The Handle array returned is null", actual);
assertEquals(expected.length, actual.length);
for (int i = 0; i < expected.length; i++) {
assertNotNull("The EJBObject Handle returned is null", actual[i]);
assertNotNull("The EJBObject in the Handle is null", actual[i].getEJBObject());
assertTrue("The EJBObjects in the Handles are not equal", expected[i].getEJBObject().isIdentical(actual[i].getEJBObject()));
}
} catch (final Exception e) {
fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
}
use of javax.ejb.EJBObject in project tomee by apache.
the class BmpHandleTests method test01_getEJBObject.
// =================================
// Test handle methods
//
public void test01_getEJBObject() {
try {
final EJBObject object = ejbHandle.getEJBObject();
assertNotNull("The EJBObject is null", object);
// Wait until isIdentical is working.
// assertTrue("EJBObjects are not identical", object.isIdentical(ejbObject));
} catch (final Exception e) {
fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
}
use of javax.ejb.EJBObject in project tomee by apache.
the class EntityEJBHomeHandler method removeWithHandle.
@Override
protected Object removeWithHandle(final Method method, final Object[] args, final Object proxy) throws Throwable {
if (args[0] == null) {
throw new RemoteException("Handler is null");
}
final Handle handle = (Handle) args[0];
final EJBObject ejbObject = handle.getEJBObject();
if (ejbObject == null) {
throw new NullPointerException("The handle.getEJBObject() is null.");
}
final Object primKey = ejbObject.getPrimaryKey();
if (primKey == null) {
throw new NullPointerException("The handle.getEJBObject().getPrimaryKey() is null.");
}
final EJBRequest req = new EJBRequest(RequestMethodCode.EJB_HOME_REMOVE_BY_HANDLE, ejb, method, args, primKey, client.getSerializer());
final EJBResponse res = request(req);
switch(res.getResponseCode()) {
case ResponseCodes.EJB_ERROR:
throw new SystemError((ThrowableArtifact) res.getResult());
case ResponseCodes.EJB_SYS_EXCEPTION:
throw new SystemException((ThrowableArtifact) res.getResult());
case ResponseCodes.EJB_APP_EXCEPTION:
throw new ApplicationException((ThrowableArtifact) res.getResult());
case ResponseCodes.EJB_OK:
invalidateAllHandlers(ejb.deploymentID + ":" + primKey);
return null;
default:
throw new RemoteException("Received invalid response code from server: " + res.getResponseCode());
}
}
use of javax.ejb.EJBObject in project tomee by apache.
the class CmpRmiIiopTests method test40_returnEJBObject.
/*-------------------------------------------------*/
/* EJBObject */
/*-------------------------------------------------*/
public void test40_returnEJBObject() {
try {
final Object obj = initialContext.lookup("client/tests/entity/cmp/EncBean");
final EncCmpHome home = (EncCmpHome) obj;
assertNotNull("The EJBHome returned from JNDI is null", home);
final EncCmpObject expected = home.create("test_40 CmpBean");
assertNotNull("The EJBObject created is null", expected);
final EncCmpObject actual = (EncCmpObject) ejbObject.returnEJBObject(expected);
assertNotNull("The EJBObject returned is null", actual);
assertTrue("The EJBObejcts are not identical", expected.isIdentical(actual));
} catch (final Exception e) {
fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
}
Aggregations