1 8 package org.codehaus.spice.jndikit.rmi.test; 9 10 import javax.naming.Context ; 11 import javax.naming.OperationNotSupportedException ; 12 import javax.naming.NamingException ; 13 14 import org.codehaus.spice.jndikit.rmi.RMIInitialContextFactory; 15 import org.codehaus.spice.jndikit.test.AbstractContextTestCase; 16 import junit.framework.AssertionFailedError; 17 18 24 public abstract class AbstractRMIContextTestCase 25 extends AbstractContextTestCase 26 { 27 28 private final RMITestSetup _helper; 29 30 public AbstractRMIContextTestCase( RMIInitialContextFactory factory ) 31 { 32 _helper = new RMITestSetup( factory ); 33 } 34 35 public void testGetNameInNamespace() throws AssertionFailedError 36 { 37 try 38 { 39 Context sub1 = m_root.createSubcontext( "sub1"); 40 Context sub2 = sub1.createSubcontext( "sub2"); 41 Context sub3 = sub2.createSubcontext( "sub3"); 42 Context sub4 = sub3.createSubcontext( "sub4"); 43 assertEquals("sub1/sub2/sub3/sub4", sub4.getNameInNamespace()); 44 } 45 catch( final NamingException ne ) 46 { 47 throw new AssertionFailedError( ne.getMessage() ); 48 } 49 } 50 51 57 public void testInvalidBind() throws AssertionFailedError { 58 try 59 { 60 m_context.bind("invalid", new Object ()); 61 fail("Expected bind of non-Serializable, non-Referenceable object to throw NamingException"); 62 } catch (final NamingException expected) { 63 } 64 } 65 66 protected void setUp() throws Exception 67 { 68 _helper.setUp(); 69 super.setUp(); 70 } 71 72 protected void tearDown() throws Exception 73 { 74 _helper.tearDown(); 75 super.tearDown(); 76 } 77 78 protected Context getRoot() throws Exception 79 { 80 return _helper.getRoot(); 81 } 82 83 } 84 | Popular Tags |