Coverage details for umich.cac.data.test.NodeFieldTest

LineHitsSource
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  
253    private String nl = System.getProperty("line.separator");
26  
27     /** Logger */
28  
296    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  
423        super(testName);
43  
443    }
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  
570        junit.textui.TestRunner.run(suite());
58  
590    }
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  
713        TestSuite suite = new TestSuite(NodeFieldTest.class);
72  
733        return suite;
74  
75     }
76  
77     /**
78      *
79      * Test that the User field properly renders XML
80      *
81      */
82  
83     public void testNodeFieldWithCpuRenderer() {
84  
853        String inputLine = "node122m/0";
86  
873        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  
993            NodeField userField = new NodeField(FieldName.NODE, inputLine);
100  
1013            String output = userField.toXML();
102  
1033            if (logger.isLoggable(Level.INFO)) {
104  
1053                StringBuffer outputBuffer = new StringBuffer();
1063                outputBuffer.append(nl);
1073                outputBuffer.append("CALCULATED");
1083                outputBuffer.append(nl);
1093                outputBuffer.append(output);
1103                outputBuffer.append(nl);
1113                outputBuffer.append("EXPECTED");
1123                outputBuffer.append(nl);
1133                outputBuffer.append(expectedOutput);
1143                outputBuffer.append(nl);
115  
116                 //Use system.out because logger buffers, and mixes with junit
117                 // out on error
1183                System.out.println(outputBuffer.toString());
119  
120             }
121  
1223            assertTrue(output.equals(expectedOutput));
123  
1240        } catch (Exception e) {
125  
1260            fail();
127  
1283        }
129  
1303    }
131  
132 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.