Package org.jconfig

Examples of org.jconfig.Configuration


        junit.textui.TestRunner.run(CDataConfigParserTest.class);
    }
   
    public void testParseCDataConfig() {
        System.setProperty("jconfig.parser","org.jconfig.parser.CDataConfigParser");
        Configuration config = ConfigurationManager.getConfiguration("advanced");
        String world = config.getProperty("hello");
        assertEquals("world",world);
        String escape = config.getProperty("escapetest");
        assertEquals(escape,"this\nis\nme");
        String special = config.getProperty("special",null,"inner");
        assertEquals("one",special);
        System.setProperty("jconfig.parser","org.jconfig.parser.DefaultConfigParser");
    }
View Full Code Here


        try {
            XMLFileHandler fileHandler = new XMLFileHandler();
            String filename = System.getProperty("java.io.tmpdir")+"cdata_test_config.xml";           
            File file = new File(filename);
            fileHandler.setFile(file);
            Configuration config = ConfigurationManager.getConfiguration("advanced");
            fileHandler.store(config);
            config = fileHandler.load(file, "MyTest");
            String special = config.getProperty("special",null,"inner");
            assertEquals("one",special);
        }
        catch (Exception e) {
            e.printStackTrace();
            fail("unexpected exception");
View Full Code Here

    super.tearDown();
  }
 
  public void testErrorHandler() {
    System.setProperty("jconfig.errorhandler","org.jconfig.error.MockErrorHandler");
    Configuration cfg = ConfigurationManager.getConfiguration("I do not exist");
    assertNotNull(cfg);
    MockErrorHandler handler = (MockErrorHandler)ErrorReporter.getErrorHandler();
    assertEquals("Problem while trying to read configuration. Returning new configuration.",handler.getMsg());   
    System.setProperty("jconfig.errorhandler","blabla");
  }
View Full Code Here

   
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Configuration config = ConfigurationManager.getConfiguration("simple");
        JDBCBeanHelper helper = new JDBCBeanHelper();
        CategoryBeanMapper.mapBean(helper,"JDBC","simple");
        System.out.println("URL:"+helper.getURL());
        System.out.println("port:"+helper.getPORT());
    }
View Full Code Here

        } catch (ConfigurationManagerException e) {
            assertEquals("Configuration name not valid. Empty String not allowed", e.getMessage());
            // this was expected
        }
        // next we check for valid jdbc settings
        Configuration configuration = handler.load("test_ls");
        assertNotNull("JDBC Configuration could not be loaded.", configuration);
        Category news = configuration.getCategory("news");
        assertNotNull("Category was <null>. This cannot be true.", news);
        assertEquals("Expected value was wrong.", "10", news.getProperty("count"));
        Category general = configuration.getCategory("general");
        assertNotNull("Category was <null>. This cannot be true", general);
        assertEquals("Expected value was wrong.", "JDBC is cool", general.getProperty("description"));
    }
View Full Code Here

        assertNotNull("Category was <null>. This cannot be true", general);
        assertEquals("Expected value was wrong.", "JDBC is cool", general.getProperty("description"));
    }
   
    public void testLoadAndSave() {       
        Configuration cfg = getConfig();       
        assertNotNull(cfg);               
        Category news = cfg.getCategory("news");
        assertNotNull("Category was <null>. This cannot be true.", news);
        assertEquals("Expected value was wrong.", "10", news.getProperty("count"));       
    }
View Full Code Here

        var = VariableManager.getInstance().getVariable("test_ls","my.path");
        assertEquals("/usr/development/mystuff/etc",var);
    }
   
    public void testReplaceVariable() {               
        Configuration cfg = getConfig();       
        String var = cfg.getProperty("workflow_file");
        assertNotNull(var);
        assertEquals(var,"/usr/development/mystuff/etc/workflow.xml");       
    }
View Full Code Here

        assertNotNull(var);
        assertEquals(var,"/usr/development/mystuff/etc/workflow.xml");       
    }
   
    public void testRemoveAndReplaceVariable() {               
        Configuration cfg = getConfig();       
        String var = cfg.getProperty("workflow_file");
        assertNotNull(var);
        assertEquals(var,"/usr/development/mystuff/etc/workflow.xml");
        VariableManager.getInstance().removeVariable("my.path","test_ls");
        try {
            ConfigurationHandler handler = new MockJDBCHandler();       
            handler.store(cfg);           
        } catch (ConfigurationManagerException e) {           
        }       
        cfg = getConfig();
        var = cfg.getProperty("workflow_file");
        assertNotNull(var);       
        assertEquals(var,"${my.path}/workflow.xml");
    }
View Full Code Here

        assertNotNull(var);       
        assertEquals(var,"${my.path}/workflow.xml");
    }
   
    public void testRemoveProperty() {               
        Configuration cfg = getConfig();       
        cfg.removeProperty("delete");
        try {
            ConfigurationHandler handler = new MockJDBCHandler();       
            handler.store(cfg);           
        } catch (ConfigurationManagerException e) {           
        }
       
        cfg = getConfig();
        assertNull(cfg.getProperty("delete"));
    }
View Full Code Here

        cfg = getConfig();
        assertNull(cfg.getProperty("delete"));
    }
   
    public void testAddProperty() {               
        Configuration cfg = getConfig();       
        cfg.setProperty("hello","world","new.one");
        try {
            ConfigurationHandler handler = new MockJDBCHandler();       
            handler.store(cfg);           
        } catch (ConfigurationManagerException e) {           
        }
       
        cfg = getConfig();
        assertNotNull(cfg.getProperty("hello",null,"new.one"));
    }
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.