Search in sources :

Example 1 with HomeHandle

use of jakarta.ejb.HomeHandle in project tomee by apache.

the class CrossClassLoaderProxyTestObject method testRemoteInterface.

public void testRemoteInterface() throws Exception {
    assertNotNull("widgetHome", widgetHome);
    // assertTrue("home should be an instance of WidgetHome", home instanceof CrossClassLoaderProxyTest.WidgetHome);
    // CrossClassLoaderProxyTest.WidgetHome widgetHome = (CrossClassLoaderProxyTest.WidgetHome)home;
    final Object object = widgetHome.create();
    assertNotNull("widgetHome.create()", object);
    assertTrue("object should be an instance of WidgetRemote", object instanceof CrossClassLoaderProxyTest.WidgetRemote);
    final CrossClassLoaderProxyTest.WidgetRemote widget = (CrossClassLoaderProxyTest.WidgetRemote) object;
    // Do a business method...
    final Stack<CrossClassLoaderProxyTest.Lifecycle> lifecycle = widget.getLifecycle();
    assertNotNull("lifecycle", lifecycle);
    assertNotSame("is copy", lifecycle, CrossClassLoaderProxyTest.WidgetBean.lifecycle);
    // Check the lifecycle of the bean
    final List expected = Arrays.asList(CrossClassLoaderProxyTest.Lifecycle.values());
    assertEquals(join("\n", expected), join("\n", lifecycle));
    // verify home ejb meta data
    final EJBMetaData metaData = widgetHome.getEJBMetaData();
    assertTrue("metaData.getEJBHome() should be an instance of WidgetHome", metaData.getEJBHome() instanceof CrossClassLoaderProxyTest.WidgetHome);
    assertEquals(CrossClassLoaderProxyTest.WidgetHome.class, metaData.getHomeInterfaceClass());
    assertEquals(CrossClassLoaderProxyTest.WidgetRemote.class, metaData.getRemoteInterfaceClass());
    // verify home handle
    final HomeHandle homeHandle = widgetHome.getHomeHandle();
    assertTrue("homeHandle.getEJBHome() should be an instance of WidgetHome", homeHandle.getEJBHome() instanceof CrossClassLoaderProxyTest.WidgetHome);
    // verify ejb object getHome
    assertTrue("widget.getEJBHome() should be an instance of WidgetHome", widget.getEJBHome() instanceof CrossClassLoaderProxyTest.WidgetHome);
    // verify ejb object handle
    final Handle objectHandle = widget.getHandle();
    assertTrue("objectHandle.getEJBObject() should be an instance of WidgetHome", objectHandle.getEJBObject() instanceof CrossClassLoaderProxyTest.WidgetRemote);
}
Also used : EJBMetaData(jakarta.ejb.EJBMetaData) HomeHandle(jakarta.ejb.HomeHandle) List(java.util.List) HomeHandle(jakarta.ejb.HomeHandle) Handle(jakarta.ejb.Handle)

Example 2 with HomeHandle

use of jakarta.ejb.HomeHandle in project tomee by apache.

the class Cmp2HomeHandleTests method Xtest02_copyHandleByMarshalledObject.

public void Xtest02_copyHandleByMarshalledObject() {
    try {
        final MarshalledObject obj = new MarshalledObject(ejbHomeHandle);
        final HomeHandle copy = (HomeHandle) obj.get();
        assertNotNull("The HomeHandle copy is null", copy);
        final EJBHome home = copy.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
Also used : EJBHome(jakarta.ejb.EJBHome) MarshalledObject(java.rmi.MarshalledObject) HomeHandle(jakarta.ejb.HomeHandle)

Example 3 with HomeHandle

use of jakarta.ejb.HomeHandle in project tomee by apache.

the class Unknown2HomeHandleTests method Xtest03_copyHandleBySerialize.

public void Xtest03_copyHandleBySerialize() {
    try {
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(ejbHomeHandle);
        oos.flush();
        oos.close();
        final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        final ObjectInputStream ois = new ObjectInputStream(bais);
        final HomeHandle copy = (HomeHandle) ois.readObject();
        assertNotNull("The HomeHandle copy is null", copy);
        final EJBHome home = copy.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) EJBHome(jakarta.ejb.EJBHome) HomeHandle(jakarta.ejb.HomeHandle) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) ObjectInputStream(java.io.ObjectInputStream)

Example 4 with HomeHandle

use of jakarta.ejb.HomeHandle in project tomee by apache.

the class Complex2HomeHandleTests method Xtest03_copyHandleBySerialize.

public void Xtest03_copyHandleBySerialize() {
    try {
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(ejbHomeHandle);
        oos.flush();
        oos.close();
        final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        final ObjectInputStream ois = new ObjectInputStream(bais);
        final HomeHandle copy = (HomeHandle) ois.readObject();
        assertNotNull("The HomeHandle copy is null", copy);
        final EJBHome home = copy.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) EJBHome(jakarta.ejb.EJBHome) HomeHandle(jakarta.ejb.HomeHandle) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) ObjectInputStream(java.io.ObjectInputStream)

Example 5 with HomeHandle

use of jakarta.ejb.HomeHandle in project tomee by apache.

the class Complex2HomeHandleTests method Xtest02_copyHandleByMarshalledObject.

public void Xtest02_copyHandleByMarshalledObject() {
    try {
        final MarshalledObject obj = new MarshalledObject(ejbHomeHandle);
        final HomeHandle copy = (HomeHandle) obj.get();
        assertNotNull("The HomeHandle copy is null", copy);
        final EJBHome home = copy.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
Also used : EJBHome(jakarta.ejb.EJBHome) MarshalledObject(java.rmi.MarshalledObject) HomeHandle(jakarta.ejb.HomeHandle)

Aggregations

HomeHandle (jakarta.ejb.HomeHandle)7 EJBHome (jakarta.ejb.EJBHome)6 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 ObjectInputStream (java.io.ObjectInputStream)3 ObjectOutputStream (java.io.ObjectOutputStream)3 MarshalledObject (java.rmi.MarshalledObject)3 EJBMetaData (jakarta.ejb.EJBMetaData)1 Handle (jakarta.ejb.Handle)1 List (java.util.List)1