1 22 package org.jboss.ejb3.test.exception.unit; 23 24 import javax.naming.InitialContext ; 25 import org.jboss.ejb3.test.exception.Foo1; 26 import org.jboss.ejb3.test.exception.FooException1; 27 import org.jboss.logging.Logger; 28 import org.jboss.test.JBossTestCase; 29 import junit.framework.Test; 30 31 35 public class ExceptionTestCase 36 extends JBossTestCase { 37 38 private static final Logger log = Logger 39 .getLogger(ExceptionTestCase.class); 40 41 public ExceptionTestCase(String name) 42 { 43 super(name); 44 } 45 46 public void testException() throws Exception 47 { 48 InitialContext jndiContext = new InitialContext (); 49 50 Foo1 foo = (Foo1) jndiContext.lookup("FooBean1/remote"); 51 assertNotNull(foo); 52 53 try { 54 foo.bar(); 55 assertTrue(false); 56 } catch (Throwable t){ 57 t.printStackTrace(); 58 assertTrue(t instanceof FooException1); 59 } 60 61 String status = foo.getStatus(); 62 assertEquals("Caught FooException1", status); 63 } 64 65 public static Test suite() throws Exception 66 { 67 return getDeploySetup(ExceptionTestCase.class, "exception.jar"); 68 } 69 70 } 71 | Popular Tags |