Line | Hits | Source |
---|---|---|
1 | package umich.cac.pbs.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.pbs.ExecutionRecord; | |
10 | import umich.cac.util.FileUtil; | |
11 | ||
12 | /** | |
13 | * Tests for ExecutionRecord class. | |
14 | * | |
15 | * @author rmach@umich.edu | |
16 | * @version $Header: /cvsroot/pbsaccounting/pbsaccounting/src/umich/cac/pbs/test/ExecutionRecordTest.java,v 1.4 2003/10/21 19:08:00 rodmach Exp $ | |
17 | */ | |
18 | ||
19 | public class ExecutionRecordTest extends TestCase { | |
20 | ||
21 | /** Logger */ | |
22 | ||
23 | 6 | private Logger logger = |
24 | 3 | Logger.getLogger(ExecutionRecordTest.class.getName()); |
25 | ||
26 | /** The new line seperator for this system */ | |
27 | 6 | private String nl = System.getProperty("line.separator"); |
28 | ||
29 | /** | |
30 | * | |
31 | * Constructor | |
32 | * | |
33 | * @param testName | |
34 | * name of test suite | |
35 | * | |
36 | */ | |
37 | ||
38 | public ExecutionRecordTest(java.lang.String testName) { | |
39 | 6 | super(testName); |
40 | 6 | } |
41 | ||
42 | /** | |
43 | * | |
44 | * Main - for running stand-alone test | |
45 | * | |
46 | * @param args | |
47 | * command line arguments | |
48 | * | |
49 | */ | |
50 | ||
51 | public static void main(java.lang.String[] args) { | |
52 | 0 | junit.textui.TestRunner.run(suite()); |
53 | 0 | } |
54 | ||
55 | /** | |
56 | * | |
57 | * Return a new test suite | |
58 | * | |
59 | * @return a new test suite | |
60 | * | |
61 | */ | |
62 | ||
63 | public static Test suite() { | |
64 | 3 | TestSuite suite = new TestSuite(ExecutionRecordTest.class); |
65 | 3 | return suite; |
66 | } | |
67 | ||
68 | /** | |
69 | * | |
70 | * Test that ExecutionRecord returns the correct XML given a example E | |
71 | * record | |
72 | * | |
73 | */ | |
74 | ||
75 | public void testExecutionXML() { | |
76 | ||
77 | 3 | String expectedString = FileUtil.getFile("testcases/erecord.xml"); |
78 | 3 | String inputString = FileUtil.getFile("testcases/erecord.txt"); |
79 | //Must do split to test processRecord | |
80 | 3 | String[] fields = inputString.split(";"); |
81 | 3 | ExecutionRecord executionRecord = new ExecutionRecord(); |
82 | 3 | String processedResults = executionRecord.processRecord(fields); |
83 | ||
84 | 3 | if (logger.isLoggable(Level.INFO)) { |
85 | ||
86 | 3 | StringBuffer outputBuffer = new StringBuffer(); |
87 | 3 | outputBuffer.append(nl); |
88 | 3 | outputBuffer.append("CALCULATED"); |
89 | 3 | outputBuffer.append(nl); |
90 | 3 | outputBuffer.append(processedResults); |
91 | 3 | outputBuffer.append(nl); |
92 | 3 | outputBuffer.append("EXPECTED"); |
93 | 3 | outputBuffer.append(nl); |
94 | 3 | outputBuffer.append(expectedString); |
95 | 3 | outputBuffer.append(nl); |
96 | ||
97 | //Use system.out because logger buffers, and mixes with junit out | |
98 | // on error | |
99 | 3 | System.out.println(outputBuffer.toString()); |
100 | ||
101 | } | |
102 | 3 | assertTrue(expectedString.equals(processedResults)); |
103 | ||
104 | 3 | } |
105 | ||
106 | /** | |
107 | * | |
108 | * Test that ExecutionRecord with Processors Per Node in OpenPBS Style | |
109 | * returns the correct XML given a example E record | |
110 | * | |
111 | */ | |
112 | ||
113 | public void testPPNAndOpenPbsExecutionXML() { | |
114 | ||
115 | 3 | String expectedString = FileUtil.getFile("testcases/erecordppn.xml"); |
116 | 3 | String inputString = FileUtil.getFile("testcases/erecordppn.txt"); |
117 | //Must do split to test processRecord | |
118 | 3 | String[] fields = inputString.split(";"); |
119 | 3 | ExecutionRecord executionRecord = new ExecutionRecord(); |
120 | 3 | String processedResults = executionRecord.processRecord(fields); |
121 | ||
122 | 3 | if (logger.isLoggable(Level.INFO)) { |
123 | 3 | StringBuffer outputBuffer = new StringBuffer(); |
124 | 3 | outputBuffer.append(nl); |
125 | 3 | outputBuffer.append("PPN CALCULATED"); |
126 | 3 | outputBuffer.append(nl); |
127 | 3 | outputBuffer.append(processedResults); |
128 | 3 | outputBuffer.append(nl); |
129 | 3 | outputBuffer.append("PPN EXPECTED"); |
130 | 3 | outputBuffer.append(nl); |
131 | 3 | outputBuffer.append(expectedString); |
132 | 3 | outputBuffer.append(nl); |
133 | ||
134 | //Use system.out because logger buffers, and mixes with junit out | |
135 | // on error | |
136 | ||
137 | 3 | System.out.println(outputBuffer.toString()); |
138 | ||
139 | } | |
140 | ||
141 | 3 | assertTrue(expectedString.equals(processedResults)); |
142 | ||
143 | 3 | } |
144 | ||
145 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |