Clover coverage report -
Coverage timestamp: Do Okt 21 2004 12:21:23 CEST
file stats: LOC: 76   Methods: 6
NCLOC: 56   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
XMLFileHandlerTest.java - 83,9% 66,7% 81,1%
coverage coverage
 1    /*
 2    * XMLFileHandlerTest.java
 3    * JUnit based test
 4    *
 5    * Created on 3. Februar 2003, 22:17
 6    */
 7   
 8    package org.jconfig.handler;
 9   
 10    import java.io.File;
 11   
 12    import junit.framework.Test;
 13    import junit.framework.TestCase;
 14    import junit.framework.TestSuite;
 15   
 16    import org.jconfig.Configuration;
 17    import org.jconfig.parser.DefaultConfigParser;
 18    import org.jconfig.utils.ConfigurationUtils;
 19    /**
 20    *
 21    * @author andreas
 22    */
 23    public class XMLFileHandlerTest extends TestCase {
 24   
 25  2 public XMLFileHandlerTest(java.lang.String testName) {
 26  2 super(testName);
 27    }
 28   
 29  0 public static void main(java.lang.String[] args) {
 30  0 junit.textui.TestRunner.run(suite());
 31    }
 32   
 33  0 public static Test suite() {
 34  0 TestSuite suite = new TestSuite(XMLFileHandlerTest.class);
 35  0 return suite;
 36    }
 37   
 38  2 public void setUp() throws Exception {
 39  2 System.setProperty("jconfig.parser", DefaultConfigParser.class.getName());
 40    }
 41   
 42  1 public void testLoadAndSave() {
 43  1 File file = ConfigurationUtils.getFileFromInputStream("test.xml");
 44  1 assertNotNull(file);
 45  1 assertEquals(true, file.exists());
 46  1 try {
 47  1 XMLFileHandler handler = new XMLFileHandler();
 48  1 handler.setFile(file);
 49  1 Configuration config = handler.load("test");
 50  1 assertNotNull(config);
 51  1 String test = config.getProperty("USER",null,"JDBC");
 52  1 assertEquals("dice",test);
 53  1 assertEquals("10000",config.getProperty("maxNumber",null,"VariableTest"));
 54  1 assertEquals(10000L,config.getLongProperty("maxNumber",-1,"VariableTest"));
 55  1 String val = config.getProperty("varprop1",null,"includeTest");
 56  1 assertNotNull(val);
 57  1 assertEquals("value1",val);
 58  1 handler.setEncoding("ISO-8859-1");
 59  1 config.setProperty("PWD","for me","JDBC");
 60  1 handler.store(config);
 61  1 config = handler.load("test");
 62  1 assertNotNull(config);
 63  1 assertEquals("developer",config.getVariable("user.name"));
 64    }
 65    catch (Exception e) {
 66  0 e.printStackTrace();
 67  0 fail("unexpected exception");
 68    }
 69    }
 70   
 71  1 public void testGetEncoding() {
 72  1 XMLFileHandler handler = new XMLFileHandler();
 73  1 assertEquals("ISO-8859-1", handler.getEncodingType("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>"));
 74  1 assertEquals("ISO-8859-1", handler.getEncodingType("<?xml version='1.0' encoding='ISO-8859-1' ?>"));
 75    }
 76    }