Line | Hits | Source |
---|---|---|
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 */ | |
21 | 3 | private String nl = System.getProperty("line.separator"); |
22 | ||
23 | /** Logger */ | |
24 | 6 | 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) { | |
33 | 3 | super(testName); |
34 | 3 | } |
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) { | |
43 | 0 | junit.textui.TestRunner.run(suite()); |
44 | 0 | } |
45 | ||
46 | /** | |
47 | * Return a new test suite | |
48 | * | |
49 | * @return a new test suite | |
50 | */ | |
51 | public static Test suite() { | |
52 | 3 | TestSuite suite = new TestSuite(DateFieldTest.class); |
53 | ||
54 | 3 | return suite; |
55 | } | |
56 | ||
57 | /** | |
58 | * Test that the Date field properly renders XML | |
59 | */ | |
60 | public void testDateFieldRenderer() { | |
61 | 3 | String inputLine = "11/21/2002 10:22:10"; |
62 | ||
63 | 3 | 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 { | |
74 | 3 | DateField dateField = new DateField(FieldName.DATE, inputLine); |
75 | ||
76 | 3 | String output = dateField.toXML(); |
77 | ||
78 | 3 | if (logger.isLoggable(Level.INFO)) { |
79 | 3 | StringBuffer outputBuffer = new StringBuffer(); |
80 | 3 | outputBuffer.append(nl); |
81 | 3 | outputBuffer.append("CALCULATED"); |
82 | 3 | outputBuffer.append(nl); |
83 | 3 | outputBuffer.append(output); |
84 | 3 | outputBuffer.append(nl); |
85 | 3 | outputBuffer.append("EXPECTED"); |
86 | 3 | outputBuffer.append(nl); |
87 | 3 | outputBuffer.append(expectedOutput); |
88 | 3 | outputBuffer.append(nl); |
89 | //Use system.out because logger buffers, and mixes with junit | |
90 | // out on error | |
91 | 3 | System.out.println(outputBuffer.toString()); |
92 | } | |
93 | 3 | assertTrue(output.equals(expectedOutput)); |
94 | 0 | } catch (Exception e) { |
95 | 0 | fail(); |
96 | 3 | } |
97 | ||
98 | 3 | } |
99 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |