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.MemField; | |
11 | ||
12 | /** | |
13 | * Tests for MemField class. | |
14 | * | |
15 | * @author rmach@umich.edu | |
16 | * @version $Header: /cvsroot/pbsaccounting/pbsaccounting/src/umich/cac/data/test/MemFieldTest.java,v 1.3 2003/10/21 19:08:00 rodmach Exp $ | |
17 | */ | |
18 | public class MemFieldTest 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(MemFieldTest.class.getName()); |
25 | ||
26 | /** | |
27 | * Constructor | |
28 | * | |
29 | * @param testName name of test suite | |
30 | */ | |
31 | public MemFieldTest(java.lang.String testName) { | |
32 | 3 | super(testName); |
33 | 3 | } |
34 | ||
35 | /** | |
36 | * Main - for running stand-alone test | |
37 | * | |
38 | * @param args | |
39 | * command line arguments | |
40 | */ | |
41 | public static void main(java.lang.String[] args) { | |
42 | 0 | junit.textui.TestRunner.run(suite()); |
43 | 0 | } |
44 | ||
45 | /** | |
46 | * Return a new test suite | |
47 | * | |
48 | * @return a new test suite | |
49 | */ | |
50 | public static Test suite() { | |
51 | 3 | TestSuite suite = new TestSuite(MemFieldTest.class); |
52 | ||
53 | 3 | return suite; |
54 | } | |
55 | ||
56 | /** | |
57 | * Test that the User field properly renders XML | |
58 | */ | |
59 | public void testMemFieldRenderer() { | |
60 | 3 | String inputLine = "120kb"; |
61 | ||
62 | 3 | String expectedOutput = |
63 | "<vmem>" | |
64 | + nl | |
65 | + "<memory>120</memory>" | |
66 | + nl | |
67 | + "<units>kb</units>" | |
68 | + nl | |
69 | + "</vmem>" | |
70 | + nl; | |
71 | ||
72 | try { | |
73 | 3 | MemField memField = new MemField(FieldName.VMEM, inputLine); |
74 | ||
75 | 3 | String output = memField.toXML(); |
76 | ||
77 | 3 | if (logger.isLoggable(Level.INFO)) { |
78 | 3 | StringBuffer outputBuffer = new StringBuffer(); |
79 | 3 | outputBuffer.append(nl); |
80 | 3 | outputBuffer.append("CALCULATED"); |
81 | 3 | outputBuffer.append(nl); |
82 | 3 | outputBuffer.append(output); |
83 | 3 | outputBuffer.append(nl); |
84 | 3 | outputBuffer.append("EXPECTED"); |
85 | 3 | outputBuffer.append(nl); |
86 | 3 | outputBuffer.append(expectedOutput); |
87 | 3 | outputBuffer.append(nl); |
88 | //Use system.out because logger buffers, and mixes with junit | |
89 | // out on error | |
90 | 3 | System.out.println(outputBuffer.toString()); |
91 | } | |
92 | 3 | assertTrue(output.equals(expectedOutput)); |
93 | 0 | } catch (Exception e) { |
94 | 0 | fail(); |
95 | 3 | } |
96 | ||
97 | 3 | } |
98 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |