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

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.ExecHostField;
10 import umich.cac.data.FieldName;
11  
12 /**
13  * Tests for ExecHostField class.
14  *
15  * @author rmach@umich.edu
16  * @version $Header: /cvsroot/pbsaccounting/pbsaccounting/src/umich/cac/data/test/ExecHostFieldTest.java,v 1.3 2003/10/21 19:08:00 rodmach Exp $
17  */
18 public class ExecHostFieldTest extends TestCase {
19  
20     /** The new line seperator for this system */
213    private String nl = System.getProperty("line.separator");
22  
23     /** Logger */
246    private Logger logger = Logger.getLogger(ExecHostFieldTest.class.getName());
25  
26     /**
27      * Constructor
28      *
29      * @param testName
30      * name of test suite
31      */
32     public ExecHostFieldTest(java.lang.String testName) {
333        super(testName);
343    }
35  
36     /**
37      * Main - for running stand-alone test
38      *
39      * @param args
40      * command line arguments
41      */
42     public static void main(java.lang.String[] args) {
430        junit.textui.TestRunner.run(suite());
440    }
45  
46     /**
47      * Return a new test suite
48      *
49      * @return a new test suite
50      */
51     public static Test suite() {
523        TestSuite suite = new TestSuite(ExecHostFieldTest.class);
53  
543        return suite;
55     }
56  
57     /**
58      * Test that the User field properly renders XML
59      */
60     public void testExecHostFieldRenderer() {
613        String inputLine = "node127m/0+node126m/2";
62  
633        String expectedOutput =
64             "<exec_host>"
65                 + nl
66                 + "<node>"
67                 + nl
68                 + "<nodename>node127m</nodename>"
69                 + nl
70                 + "<cpu>0</cpu>"
71                 + nl
72                 + "</node>"
73                 + nl
74                 + "<node>"
75                 + nl
76                 + "<nodename>node126m</nodename>"
77                 + nl
78                 + "<cpu>2</cpu>"
79                 + nl
80                 + "</node>"
81                 + nl
82                 + "</exec_host>"
83                 + nl;
84  
85         try {
863            ExecHostField needNodesField =
87                 new ExecHostField(FieldName.EXEC_HOST, inputLine);
88  
893            String output = needNodesField.toXML();
90  
913            if (logger.isLoggable(Level.INFO)) {
923                StringBuffer outputBuffer = new StringBuffer();
933                outputBuffer.append(nl);
943                outputBuffer.append("CALCULATED");
953                outputBuffer.append(nl);
963                outputBuffer.append(output);
973                outputBuffer.append(nl);
983                outputBuffer.append("EXPECTED");
993                outputBuffer.append(nl);
1003                outputBuffer.append(expectedOutput);
1013                outputBuffer.append(nl);
102                 //Use system.out because logger buffers, and mixes with junit
103                 // out on error
1043                System.out.println(outputBuffer.toString());
105             }
1063            assertTrue(output.equals(expectedOutput));
1070        } catch (Exception e) {
1080            fail();
1093        }
110  
1113    }
112 }

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.