KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

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