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.FieldName; | |
10 | import umich.cac.data.NodeField; | |
11 | ||
12 | /** | |
13 | * | |
14 | * Tests for NodeField class. | |
15 | * | |
16 | * @author rmach@umich.edu | |
17 | * @version $Header: /cvsroot/pbsaccounting/pbsaccounting/src/umich/cac/data/test/NodeFieldTest.java,v 1.4 2003/10/21 19:08:00 rodmach Exp $ | |
18 | * | |
19 | */ | |
20 | ||
21 | public class NodeFieldTest extends TestCase { | |
22 | ||
23 | /** The new line seperator for this system */ | |
24 | ||
25 | 3 | private String nl = System.getProperty("line.separator"); |
26 | ||
27 | /** Logger */ | |
28 | ||
29 | 6 | private Logger logger = Logger.getLogger(NodeFieldTest.class.getName()); |
30 | ||
31 | /** | |
32 | * | |
33 | * Constructor | |
34 | * | |
35 | * @param testName | |
36 | * name of test suite | |
37 | * | |
38 | */ | |
39 | ||
40 | public NodeFieldTest(java.lang.String testName) { | |
41 | ||
42 | 3 | super(testName); |
43 | ||
44 | 3 | } |
45 | ||
46 | /** | |
47 | * | |
48 | * Main - for running stand-alone test | |
49 | * | |
50 | * @param args | |
51 | * command line arguments | |
52 | * | |
53 | */ | |
54 | ||
55 | public static void main(java.lang.String[] args) { | |
56 | ||
57 | 0 | junit.textui.TestRunner.run(suite()); |
58 | ||
59 | 0 | } |
60 | ||
61 | /** | |
62 | * | |
63 | * Return a new test suite | |
64 | * | |
65 | * @return a new test suite | |
66 | * | |
67 | */ | |
68 | ||
69 | public static Test suite() { | |
70 | ||
71 | 3 | TestSuite suite = new TestSuite(NodeFieldTest.class); |
72 | ||
73 | 3 | return suite; |
74 | ||
75 | } | |
76 | ||
77 | /** | |
78 | * | |
79 | * Test that the User field properly renders XML | |
80 | * | |
81 | */ | |
82 | ||
83 | public void testNodeFieldWithCpuRenderer() { | |
84 | ||
85 | 3 | String inputLine = "node122m/0"; |
86 | ||
87 | 3 | String expectedOutput = |
88 | "<node>" | |
89 | + nl | |
90 | + "<nodename>node122m</nodename>" | |
91 | + nl | |
92 | + "<cpu>0</cpu>" | |
93 | + nl | |
94 | + "</node>" | |
95 | + nl; | |
96 | ||
97 | try { | |
98 | ||
99 | 3 | NodeField userField = new NodeField(FieldName.NODE, inputLine); |
100 | ||
101 | 3 | String output = userField.toXML(); |
102 | ||
103 | 3 | if (logger.isLoggable(Level.INFO)) { |
104 | ||
105 | 3 | StringBuffer outputBuffer = new StringBuffer(); |
106 | 3 | outputBuffer.append(nl); |
107 | 3 | outputBuffer.append("CALCULATED"); |
108 | 3 | outputBuffer.append(nl); |
109 | 3 | outputBuffer.append(output); |
110 | 3 | outputBuffer.append(nl); |
111 | 3 | outputBuffer.append("EXPECTED"); |
112 | 3 | outputBuffer.append(nl); |
113 | 3 | outputBuffer.append(expectedOutput); |
114 | 3 | outputBuffer.append(nl); |
115 | ||
116 | //Use system.out because logger buffers, and mixes with junit | |
117 | // out on error | |
118 | 3 | System.out.println(outputBuffer.toString()); |
119 | ||
120 | } | |
121 | ||
122 | 3 | assertTrue(output.equals(expectedOutput)); |
123 | ||
124 | 0 | } catch (Exception e) { |
125 | ||
126 | 0 | fail(); |
127 | ||
128 | 3 | } |
129 | ||
130 | 3 | } |
131 | ||
132 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |