Search in sources :

Example 66 with EJBObject

use of javax.ejb.EJBObject in project tomee by apache.

the class CmpRmiIiopTests method test42_returnNestedEJBObject.

public void test42_returnNestedEJBObject() {
    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_42 CmpBean");
        assertNotNull("The EJBObject created is null", expected);
        final ObjectGraph graph = ejbObject.returnObjectGraph(new ObjectGraph(expected));
        assertNotNull("The ObjectGraph is null", graph);
        final EncCmpObject actual = (EncCmpObject) graph.getObject();
        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());
    }
}
Also used : ObjectGraph(org.apache.openejb.test.object.ObjectGraph) EJBObject(javax.ejb.EJBObject) RemoteException(java.rmi.RemoteException)

Example 67 with EJBObject

use of javax.ejb.EJBObject in project tomee by apache.

the class CmpRmiIiopTests method test52_returnNestedHandle.

public void test52_returnNestedHandle() {
    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 object = home.create("test_52 CmpBean");
        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());
    }
}
Also used : EJBObject(javax.ejb.EJBObject) ObjectGraph(org.apache.openejb.test.object.ObjectGraph) EJBObject(javax.ejb.EJBObject) RemoteException(java.rmi.RemoteException) Handle(javax.ejb.Handle)

Example 68 with EJBObject

use of javax.ejb.EJBObject in project tomee by apache.

the class CmpRmiIiopTests method test50_returnHandle.

/*-------------------------------------------------*/
/*  Handle                                         */
/*-------------------------------------------------*/
public void test50_returnHandle() {
    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 object = home.create("test_50 CmpBean");
        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 Handle actual = ejbObject.returnHandle(expected);
        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());
    }
}
Also used : EJBObject(javax.ejb.EJBObject) EJBObject(javax.ejb.EJBObject) RemoteException(java.rmi.RemoteException) Handle(javax.ejb.Handle)

Example 69 with EJBObject

use of javax.ejb.EJBObject in project tomee by apache.

the class SingletonPojoHandleTests method setUp.

protected void setUp() throws Exception {
    super.setUp();
    final Object obj = initialContext.lookup("client/tests/singleton/BasicSingletonPojoHome");
    ejbHome = (BasicSingletonHome) obj;
    ejbObject = ejbHome.createObject();
    ejbHandle = ejbObject.getHandle();
}
Also used : EJBObject(javax.ejb.EJBObject)

Example 70 with EJBObject

use of javax.ejb.EJBObject in project tomee by apache.

the class SingletonRmiIiopTests method test44_returnEJBObjectArray.

public void test44_returnEJBObjectArray() {
    try {
        final Object obj = initialContext.lookup("client/tests/singleton/EncBean");
        final EncSingletonHome home = (EncSingletonHome) obj;
        assertNotNull("The EJBHome returned from JNDI is null", home);
        final EncSingletonObject[] expected = new EncSingletonObject[3];
        for (int i = 0; i < expected.length; i++) {
            expected[i] = home.create();
            assertNotNull("The EJBObject created is null", expected[i]);
        }
        final EJBObject[] actual = ejbObject.returnEJBObjectArray(expected);
        assertNotNull("The EJBObject array returned is null", actual);
        assertEquals(expected.length, actual.length);
        for (int i = 0; i < actual.length; i++) {
            assertTrue("The EJBObejcts are not identical", expected[i].isIdentical(actual[i]));
        }
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
Also used : EJBObject(javax.ejb.EJBObject) EJBObject(javax.ejb.EJBObject) RemoteException(java.rmi.RemoteException)

Aggregations

EJBObject (javax.ejb.EJBObject)104 RemoteException (java.rmi.RemoteException)41 Handle (javax.ejb.Handle)28 ObjectGraph (org.apache.openejb.test.object.ObjectGraph)12 EJBLocalObject (javax.ejb.EJBLocalObject)8 EJBException (javax.ejb.EJBException)7 EncCmpObject (org.apache.openejb.test.entity.cmp.EncCmpObject)7 RmiIiopCmpObject (org.apache.openejb.test.entity.cmp.RmiIiopCmpObject)7 MarshalledObject (java.rmi.MarshalledObject)6 EncCmpHome (org.apache.openejb.test.entity.cmp.EncCmpHome)6 Test (org.junit.Test)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 NoSuchObjectException (java.rmi.NoSuchObjectException)4 RemoveException (javax.ejb.RemoveException)4 SystemException (javax.transaction.SystemException)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 IOException (java.io.IOException)3 NotSerializableException (java.io.NotSerializableException)3 ObjectInputStream (java.io.ObjectInputStream)3