Package org.jconfig

Examples of org.jconfig.Configuration


    }
   
    private Configuration getConfig() {
        ConfigurationManager.getInstance().removeConfiguration("test_ls");
        ConfigurationHandler handler = new MockJDBCHandler();       
        Configuration cfg = null;
        try {
             cfg = handler.load("test_ls");   
        } catch (ConfigurationManagerException e) {           
            e.printStackTrace();
            fail("unexpected exception");
View Full Code Here


        assertNotNull(file);
        assertEquals(true, file.exists());
        try {
            XMLFileHandler handler = new XMLFileHandler();
            handler.setFile(file);
            Configuration config = handler.load("test");
            assertNotNull(config);
            String test = config.getProperty("USER",null,"JDBC");
            assertEquals("dice",test);
            assertEquals("10000",config.getProperty("maxNumber",null,"VariableTest"));
            assertEquals(10000L,config.getLongProperty("maxNumber",-1,"VariableTest"));
            String val = config.getProperty("varprop1",null,"includeTest");
            assertNotNull(val);
            assertEquals("value1",val);
            handler.setEncoding("ISO-8859-1");           
            config.setProperty("PWD","for me","JDBC");
            handler.store(config);
            config = handler.load("test");
            assertNotNull(config);
            assertEquals("developer",config.getVariable("user.name"));
        }
        catch (Exception e) {
            e.printStackTrace();
            fail("unexpected exception");
        }
View Full Code Here

   
    public void testLoad() throws Exception {       
        File file = ConfigurationUtils.getFileFromInputStream("test.properties");
        PropertiesFileHandler handler = new PropertiesFileHandler();
        handler.setFile(file);
        Configuration config = handler.load("test");
        assertNotNull(config);
        assertEquals(1,config.getNumberOfCategories());
        assertEquals("/usr/development/mystuff/etc/new_sitemap.xml",config.getProperty("sitemap_file"));
    }
View Full Code Here

   
    public void testLoad() {
        InputStreamHandler cHandler = new InputStreamHandler();
        cHandler.setFileName("test.xml");       
        try {
            Configuration config = cHandler.load("test");
            assertNotNull(config);
            String test = config.getProperty("USER",null,"JDBC");
            assertEquals("dice",test);
            cHandler.setEncoding("iso-8859-1");
            config.setProperty("PWD","for me","JDBC");
//            assertEquals("ISO-8859-1",config.getEncoding());
            String val = config.getProperty("varprop1",null,"includeTest");
            assertNotNull(val);
            assertEquals("value1",val);
            cHandler.store(config);           
        }
        catch (Exception e) {
View Full Code Here

    }
   
    public void testLoad() {
        SimpleScriptHandler scriptHandler = new SimpleScriptHandler();
        try {
            Configuration cfg = scriptHandler.load("simple");
            assertNotNull(cfg);
            String val = cfg.getProperty("hello");
            assertEquals("world",val);
            val = cfg.getProperty("val1","unknown","mycategory");
            assertEquals("100",val);
        }
        catch (Exception e) {
            e.printStackTrace();
            fail("unexpected exception");
View Full Code Here

    }
 
  public void testSave() {
        SimpleScriptHandler scriptHandler = new SimpleScriptHandler();
        try {
            Configuration cfg = scriptHandler.load("simple");
            assertNotNull(cfg);
      cfg.setProperty("save","now");
      //System.out.println(cfg);
      scriptHandler.store(cfg);
      cfg = scriptHandler.load("simple");
            assertEquals("world",cfg.getProperty("hello"));
      assertEquals("now",cfg.getProperty("save"));
            assertEquals("100",cfg.getProperty("val1","unknown","mycategory"));
        }
        catch (Exception e) {
            e.printStackTrace();
            fail("unexpected exception");
        }
View Full Code Here

    }
   
    public void testLoad() {
        ScriptHandler scriptHandler = new ScriptHandler();
        try {
            Configuration cfg = scriptHandler.load("test");
            assertNotNull(cfg);
            String val = cfg.getProperty("hello");
            assertEquals("world",val);
            val = cfg.getProperty("more",null,"special");
            assertEquals("override",val);
            val = cfg.getProperty("more",null,"stuff");
            assertEquals("override",val);
            val = cfg.getProperty("my crap",null,"stuff");
            assertEquals("is real crap",val);
            //assertEquals("is real crap2",val);
        }
        catch (Exception e) {
            e.printStackTrace();
View Full Code Here

    }
   
    public void testLoad() {
        LDAPHandler ldapHandler = new LDAPHandler();
        try {
            Configuration config = ldapHandler.load("so what");
            assertNotNull(config);
            String[] cats = config.getCategoryNames();
            //assertEquals(2,cats.length);
            for ( int i = 0; i < cats.length;i++) {
                System.out.println("CAT["+i+"]:"+cats[i]);
            }
        }
View Full Code Here

   
    public void testLoad() {       
        try {
            URLHandler handler = new URLHandler();
            handler.setURL("http://localhost:8181/test.xml");
            Configuration config = handler.load("test");
            assertNotNull(config);
            String test = config.getProperty("USER",null,"JDBC");
            assertEquals("dice",test);
            assertEquals("10000",config.getProperty("maxNumber",null,"VariableTest"));
            assertEquals(10000L,config.getLongProperty("maxNumber",-1,"VariableTest"));           
        }
        catch (Exception e) {
            e.printStackTrace();
            fail("unexpected exception");
        }
View Full Code Here

        java.net.URL jcfURL = null;
        InputStream is = null;
        try {           
            ConfigServerHandler urlHandler = new ConfigServerHandler();
            urlHandler.setURL(URL+"/config");
            Configuration config = urlHandler.load();
            assertNotNull(config);
            assertEquals("dice",config.getProperty("USER",null,"JDBC"));
        }
        catch ( Exception e ) {
            e.printStackTrace();
        }       
    }       
View Full Code Here

TOP

Related Classes of org.jconfig.Configuration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.