Clover coverage report -
Coverage timestamp: Do Okt 21 2004 12:21:23 CEST
file stats: LOC: 155   Methods: 14
NCLOC: 78   Classes: 2
 
 Source file Conditionals Statements Methods TOTAL
ConfigurationManagerTest.java 50% 78,9% 78,6% 76,8%
coverage coverage
 1    package org.jconfig;
 2   
 3    import junit.framework.TestCase;
 4   
 5    import org.jconfig.handler.ConfigurationHandler;
 6    import org.jconfig.handler.PropertiesFileHandler;
 7   
 8    import java.util.HashMap;
 9    import java.util.Map;
 10   
 11    /**
 12    * @author Andreas Mecky <andreas.mecky@xcom.de>
 13    * @author Terry Dye <terry.dye@xcom.de>
 14    *
 15    */
 16    public class ConfigurationManagerTest extends TestCase {
 17   
 18    /**
 19    * Constructor for ConfigurationManagerTest.
 20    * @param arg0
 21    */
 22  10 public ConfigurationManagerTest(String arg0) {
 23  10 super(arg0);
 24    }
 25   
 26  0 public static void main(String[] args) {
 27  0 junit.textui.TestRunner.run(ConfigurationManagerTest.class);
 28    }
 29   
 30  1 public void testGetInstance() {
 31  1 ConfigurationManager cm = ConfigurationManager.getInstance();
 32  1 assertNotNull(cm);
 33    }
 34   
 35    /*
 36    * Test for Configuration getConfiguration()
 37    */
 38  1 public void testGetConfiguration() {
 39  1 Configuration config = ConfigurationManager.getConfiguration();
 40  1 assertNotNull(config);
 41    }
 42   
 43    /*
 44    * Test for Configuration getConfiguration(String)
 45    */
 46  1 public void testGetConfigurationString() {
 47  1 Configuration configXyz = ConfigurationManager.getConfiguration("xyz");
 48  1 Configuration configAbc = ConfigurationManager.getConfiguration("abc");
 49  1 assertNotNull(configXyz);
 50  1 assertNotNull(configAbc);
 51    }
 52   
 53   
 54    /**
 55    * Method testSaveConfigurationHandlerConfiguration.
 56    */
 57    /*
 58    * Test for void save(ConfigurationHandler, Configuration)
 59    */
 60  1 public void testSaveConfigurationHandlerConfiguration() {
 61    }
 62   
 63    /**
 64    * Method testReload.
 65    */
 66  1 public void testReload() {
 67  1 Configuration config = ConfigurationManager.getConfiguration("default");
 68    }
 69   
 70    /**
 71    * Method testSaveString.
 72    */
 73    /*
 74    * Test for void save(String)
 75    */
 76  1 public void testSaveString() {
 77    }
 78   
 79    /**
 80    * Method testAddPropertyListener.
 81    */
 82  1 public void testAddPropertyListener() throws Exception {
 83  1 ConfigurationHandler ish = new PropertiesFileHandler("jconfig.properties");
 84   
 85  1 ConfigurationManager.getInstance().load(ish,"default");
 86  1 ConfigurationManager manager = ConfigurationManager.getInstance();
 87    }
 88   
 89    /**
 90    * Method testFileChanged.
 91    */
 92    // This is tested in the ConfigurationTest
 93  0 public void _testFileChanged() {
 94  0 Configuration config = ConfigurationManager.getConfiguration();
 95  0 WaitingHelper helper = new WaitingHelper();
 96  0 helper.run();
 97  0 config.getProperty("SOMETHING", "SOMETHING");
 98    // here where's you need to do something to the file
 99    // and verify that the changes were accepted. Perhaps it would
 100    // be easier to have two files, and just copy over the watched
 101    // file for testing.
 102    }
 103   
 104    /**
 105    * Method testInputStreamHandler.
 106    * @throws Exception
 107    */
 108  1 public void testInputStreamHandler() throws Exception {
 109  1 ConfigurationHandler ish = new PropertiesFileHandler("jconfig.properties");
 110   
 111  1 Configuration config = ConfigurationManager.getConfiguration("default");
 112  1 ConfigurationManager.getInstance().load(ish,"default");
 113  1 assertEquals("8080",config.getProperty("http.proxyPort"));
 114  1 assertEquals("192.168.3.1",config.getProperty("http.proxyHost"));
 115    }
 116   
 117  1 public void testGetConfigurationWithName() {
 118  1 Configuration configXyz = ConfigurationManager.getConfiguration("test");
 119  1 assertNotNull(configXyz);
 120  1 assertTrue(!configXyz.isNew());
 121  1 String special = configXyz.getProperty("special");
 122  1 assertEquals("one",special);
 123    }
 124   
 125  1 public void testGetConfigurationNames() {
 126  1 String[] names = ConfigurationManager.getInstance().getConfigurationNames();
 127  1 Map map = new HashMap();
 128  1 for (int i = 0; i < names.length; i++) {
 129  3 map.put(names[i], names[i]);
 130    }
 131  1 assertNotNull(names);
 132  1 assertNotNull(map.get("default"));
 133  1 assertNotNull(map.get("test"));
 134    }
 135    }
 136    /*
 137    * jUnit doesn't like you to put the thread on hold,
 138    * and I have no idea how to get around this problem.
 139    * so we set things into a very long loop. hopefully
 140    * it is enough time to test what we want.
 141    *
 142    */
 143    class WaitingHelper implements Runnable {
 144    private boolean state = true;
 145    /**
 146    * @see java.lang.Runnable#run()
 147    */
 148  0 public void run() {
 149  0 int i = 0;
 150  0 while(i<999999999) {
 151  0 i++;
 152    }
 153    }
 154   
 155    }