Clover coverage report - JFCUnit Test Coverage
Coverage timestamp: Mon Dec 20 2004 23:38:10 MST
file stats: LOC: 112   Methods: 5
NCLOC: 66   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
FileTagHandlerT.java - 100% 100% 100%
coverage
 1   
 package junit.extensions.xml.elements;
 2   
 
 3   
 import java.io.File;
 4   
 import java.io.IOException;
 5   
 
 6   
 import org.w3c.dom.Element;
 7   
 import junit.extensions.xml.XMLConstants;
 8   
 import junit.extensions.xml.XMLException;
 9   
 import junit.framework.TestCase;
 10   
 import junit.extensions.xml.XMLTagResourceBundle;
 11   
 import junit.extensions.xml.IXMLTestSuite;
 12   
 
 13   
 /**
 14   
  * <p>Title: Test the File tag handler.</p>
 15   
  * <p>Description: </p>
 16   
  * <p>Copyright: Copyright (c) 2003</p>
 17   
  * <p>Company: </p>
 18   
  * @author Kevin Wilson not attributable
 19   
  * @version 1.0
 20   
  */
 21   
 
 22   
 public class FileTagHandlerT extends TestCase {
 23   
   /**
 24   
    * element fixture.
 25   
    */
 26   
   private ElementFixture m_elementFixture;
 27   
 
 28   
   /**
 29   
    * Setup the test.
 30   
    * @throws Exception may be thrown.
 31   
    */
 32  3
   protected void setUp() throws Exception {
 33  3
     super.setUp();
 34  3
     m_elementFixture = new ElementFixture(this);
 35   
 
 36  3
     m_elementFixture.setUp();
 37   
   }
 38   
 
 39   
   /**
 40   
    * Tear down the test.
 41   
    * @throws Exception may be thrown.
 42   
    */
 43  3
   protected void tearDown() throws Exception {
 44  3
     m_elementFixture.tearDown();
 45   
 
 46  3
     m_elementFixture = null;
 47  3
     super.tearDown();
 48   
   }
 49   
 
 50   
   /**
 51   
    * Test a relative path.
 52   
    * @throws IOException may be thrown.
 53   
    */
 54  1
   public void testRelative() throws IOException {
 55  1
     String filename = "C:\\sourceforge\\File1.xml";
 56  1
     String filename2 = "C:\\sourceforge\\jfcunit\\Relative.xml";
 57   
 
 58  1
     Element suite = m_elementFixture.getSuiteElement();
 59  1
     File f = new File(filename);
 60  1
     Element fileElement = m_elementFixture.newChild(suite, "file", new String[] {
 61   
                                           "name", "jfcunit\\Relative.xml",
 62   
                                           "relative", "true"
 63   
     });
 64  1
     m_elementFixture.saveFile(f);
 65   
 
 66  1
     ElementFixture ef2 = new ElementFixture(this);
 67  1
     ef2.setUp();
 68  1
     ef2.saveFile(new File(filename2));
 69   
 
 70  1
     fileElement.getOwnerDocument().getDocumentElement().setAttribute(XMLConstants.JFCFILELOC, filename);
 71  1
     FileTagHandler file = new FileTagHandler(fileElement, m_elementFixture.getTestSuite());
 72  1
     m_elementFixture.saveFile(f);
 73  1
     XMLException ex = null;
 74  1
       file.processElement();
 75   
   }
 76   
 
 77   
   /**
 78   
    * Test the stack overflow condition.
 79   
    * @throws IOException may be thrown.
 80   
    */
 81  1
   public void testStackOverFlowException() throws IOException {
 82  1
     String filename = "TESTOverFlow.xml";
 83  1
     Element suite = m_elementFixture.getSuiteElement();
 84  1
     File f = new File(filename);
 85  1
     Element fileElement = m_elementFixture.newChild(suite, "file", new String[] {
 86   
                                           "name", filename
 87   
     });
 88  1
     FileTagHandler file = new FileTagHandler(fileElement, m_elementFixture.getTestSuite());
 89  1
     m_elementFixture.saveFile(f);
 90  1
     XMLException ex = null;
 91  1
     try {
 92  1
       file.processElement();
 93   
     } catch (XMLException e) {
 94  1
       ex = e;
 95   
     }
 96  1
     assertNotNull("Exception should have been thrown", ex);
 97   
   }
 98   
 
 99   
   /**
 100   
    * Test with the Tag lookup.
 101   
    */
 102  1
   public void testLookup() {
 103  1
     IXMLTestSuite suite = m_elementFixture.getTestSuite();
 104  1
     Element fileElement = m_elementFixture.newElement("file", new String[] {
 105   
         "name", "abc"
 106   
     });
 107  1
     Object o = XMLTagResourceBundle.getTagHandler(fileElement, suite, "file");
 108  1
     assertNotNull(o);
 109   
   }
 110   
 
 111   
 }
 112