1 16 package org.apache.naming; 17 18 import java.util.Hashtable ; 19 20 import javax.naming.Context ; 21 22 import junit.framework.Test; 23 import junit.framework.TestSuite; 24 import junit.textui.TestRunner; 25 26 27 32 public class SynchronizedContextTest extends AbstractContextTest { 33 34 public SynchronizedContextTest(String name) { 35 super(name); 36 } 37 38 public static void main(String [] args) { 39 TestRunner.run(suite()); 40 } 41 42 public static Test suite() { 43 TestSuite suite = new TestSuite(SynchronizedContextTest.class); 44 suite.setName("Synchronized Context Tests"); 45 return suite; 46 } 47 48 protected Context makeInitialContext() { 49 try { 50 Hashtable env = new Hashtable (); 51 env.put(SynchronizedContext.SYNCHRONIZED, "true"); 52 NamingContext ctx = new NamingContext(env, "root"); 53 return new SynchronizedContext(ctx); 54 } catch (Exception ex) { 55 fail("Failed to create SynchronizedContext"); 56 } 57 return null; 58 } 59 60 protected boolean isGetNameInNamespaceSupported() { 61 return false; 62 } 63 64 public void testIsSynchronized() throws Exception { 65 assertTrue(SynchronizedContext.isSynchronized(initialContext.getEnvironment())); 66 Hashtable env = new Hashtable (); 67 env.put(SynchronizedContext.SYNCHRONIZED, "false"); 68 assertFalse(SynchronizedContext.isSynchronized(env)); 69 env = null; 70 assertFalse(SynchronizedContext.isSynchronized(env)); 71 } 72 } 73 | Popular Tags |