Coverage details for umich.cac.data.test.DateFieldTest

LineHitsSource
1 package umich.cac.data.test;
2  
3 import java.util.logging.Level;
4 import java.util.logging.Logger;
5  
6 import junit.framework.Test;
7 import junit.framework.TestCase;
8 import junit.framework.TestSuite;
9 import umich.cac.data.DateField;
10 import umich.cac.data.FieldName;
11  
12 /**
13  * Tests for DateField class.
14  *
15  * @author rmach@umich.edu
16  * @version $Header: /cvsroot/pbsaccounting/pbsaccounting/src/umich/cac/data/test/DateFieldTest.java,v 1.3 2003/10/21 19:08:00 rodmach Exp $
17  */
18 public class DateFieldTest extends TestCase {
19  
20     /** The new line seperator for this system */
213    private String nl = System.getProperty("line.separator");
22  
23     /** Logger */
246    private Logger logger = Logger.getLogger(DateFieldTest.class.getName());
25  
26     /**
27      * Constructor
28      *
29      * @param testName
30      * name of test suite
31      */
32     public DateFieldTest(java.lang.String testName) {
333        super(testName);
343    }
35  
36     /**
37      * Main - for running stand-alone test
38      *
39      * @param args
40      * command line arguments
41      */
42     public static void main(java.lang.String[] args) {
430        junit.textui.TestRunner.run(suite());
440    }
45  
46     /**
47      * Return a new test suite
48      *
49      * @return a new test suite
50      */
51     public static Test suite() {
523        TestSuite suite = new TestSuite(DateFieldTest.class);
53  
543        return suite;
55     }
56  
57     /**
58      * Test that the Date field properly renders XML
59      */
60     public void testDateFieldRenderer() {
613        String inputLine = "11/21/2002 10:22:10";
62  
633        String expectedOutput =
64             "<date>"
65                 + nl
66                 + "<day>11/21/2002</day>"
67                 + nl
68                 + "<time>10:22:10</time>"
69                 + nl
70                 + "</date>"
71                 + nl;
72  
73         try {
743            DateField dateField = new DateField(FieldName.DATE, inputLine);
75  
763            String output = dateField.toXML();
77  
783            if (logger.isLoggable(Level.INFO)) {
793                StringBuffer outputBuffer = new StringBuffer();
803                outputBuffer.append(nl);
813                outputBuffer.append("CALCULATED");
823                outputBuffer.append(nl);
833                outputBuffer.append(output);
843                outputBuffer.append(nl);
853                outputBuffer.append("EXPECTED");
863                outputBuffer.append(nl);
873                outputBuffer.append(expectedOutput);
883                outputBuffer.append(nl);
89                 //Use system.out because logger buffers, and mixes with junit
90                 // out on error
913                System.out.println(outputBuffer.toString());
92             }
933            assertTrue(output.equals(expectedOutput));
940        } catch (Exception e) {
950            fail();
963        }
97  
983    }
99 }

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.