KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > test > orb > ExceptionTest


1 package org.jacorb.test.orb;
2
3 import junit.framework.Test;
4 import junit.framework.TestSuite;
5
6 import org.jacorb.test.*;
7 import org.jacorb.test.common.*;
8
9 /**
10  * This class gathers all sorts of exception-related tests.
11  * @author Andre Spiegel spiegel@gnu.org
12  * @version $Id: ExceptionTest.java,v 1.3 2005/05/13 13:34:36 andre.spiegel Exp $
13  */

14 public class ExceptionTest extends ClientServerTestCase
15 {
16     private ExceptionServer server;
17
18     public ExceptionTest(String JavaDoc name, ClientServerSetup setup)
19     {
20         super(name, setup);
21     }
22
23     public void setUp() throws Exception JavaDoc
24     {
25         server = ExceptionServerHelper.narrow( setup.getServerObject() );
26     }
27
28     public static Test suite()
29     {
30         TestSuite suite = new JacORBTestSuite("Client/server exception tests",
31                                               ExceptionTest.class);
32         ClientServerSetup setup =
33             new ClientServerSetup(suite,
34                                   "org.jacorb.test.orb.ExceptionServerImpl");
35
36         suite.addTest(new ExceptionTest("testRuntimeException", setup));
37         
38         return setup;
39     }
40     
41     /**
42      * Checks whether a RuntimeException in the Servant is
43      * properly reported back to the client, including the
44      * error message.
45      * @jacorb-since cvs
46      */

47     public void testRuntimeException()
48     {
49         try
50         {
51             server.throwRuntimeException("sample message");
52             fail("should have raised a CORBA SystemException");
53         }
54         catch (org.omg.CORBA.SystemException JavaDoc ex)
55         {
56             assertEquals("Server-side Exception: java.lang.RuntimeException: sample message", ex.getMessage());
57         }
58     }
59 }
60
Popular Tags