| Line | Hits | Source |
|---|---|---|
| 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 */ | |
| 22 | 15 | private Logger logger = Logger.getLogger(FieldFactoryTest.class.getName()); |
| 23 | ||
| 24 | /** The field factory we are testing */ | |
| 25 | 12 | 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) { | |
| 34 | 12 | super(testName); |
| 35 | 12 | } |
| 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) { | |
| 44 | 0 | junit.textui.TestRunner.run(suite()); |
| 45 | 0 | } |
| 46 | ||
| 47 | /** | |
| 48 | * Return a new test suite | |
| 49 | * | |
| 50 | * @return a new test suite | |
| 51 | */ | |
| 52 | public static Test suite() { | |
| 53 | 3 | TestSuite suite = new TestSuite(FieldFactoryTest.class); |
| 54 | ||
| 55 | 3 | return suite; |
| 56 | } | |
| 57 | ||
| 58 | /** Test getting a field that doesn't exist, expect null to be returned */ | |
| 59 | public void testGetFieldThatDoesntExist() { | |
| 60 | 3 | Field nullField = fieldFactory.getField("BOGUSTEST", "BOGUSTEST"); |
| 61 | 3 | assertTrue(nullField == null); |
| 62 | 3 | } |
| 63 | ||
| 64 | /** | |
| 65 | * Test getting a custom field returns the correct custom Field object, | |
| 66 | * like "date" | |
| 67 | */ | |
| 68 | public void testGetCustomField() { | |
| 69 | 3 | Field aField = fieldFactory.getField("date", "12/17/2002 10:15:57"); |
| 70 | 3 | assertTrue(aField != null); |
| 71 | 3 | assertTrue(aField instanceof DateField); |
| 72 | 3 | } |
| 73 | ||
| 74 | /** Test getting a normal type field, like "ctime" */ | |
| 75 | public void testGetNormalField() { | |
| 76 | 3 | Field ctime = fieldFactory.getField("ctime", "1040138156"); |
| 77 | 3 | assertTrue(ctime != null); |
| 78 | 3 | assertTrue(ctime.getFieldName().equals(FieldName.CTIME)); |
| 79 | 3 | } |
| 80 | ||
| 81 | /** | |
| 82 | * Test getting the Field object when field name is known, like | |
| 83 | * FieldName.DATE | |
| 84 | */ | |
| 85 | public void testGetFieldWithFieldName() { | |
| 86 | 3 | Field dateField = |
| 87 | fieldFactory.getField(FieldName.DATE, "12/17/2002 10:15:57"); | |
| 88 | 3 | assertTrue(dateField != null); |
| 89 | 3 | assertTrue(dateField instanceof DateField); |
| 90 | 3 | } |
| 91 | ||
| 92 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |