1 package org.sapia.regis; 2 3 import java.util.Properties ; 4 5 import org.sapia.regis.local.LocalRegistry; 6 import org.sapia.regis.local.LocalRegistryFactory; 7 8 import junit.framework.TestCase; 9 10 public class RegistryContextTest extends TestCase { 11 12 public RegistryContextTest(String arg0) { 13 super(arg0); 14 } 15 16 public void testConnect() throws Exception { 17 Properties props = new Properties (); 18 props.setProperty(RegistryContext.FACTORY_CLASS, LocalRegistryFactory.class.getName()); 19 super.assertTrue(new RegistryContext(props).connect() instanceof LocalRegistry); 20 } 21 22 public void testBootstrapPrecedence() throws Exception { 23 Properties props = new Properties (); 24 props.setProperty(RegistryContext.BOOTSTRAP, "${user.dir}/etc/bootstrap1.properties, file:etc/bootstrap2.properties"); 25 Node node = new RegistryContext(props).connect().getRoot().getChild(Path.parse("databases/000")); 26 super.assertEquals("jsmith", node.getProperty("username").asString()); 27 } 28 29 public void testBootstrapFallback() throws Exception { 30 Properties props = new Properties (); 31 props.setProperty(RegistryContext.BOOTSTRAP, "etc/foo.properties, ${user.dir}/etc/bootstrap2.properties"); 32 Node node = new RegistryContext(props).connect().getRoot().getChild(Path.parse("databases/001")); 33 super.assertEquals("stiger", node.getProperty("username").asString()); 34 } 35 36 37 } 38 | Popular Tags |