Clover coverage report - JFCUnit Test Coverage
Coverage timestamp: Mon Dec 20 2004 23:38:10 MST
file stats: LOC: 139   Methods: 9
NCLOC: 78   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
JLabelFinderT.java - 100% 100% 100%
coverage
 1   
 package junit.extensions.jfcunit.finder;
 2   
 
 3   
 import junit.extensions.jfcunit.AbstractTestCase;
 4   
 
 5   
 import javax.swing.JFrame;
 6   
 import javax.swing.JLabel;
 7   
 
 8   
 /**
 9   
  * A TestCase to test the methods in the JLabelFinder class.
 10   
  *
 11   
  * @author <a href="mailto:vraravam@thoughtworks.com">Vijay Aravamudhan : ThoughtWorks Inc.</a>
 12   
  */
 13   
 public class JLabelFinderT extends AbstractTestCase {
 14   
     /**
 15   
      * Constructor.
 16   
      *
 17   
      * @param name Name of the test case.
 18   
      */
 19  8
     public JLabelFinderT(final String name) {
 20  8
         super(name);
 21   
     }
 22   
 
 23   
     /**
 24   
      * Tests the 'test' method for: invalid component.
 25   
      *
 26   
      * @exception  Exception   An instance of java.lang.Exception can be thrown
 27   
      */
 28  1
     public void testInvalidComponent() throws Exception {
 29  1
         JLabelFinder finder = new JLabelFinder("Dum");
 30  1
         JLabel label = new JLabel("Dummy");
 31  1
         JFrame frame = createJFrame(getName());
 32  1
         setWindow(frame);
 33  1
         frame.getContentPane().add(label);
 34  1
         packAndShow(frame);
 35  1
         assertFalse("Finder is not working", finder.testComponent(frame));
 36   
     }
 37   
 
 38   
     /**
 39   
      * Tests the 'test' method for: null label.
 40   
      *
 41   
      * @exception  Exception   An instance of java.lang.Exception can be thrown
 42   
      */
 43  1
     public void testNullLabel() throws Exception {
 44  1
         JLabelFinder finder = new JLabelFinder(null);
 45  1
         JLabel label = new JLabel();
 46  1
         JFrame frame = createJFrame(getName());
 47  1
         setWindow(frame);
 48  1
         frame.getContentPane().add(label);
 49  1
         packAndShow(frame);
 50  1
         assertFalse("Finder is not working", finder.testComponent(label));
 51   
     }
 52   
 
 53   
     /**
 54   
      * Tests the 'test' method for: empty label.
 55   
      *
 56   
      * @exception  Exception   An instance of java.lang.Exception can be thrown
 57   
      */
 58  1
     public void testEmptyLabel() throws Exception {
 59  1
         JLabelFinder finder = new JLabelFinder("");
 60  1
         JLabel label = new JLabel("Dummy");
 61  1
         JFrame frame = createJFrame(getName());
 62  1
         setWindow(frame);
 63  1
         frame.getContentPane().add(label);
 64  1
         packAndShow(frame);
 65  1
         assertTrue("Finder is not working", finder.testComponent(label));
 66   
     }
 67   
 
 68   
     /**
 69   
      * Tests the 'test' method for: invalid label.
 70   
      *
 71   
      * @exception  Exception   An instance of java.lang.Exception can be thrown
 72   
      */
 73  1
     public void testInvalidLabel() throws Exception {
 74  1
         JLabelFinder finder = new JLabelFinder("Dummy");
 75  1
         JLabel label = new JLabel("");
 76  1
         JFrame frame = createJFrame(getName());
 77  1
         setWindow(frame);
 78  1
         frame.getContentPane().add(label);
 79  1
         packAndShow(frame);
 80  1
         assertFalse("Finder is not working", finder.testComponent(label));
 81   
     }
 82   
 
 83   
     /**
 84   
      * Tests the 'test' method for: valid label.
 85   
      *
 86   
      * @exception  Exception   An instance of java.lang.Exception can be thrown
 87   
      */
 88  1
     public void testValidLabel1CaseSensitive() throws Exception {
 89  1
         JLabelFinder finder = new JLabelFinder("Dum");
 90  1
         JLabel label = new JLabel("Dummy");
 91  1
         JFrame frame = createJFrame(getName());
 92  1
         setWindow(frame);
 93  1
         frame.getContentPane().add(label);
 94  1
         packAndShow(frame);
 95  1
         assertTrue("Finder is not working", finder.testComponent(label));
 96   
     }
 97   
 
 98   
     /**
 99   
      * Tests the 'test' method for: valid label.
 100   
      *
 101   
      * @exception  Exception   An instance of java.lang.Exception can be thrown
 102   
      */
 103  1
     public void testValidLabel1CaseInsensitive() throws Exception {
 104  1
         JLabelFinder finder = new JLabelFinder("dum", true);
 105  1
         JLabel label = new JLabel("Dummy");
 106  1
         JFrame frame = createJFrame(getName());
 107  1
         setWindow(frame);
 108  1
         frame.getContentPane().add(label);
 109  1
         packAndShow(frame);
 110  1
         assertTrue("Finder is not working", finder.testComponent(label));
 111   
     }
 112   
 
 113   
     /**
 114   
      * Tests the 'test' method for: valid label.
 115   
      *
 116   
      * @exception  Exception   An instance of java.lang.Exception can be thrown
 117   
      */
 118  1
     public void testValidLabel2() throws Exception {
 119  1
         JLabelFinder finder = new JLabelFinder("");
 120  1
         JLabel label = new JLabel("Dummy");
 121  1
         JFrame frame = createJFrame(getName());
 122  1
         setWindow(frame);
 123  1
         frame.getContentPane().add(label);
 124  1
         packAndShow(frame);
 125  1
         assertTrue("Finder is not working", finder.testComponent(label));
 126   
     }
 127   
 
 128   
     /**
 129   
      * test get/setText().
 130   
      */
 131  1
     public void testText() {
 132  1
         JLabelFinder finder = new JLabelFinder(null);
 133  1
         assertEquals(null, finder.getText());
 134   
 
 135  1
         finder.setText("ABC");
 136  1
         assertEquals("ABC", finder.getText());
 137   
     }
 138   
 }
 139