Clover coverage report - JFCUnit Test Coverage
Coverage timestamp: Mon Dec 20 2004 23:38:10 MST
file stats: LOC: 191   Methods: 10
NCLOC: 123   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
TagHandlersTagHandlerT.java - 100% 100% 100%
coverage
 1   
 package junit.extensions.xml.elements;
 2   
 
 3   
 import org.w3c.dom.Element;
 4   
 import junit.extensions.xml.IXMLTestCase;
 5   
 import junit.extensions.xml.IXMLTestSuite;
 6   
 import junit.extensions.xml.XMLException;
 7   
 import junit.extensions.xml.XMLTagResourceBundle;
 8   
 import junit.framework.TestCase;
 9   
 
 10   
 /**
 11   
  * <p>Title: Test the TagHandlersTagHandler.</p>
 12   
  * <p>Copyright: Copyright (c) 2003</p>
 13   
  * <p>Company: JFCUnit OpenSource Project </p>
 14   
  * @author Kevin Wilson
 15   
  * @version 1.0
 16   
  */
 17   
 public class TagHandlersTagHandlerT
 18   
     extends TestCase {
 19   
   /**
 20   
    * tag handler.
 21   
    */
 22   
   private TagHandlersTagHandler m_tagHandlersTagHandler = null;
 23   
 
 24   
   /**
 25   
    * Test fixture.
 26   
    */
 27   
   private ElementFixture m_fixture;
 28   
 
 29   
   /**
 30   
    * Setup the test.
 31   
    * @throws Exception may be thrown.
 32   
    */
 33  8
   protected void setUp() throws Exception {
 34  8
     super.setUp();
 35  8
     m_fixture = new ElementFixture(this);
 36  8
     m_fixture.setUp();
 37   
   }
 38   
 
 39   
   /**
 40   
    * Tear down the test.
 41   
    * @throws Exception may be thrown.
 42   
    */
 43  8
   protected void tearDown() throws Exception {
 44  8
     m_tagHandlersTagHandler = null;
 45  8
     m_fixture.tearDown();
 46   
 
 47  8
     m_fixture = null;
 48  8
     super.tearDown();
 49   
   }
 50   
 
 51   
   /**
 52   
    * Test the consturctor with testcase.
 53   
    */
 54  5
   public void testTagHandlersTagHandler() {
 55  5
     Element element = m_fixture.newElement("taghandlers", new String[] {
 56   
                                                 "action", "add",
 57   
                                                 "tagname", "abc",
 58   
                                                 "classname",
 59   
         "junit.extensions.xml.elements.NoOpTagHandler"
 60   
     });
 61  5
     IXMLTestCase testcase = m_fixture.getTestCase();
 62  5
     m_tagHandlersTagHandler = new TagHandlersTagHandler(element, testcase);
 63   
   }
 64   
 
 65   
   /**
 66   
    * Test the constructor with test suite.
 67   
    */
 68  2
   public void testTagHandlersTagHandler1() {
 69  2
     Element element = m_fixture.newElement("taghandlers", new String[] {
 70   
                                                 "action", "add",
 71   
                                                 "tagname", "abc",
 72   
                                                 "classname",
 73   
         "junit.extensions.xml.elements.NoOpTagHandler"
 74   
     });
 75  2
     IXMLTestSuite testSuite = m_fixture.getTestSuite();
 76  2
     m_tagHandlersTagHandler = new TagHandlersTagHandler(element, testSuite);
 77   
   }
 78   
 
 79   
   /**
 80   
    * Test a add tag handler.
 81   
    * @throws XMLException may be thrown.
 82   
    */
 83  1
   public void testProcessAdd() throws XMLException {
 84  1
     testTagHandlersTagHandler();
 85  1
     m_tagHandlersTagHandler.processElement();
 86   
 
 87  1
     Element abc = m_fixture.newElement("abc", new String[0]);
 88  1
     IXMLTestCase tc = m_fixture.getTestCase();
 89  1
     AbstractTagHandler ath = XMLTagResourceBundle.getTagHandler(abc, tc, "abc");
 90  1
     assertNotNull("Could not get tag handler", ath);
 91   
   }
 92   
 
 93   
   /**
 94   
    * Test adding a invalid tag handler.
 95   
    * @throws XMLException may be thrown.
 96   
    */
 97  1
   public void testProcessAdd1() throws XMLException {
 98  1
     testTagHandlersTagHandler1();
 99  1
     m_tagHandlersTagHandler.processElement();
 100  1
     Element test = m_fixture.getTestElement();
 101  1
     Element abc = m_fixture.newChild(test, "abc", new String[0]);
 102   
 
 103  1
     IXMLTestCase tc = m_fixture.getTestCase();
 104  1
     AbstractTagHandler ath = XMLTagResourceBundle.getTagHandler(abc, tc, "abc");
 105  1
     assertNotNull("Could not get tag handler", ath);
 106   
   }
 107   
 
 108   
   /**
 109   
    * Test adding a bogus class not in the classpath.
 110   
    * @throws XMLException may be thrown.
 111   
    */
 112  1
   public void testProcessAdd2() throws XMLException {
 113  1
     Element element = m_fixture.newElement("taghandlers", new String[] {
 114   
                                                 "action", "add",
 115   
                                                 "tagname", "abc",
 116   
                                                 "classname",
 117   
         "junit.extensions.xml.bogus.NoOpTagHandler"
 118   
     });
 119  1
     IXMLTestCase testcase = m_fixture.getTestCase();
 120  1
     m_tagHandlersTagHandler = new TagHandlersTagHandler(element, testcase);
 121  1
     Exception ex = null;
 122  1
     try {
 123  1
       m_tagHandlersTagHandler.processElement();
 124   
     } catch (Exception e) {
 125  1
       ex = e;
 126   
     }
 127  1
     assertNotNull("Exception expected:", ex);
 128   
   }
 129   
 
 130   
   /**
 131   
    * Test remove.
 132   
    */
 133  1
   public void testTagHandlersRemove() {
 134  1
     testTagHandlersTagHandler();
 135  1
     Element element = m_fixture.newElement("taghandlers", new String[] {
 136   
                                                 "action", "remove",
 137   
                                                 "tagname", "abc"
 138   
     });
 139  1
     IXMLTestCase testcase = m_fixture.getTestCase();
 140  1
     m_tagHandlersTagHandler = new TagHandlersTagHandler(element, testcase);
 141  1
     Element abc = m_fixture.newElement("abc", new String[0]);
 142  1
     m_tagHandlersTagHandler.processElement();
 143   
 
 144  1
     Exception ex = null;
 145  1
     try {
 146  1
       AbstractTagHandler ath = XMLTagResourceBundle.getTagHandler(abc, testcase,
 147   
           "abc");
 148   
     } catch (Exception e) {
 149  1
       ex = e;
 150   
     }
 151  1
     assertNotNull("Exception expected", ex);
 152   
   }
 153   
 
 154   
   /**
 155   
    * Test a bogus action.
 156   
    */
 157  1
   public void testTagHandlersBogus() {
 158  1
     testTagHandlersTagHandler();
 159  1
     Element element = m_fixture.newElement("taghandlers", new String[] {
 160   
                                                 "action", "removezzz",
 161   
                                                 "tagname", "abc"
 162   
     });
 163  1
     IXMLTestCase testcase = m_fixture.getTestCase();
 164  1
     m_tagHandlersTagHandler = new TagHandlersTagHandler(element, testcase);
 165  1
     Element abc = m_fixture.newElement("abc", new String[0]);
 166   
 
 167  1
     Exception ex = null;
 168  1
     try {
 169  1
       m_tagHandlersTagHandler.processElement();
 170   
     } catch (Exception e) {
 171  1
       ex = e;
 172   
     }
 173  1
     assertNotNull("Exception expected", ex);
 174   
   }
 175   
 
 176   
   /**
 177   
    * Test with the Tag lookup.
 178   
    */
 179  1
   public void testLookup() {
 180  1
     testTagHandlersTagHandler();
 181  1
     Element element = m_fixture.newElement("taghandlers", new String[] {
 182   
                                            "action", "removezzz",
 183   
                                            "tagname", "abc"
 184   
     });
 185  1
     IXMLTestCase testcase = m_fixture.getTestCase();
 186  1
     Object o = XMLTagResourceBundle.getTagHandler(element, testcase, "taghandlers");
 187  1
     assertNotNull(o);
 188   
   }
 189   
 
 190   
 }
 191