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