Clover coverage report -
Coverage timestamp: Do Okt 21 2004 12:21:23 CEST
file stats: LOC: 63   Methods: 5
NCLOC: 49   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
NestedConfigCategoryTest.java 100% 96,2% 80% 94,9%
coverage coverage
 1    package org.jconfig.parser;
 2   
 3    import java.util.Collection;
 4    import java.util.Iterator;
 5    import java.util.Map;
 6    import java.util.HashMap;
 7   
 8    import junit.framework.TestCase;
 9    import org.jconfig.*;
 10    /**
 11    * Testcase for testig the NestedConfiguration
 12    *
 13    * @since 2.2
 14    * @author Andreas Mecky <andreas.mecky@xcom.de>
 15    * @author Terry Dye <terry.dye@xcom.de>
 16    */
 17    public class NestedConfigCategoryTest extends TestCase {
 18   
 19  2 public NestedConfigCategoryTest(String arg0) {
 20  2 super(arg0);
 21    }
 22   
 23  0 public static void main(String[] args) {
 24  0 junit.textui.TestRunner.run(NestedConfigCategoryTest.class);
 25    }
 26   
 27  2 public void tearDown() throws Exception {
 28  2 System.setProperty("jconfig.parser","org.jconfig.parser.DefaultConfigParser");
 29    }
 30   
 31  1 public void testGetCategoryNames() {
 32  1 ConfigurationManager.getInstance().removeConfiguration("nested");
 33  1 System.setProperty("jconfig.parser","org.jconfig.parser.NestedConfigParser");
 34  1 Configuration config = ConfigurationManager.getConfiguration("nested");
 35  1 String[] expected = {"inner","inner/myinner","inner/myinner/moreinner","MyApp","includeTest","general"};
 36  1 String[] names = config.getCategoryNames();
 37  1 Map map = new HashMap();
 38  1 for( int i = 0; i < names.length;i++ ) {
 39  6 map.put(names[i], names[i]);
 40    }
 41  1 for ( int i = 0; i < names.length;i++) {
 42  6 assertNotNull(map.get(expected[i]));
 43  6 NestedCategory nc = (NestedCategory)config.getCategory(names[i]);
 44  6 Collection children = nc.getChildCategories();
 45  6 if ( names[i].equals("inner")) {
 46  1 assertEquals(1,children.size());
 47    }
 48  6 Iterator it = children.iterator();
 49  6 while ( it.hasNext() ) {
 50  2 NestedCategory child = (NestedCategory)it.next();
 51    }
 52    }
 53    }
 54   
 55  1 public void testGetCategory() {
 56  1 ConfigurationManager.getInstance().removeConfiguration("nested");
 57  1 System.setProperty("jconfig.parser","org.jconfig.parser.NestedConfigParser");
 58  1 Configuration config = ConfigurationManager.getConfiguration("nested");
 59  1 NestedCategory nc = (NestedCategory)config.getCategory("inner/myinner/moreinner");
 60  1 assertNotNull(nc);
 61  1 assertEquals("moreinner",nc.getCategoryName());
 62    }
 63    }