simplescripthandlertest.java

来自「jConfig,JAVA读取XML的开源项目」· Java 代码 · 共 74 行

JAVA
74
字号
/*
 * LDAPHandlerTest.java
 * JUnit based test
 *
 * Created on 8. Dezember 2002, 23:45
 */

package org.jconfig.handler;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

import org.jconfig.Configuration;

/**
 *
 * @author Administrator
 */
public class SimpleScriptHandlerTest extends TestCase {
    
    public SimpleScriptHandlerTest(java.lang.String testName) {
        super(testName);
    }
    
    public void setUp() {
    	//ConfigurationManager.
    }
    
    public static void main(java.lang.String[] args) {
        junit.textui.TestRunner.run(suite());
    }
    
    public static Test suite() {
        TestSuite suite = new TestSuite(SimpleScriptHandlerTest.class);
        return suite;
    }
    
    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");
        }
    }
	
	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");
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?