Clover coverage report -
Coverage timestamp: Do Okt 21 2004 12:21:23 CEST
file stats: LOC: 107   Methods: 9
NCLOC: 66   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
CategoryTest.java - 97,7% 88,9% 96,2%
coverage coverage
 1    /*
 2    * Created on 23.07.2003
 3    *
 4    * To change the template for this generated file go to
 5    * Window>Preferences>Java>Code Generation>Code and Comments
 6    */
 7    package org.jconfig;
 8   
 9    import junit.framework.TestCase;
 10   
 11    /**
 12    * test cases for the new category object
 13    * these tests are an extension of the existing test
 14    * cases used in the ConfigurationTest
 15    *
 16    * @since 2.2
 17    * @author Andreas Mecky <andreas.mecky@xcom.de>
 18    * @author Terry Dye <terry.dye@xcom.de>
 19    */
 20    public class CategoryTest extends TestCase {
 21   
 22    private Configuration cfg;
 23   
 24    /**
 25    * Constructor for CategoryTest.
 26    * @param arg0
 27    */
 28  6 public CategoryTest(String arg0) {
 29  6 super(arg0);
 30    }
 31   
 32  0 public static void main(String[] args) {
 33  0 junit.textui.TestRunner.run(CategoryTest.class);
 34    }
 35   
 36  1 public void testSetBooleanProperty() {
 37  1 cfg.getCategory().setBooleanProperty("myBoolean", true);
 38  1 cfg.setBooleanProperty("myBoolean", true);
 39  1 assertEquals(cfg.getCategory().getBooleanProperty("myBoolean", false), true);
 40  1 assertEquals(cfg.getBooleanProperty("myBoolean", true),cfg.getCategory().getBooleanProperty("myBoolean", false));
 41  1 assertEquals(cfg.getBooleanProperty("Boolean", true),cfg.getCategory().getBooleanProperty("Boolean", true));
 42  1 cfg.setBooleanProperty("myBoolean", false);
 43  1 assertEquals(cfg.getCategory().getBooleanProperty("myBoolean", true), false);
 44   
 45  1 cfg.setBooleanProperty("myBoolean", true, "xtra");
 46  1 assertEquals(cfg.getBooleanProperty("myBoolean", false, "xtra"), cfg.getCategory("xtra").getBooleanProperty("myBoolean", true));
 47   
 48    }
 49   
 50  1 public void testSetLongProperty() {
 51  1 cfg.setLongProperty("myLong", 100);
 52  1 assertEquals(cfg.getLongProperty("myLong", -1l), cfg.getCategory().getLongProperty("myLong",-2l));
 53  1 cfg.getCategory().setLongProperty("myLong", 200l);
 54  1 assertEquals(cfg.getLongProperty("myLong", -1l), cfg.getCategory().getLongProperty("myLong",-2l));
 55   
 56  1 cfg.setLongProperty("myLong", 200, "xtra");
 57  1 assertEquals(cfg.getLongProperty("myLong", -1l, "xtra"), cfg.getCategory("xtra").getLongProperty("myLong",-2l));
 58    }
 59   
 60  1 public void testSetIntProperty() {
 61  1 cfg.setIntProperty("key", 100);
 62  1 assertEquals(cfg.getIntProperty("key", -1), cfg.getCategory().getIntProperty("key",-2));
 63  1 cfg.getCategory().setIntProperty("key", 200);
 64  1 assertEquals(cfg.getIntProperty("key", -1), cfg.getCategory().getIntProperty("key",-2));
 65   
 66  1 cfg.setIntProperty("intKey", 200, "xtra");
 67  1 assertEquals(cfg.getIntProperty("intKey", -1, "xtra"), cfg.getCategory("xtra").getIntProperty("intKey",-2));
 68    }
 69   
 70  1 public void testSetCharProperty() {
 71  1 cfg.setCharProperty("key", 'x');
 72  1 assertEquals(cfg.getCharProperty("key", 'a'), cfg.getCategory().getCharProperty("key",'b'));
 73  1 cfg.getCategory().setCharProperty("key", 'y');
 74  1 assertEquals(cfg.getCharProperty("key", 'a'), cfg.getCategory().getCharProperty("key",'b'));
 75   
 76  1 cfg.setCharProperty("key", 'x', "doobie");
 77  1 assertEquals(cfg.getCharProperty("key", 'a', "doobie"), cfg.getCategory("doobie").getCharProperty("key",'b'));
 78    }
 79   
 80  1 public void testSetDoubleProperty() {
 81  1 cfg.setDoubleProperty("key", 100.987d);
 82  1 assertEquals(cfg.getDoubleProperty("key", -1), cfg.getCategory().getDoubleProperty("key", -2), 0d);
 83  1 cfg.getCategory().setDoubleProperty("key", 200.987d);
 84  1 assertEquals(cfg.getDoubleProperty("key", -1), cfg.getCategory().getDoubleProperty("key",-2), 0d);
 85   
 86  1 cfg.setDoubleProperty("key", 100.987d, "catdog");
 87  1 assertEquals(cfg.getDoubleProperty("key", -1, "catdog"), cfg.getCategory("catdog").getDoubleProperty("key", -2), 0d);
 88    }
 89   
 90  1 public void testGetIntWithVar() {
 91  1 cfg.setProperty("ival","${intvar}123");
 92  1 int val = cfg.getIntProperty("ival",-1);
 93  1 assertEquals(11123,val);
 94    }
 95   
 96    /* (non-Javadoc)
 97    * @see junit.framework.TestCase#setUp()
 98    */
 99  6 protected void setUp() throws Exception {
 100  6 super.setUp();
 101  6 cfg = new DefaultConfiguration("Test");
 102  6 assertNotNull(cfg);
 103  6 VariableManager vm = VariableManager.getInstance();
 104  6 vm.addVariable("intvar","11", "Test");
 105    }
 106   
 107    }