Clover coverage report - JFCUnit Test Coverage
Coverage timestamp: Mon Dec 20 2004 23:38:10 MST
file stats: LOC: 184   Methods: 8
NCLOC: 120   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
AssertTextFieldContainsTagHandlerT.java - 100% 100% 100%
coverage
 1   
 package junit.extensions.xml.elements;
 2   
 
 3   
 import javax.swing.JLabel;
 4   
 import javax.swing.JTextField;
 5   
 
 6   
 import org.w3c.dom.Element;
 7   
 import junit.extensions.xml.IXMLTestCase;
 8   
 import junit.extensions.xml.XMLException;
 9   
 import junit.framework.TestCase;
 10   
 import junit.extensions.xml.XMLTagResourceBundle;
 11   
 
 12   
 /**
 13   
  * <p>Title: Test AssertTextFieldContainsTagHandler.</p>
 14   
  * <p>Copyright: Copyright (c) 2003</p>
 15   
  * <p>Company: JFCUnit OpenSource Project</p>
 16   
  * @author Kevin Wilson
 17   
  * @version 1.0
 18   
  */
 19   
 public class AssertTextFieldContainsTagHandlerT
 20   
     extends TestCase {
 21   
   /**
 22   
    * Test tag handler.
 23   
    */
 24   
   private AssertTextFieldContainsTagHandler m_tagHandler = null;
 25   
   /**
 26   
    * Test fixture.
 27   
    */
 28   
   private ElementFixture m_fixture;
 29   
 
 30   
   /**
 31   
    * Set up the test.
 32   
    * @throws Exception may be thrown.
 33   
    */
 34  6
   protected void setUp() throws Exception {
 35  6
     super.setUp();
 36  6
     m_fixture = new ElementFixture(this);
 37  6
     m_fixture.setUp();
 38   
   }
 39   
 
 40   
   /**
 41   
    * Tear down the test.
 42   
    * @throws Exception may be thrown.
 43   
    */
 44  6
   protected void tearDown() throws Exception {
 45  6
     m_tagHandler = null;
 46  6
     m_fixture.tearDown();
 47   
 
 48  6
     m_fixture = null;
 49  6
     super.tearDown();
 50   
   }
 51   
 
 52   
   /**
 53   
    * Test success without useRE.
 54   
    * @throws XMLException may be thrown.
 55   
    */
 56  1
   public void testProcessElement() throws XMLException {
 57  1
     JTextField jtf = new JTextField();
 58  1
     jtf.setText("successful");
 59   
 
 60  1
     IXMLTestCase tc = m_fixture.getTestCase();
 61  1
     tc.addProperty("comp", jtf);
 62  1
     Element asrt = m_fixture.newElement("asserttextfieldcontains",
 63   
                                         new String[] {
 64   
                                         "id", "comp",
 65   
                                         "value", "successful",
 66   
                                         "useRE", "false"
 67   
     });
 68  1
     m_tagHandler = new AssertTextFieldContainsTagHandler(asrt, tc);
 69  1
     m_tagHandler.processElement();
 70   
   }
 71   
 
 72   
   /**
 73   
    * Test success with useRE.
 74   
    * @throws XMLException may be thrown.
 75   
    */
 76  1
   public void testProcessWithUseRE() throws XMLException {
 77  1
     JTextField jtf = new JTextField();
 78  1
     jtf.setText("successful");
 79   
 
 80  1
     IXMLTestCase tc = m_fixture.getTestCase();
 81  1
     tc.addProperty("comp", jtf);
 82  1
     Element asrt = m_fixture.newElement("asserttextfieldcontains",
 83   
                                         new String[] {
 84   
                                         "id", "comp",
 85   
                                         "value", "succ",
 86   
                                         "useRE", "true"
 87   
     });
 88  1
     m_tagHandler = new AssertTextFieldContainsTagHandler(asrt, tc);
 89  1
     m_tagHandler.processElement();
 90   
   }
 91   
 
 92   
   /**
 93   
    * Test fail without useRE.
 94   
    * @throws XMLException may be thrown.
 95   
    */
 96  1
   public void testProcessFail() throws XMLException {
 97  1
     JTextField jtf = new JTextField();
 98  1
     jtf.setText("successful");
 99   
 
 100  1
     IXMLTestCase tc = m_fixture.getTestCase();
 101  1
     tc.addProperty("comp", jtf);
 102  1
     Element asrt = m_fixture.newElement("asserttextfieldcontains",
 103   
                                         new String[] {
 104   
                                         "id", "comp",
 105   
                                         "value", "fail",
 106   
                                         "useRE", "false"
 107   
     });
 108  1
     m_tagHandler = new AssertTextFieldContainsTagHandler(asrt, tc);
 109  1
     Error er = null;
 110  1
     try {
 111  1
       m_tagHandler.processElement();
 112   
     } catch (Error e) {
 113  1
       er = e;
 114   
     }
 115  1
     assertNotNull("Exception expected", er);
 116   
   }
 117   
 
 118   
   /**
 119   
    * Test fail with Use RE.
 120   
    * @throws XMLException may be thrown.
 121   
    */
 122  1
   public void testProcessFailWithUseRE() throws XMLException {
 123  1
     JTextField jtf = new JTextField();
 124  1
     jtf.setText("successful");
 125   
 
 126  1
     IXMLTestCase tc = m_fixture.getTestCase();
 127  1
     tc.addProperty("comp", jtf);
 128  1
     Element asrt = m_fixture.newElement("asserttextfieldcontains",
 129   
                                         new String[] {
 130   
                                         "id", "comp",
 131   
                                         "value", "fail",
 132   
                                         "useRE", "true"
 133   
     });
 134  1
     m_tagHandler = new AssertTextFieldContainsTagHandler(asrt, tc);
 135  1
     Error er = null;
 136  1
     try {
 137  1
       m_tagHandler.processElement();
 138   
     } catch (Error e) {
 139  1
       er = e;
 140   
     }
 141  1
     assertNotNull("Exception expected", er);
 142   
   }
 143   
 
 144   
   /**
 145   
    * Test invalid component.
 146   
    * @throws XMLException may be thrown.
 147   
    */
 148  1
   public void testInvalidComp() throws XMLException {
 149  1
     JLabel jtf = new JLabel();
 150   
 
 151  1
     IXMLTestCase tc = m_fixture.getTestCase();
 152  1
     tc.addProperty("comp", jtf);
 153  1
     Element asrt = m_fixture.newElement("asserttextfieldcontains",
 154   
                                         new String[] {
 155   
                                         "id", "comp",
 156   
                                         "value", "succ",
 157   
                                         "useRE", "true"
 158   
     });
 159  1
     m_tagHandler = new AssertTextFieldContainsTagHandler(asrt, tc);
 160   
 
 161  1
     XMLException ex = null;
 162  1
     try {
 163  1
       m_tagHandler.processElement();
 164   
     } catch (XMLException e) {
 165  1
       ex = e;
 166   
     }
 167  1
     assertNotNull("Exception expected", ex);
 168   
   }
 169   
 
 170   
   /**
 171   
    * Test the Lookup.
 172   
    */
 173  1
   public void testLookup() {
 174  1
     Element element = m_fixture.newElement("asserttextfieldcontains", new String[] {
 175   
                                            "actualrefid", "data1",
 176   
                                            "expectedrefid", "data2"});
 177  1
     IXMLTestCase testCase = m_fixture.getTestCase();
 178  1
     Object o = XMLTagResourceBundle.getTagHandler(element, testCase,
 179   
                                                   "asserttextfieldcontains");
 180  1
     assertNotNull(o);
 181   
   }
 182   
 
 183   
 }
 184