KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > marshaliiop > test > EjbUnMarshalUnitTestCase


1 package org.jboss.test.marshaliiop.test;
2
3 import junit.framework.Test;
4 import org.jboss.test.JBossIIOPTestCase;
5 import org.jboss.test.marshaliiop.TestPayload;
6 import org.jboss.test.marshaliiop.interfaces.MarshalSession;
7 import org.jboss.test.marshaliiop.interfaces.MarshalSessionHome;
8
9 import javax.rmi.PortableRemoteObject JavaDoc;
10 import java.rmi.MarshalException JavaDoc;
11
12 /**
13  * Test that unmarshall exception is thrown.
14  *
15  * @author <a HREF="mailto:tom@jboss.org">Tom Elrod</a>
16  * @version $Revision: 43739 $
17  */

18 public class EjbUnMarshalUnitTestCase extends JBossIIOPTestCase
19 {
20    public EjbUnMarshalUnitTestCase(String JavaDoc name)
21    {
22       super(name);
23    }
24
25    public static Test suite()
26          throws Exception JavaDoc
27    {
28       return getDeploySetup(EjbUnMarshalUnitTestCase.class, "test-ejb-iiop-unmarshal.jar");
29    }
30
31    /**
32     * This is a simple test which calls on the MarshalSession bean, passing a TestPayload
33     * object as the parameter. The deployed jar with the MarshalSession should NOT contain
34     * the TestPayload class, thus cause there to be a UnmarshalException to be thrown.
35     *
36     * @throws Exception
37     */

38    public void testUnMarshalException() throws Exception JavaDoc
39    {
40       Object JavaDoc objHome = getInitialContext().lookup("marshalliiop/MarshallSession");
41       objHome = PortableRemoteObject.narrow(objHome, MarshalSessionHome.class);
42       MarshalSessionHome marshalHome = (MarshalSessionHome) objHome;
43       MarshalSession marshalSession = marshalHome.create();
44
45       TestPayload payload = new TestPayload();
46       try
47       {
48          marshalSession.testMethod(payload);
49          assertTrue("Call on MarshalSession.testMethod() should have thrown UnmarshalException, but did not", false);
50       }
51       catch (MarshalException JavaDoc e)
52       {
53          assertTrue(true);
54       }
55       catch (Throwable JavaDoc thr)
56       {
57          thr.printStackTrace();
58          throw new Exception JavaDoc(thr);
59       }
60    }
61
62 }
63
Popular Tags