Coverage details for umich.cac.pbs.test.FieldFactoryTest

LineHitsSource
1 package umich.cac.pbs.test;
2  
3 import java.util.logging.Logger;
4  
5 import junit.framework.Test;
6 import junit.framework.TestCase;
7 import junit.framework.TestSuite;
8 import umich.cac.data.DateField;
9 import umich.cac.data.Field;
10 import umich.cac.data.FieldName;
11 import umich.cac.pbs.FieldFactory;
12  
13 /**
14  * Tests for FieldFactory class.
15  *
16  * @author rmach@umich.edu
17  * @version $Header: /cvsroot/pbsaccounting/pbsaccounting/src/umich/cac/pbs/test/FieldFactoryTest.java,v 1.3 2003/10/21 19:08:00 rodmach Exp $
18  */
19 public class FieldFactoryTest extends TestCase {
20  
21     /** Logger */
2215    private Logger logger = Logger.getLogger(FieldFactoryTest.class.getName());
23  
24     /** The field factory we are testing */
2512    FieldFactory fieldFactory = FieldFactory.getInstance();
26  
27     /**
28      * Constructor
29      *
30      * @param testName
31      * name of test suite
32      */
33     public FieldFactoryTest(java.lang.String testName) {
3412        super(testName);
3512    }
36  
37     /**
38      * Main - for running stand-alone test
39      *
40      * @param args
41      * command line arguments
42      */
43     public static void main(java.lang.String[] args) {
440        junit.textui.TestRunner.run(suite());
450    }
46  
47     /**
48      * Return a new test suite
49      *
50      * @return a new test suite
51      */
52     public static Test suite() {
533        TestSuite suite = new TestSuite(FieldFactoryTest.class);
54  
553        return suite;
56     }
57  
58     /** Test getting a field that doesn't exist, expect null to be returned */
59     public void testGetFieldThatDoesntExist() {
603        Field nullField = fieldFactory.getField("BOGUSTEST", "BOGUSTEST");
613        assertTrue(nullField == null);
623    }
63  
64     /**
65      * Test getting a custom field returns the correct custom Field object,
66      * like "date"
67      */
68     public void testGetCustomField() {
693        Field aField = fieldFactory.getField("date", "12/17/2002 10:15:57");
703        assertTrue(aField != null);
713        assertTrue(aField instanceof DateField);
723    }
73  
74     /** Test getting a normal type field, like "ctime" */
75     public void testGetNormalField() {
763        Field ctime = fieldFactory.getField("ctime", "1040138156");
773        assertTrue(ctime != null);
783        assertTrue(ctime.getFieldName().equals(FieldName.CTIME));
793    }
80  
81     /**
82      * Test getting the Field object when field name is known, like
83      * FieldName.DATE
84      */
85     public void testGetFieldWithFieldName() {
863        Field dateField =
87             fieldFactory.getField(FieldName.DATE, "12/17/2002 10:15:57");
883        assertTrue(dateField != null);
893        assertTrue(dateField instanceof DateField);
903    }
91  
92 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.