Coverage details for umich.cac.pbs.test.ExecutionRecordTest

LineHitsSource
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  
236    private Logger logger =
243        Logger.getLogger(ExecutionRecordTest.class.getName());
25  
26     /** The new line seperator for this system */
276    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) {
396        super(testName);
406    }
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) {
520        junit.textui.TestRunner.run(suite());
530    }
54  
55     /**
56      *
57      * Return a new test suite
58      *
59      * @return a new test suite
60      *
61      */
62  
63     public static Test suite() {
643        TestSuite suite = new TestSuite(ExecutionRecordTest.class);
653        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  
773        String expectedString = FileUtil.getFile("testcases/erecord.xml");
783        String inputString = FileUtil.getFile("testcases/erecord.txt");
79         //Must do split to test processRecord
803        String[] fields = inputString.split(";");
813        ExecutionRecord executionRecord = new ExecutionRecord();
823        String processedResults = executionRecord.processRecord(fields);
83  
843        if (logger.isLoggable(Level.INFO)) {
85  
863            StringBuffer outputBuffer = new StringBuffer();
873            outputBuffer.append(nl);
883            outputBuffer.append("CALCULATED");
893            outputBuffer.append(nl);
903            outputBuffer.append(processedResults);
913            outputBuffer.append(nl);
923            outputBuffer.append("EXPECTED");
933            outputBuffer.append(nl);
943            outputBuffer.append(expectedString);
953            outputBuffer.append(nl);
96  
97             //Use system.out because logger buffers, and mixes with junit out
98             // on error
993            System.out.println(outputBuffer.toString());
100  
101         }
1023        assertTrue(expectedString.equals(processedResults));
103  
1043    }
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  
1153        String expectedString = FileUtil.getFile("testcases/erecordppn.xml");
1163        String inputString = FileUtil.getFile("testcases/erecordppn.txt");
117         //Must do split to test processRecord
1183        String[] fields = inputString.split(";");
1193        ExecutionRecord executionRecord = new ExecutionRecord();
1203        String processedResults = executionRecord.processRecord(fields);
121  
1223        if (logger.isLoggable(Level.INFO)) {
1233            StringBuffer outputBuffer = new StringBuffer();
1243            outputBuffer.append(nl);
1253            outputBuffer.append("PPN CALCULATED");
1263            outputBuffer.append(nl);
1273            outputBuffer.append(processedResults);
1283            outputBuffer.append(nl);
1293            outputBuffer.append("PPN EXPECTED");
1303            outputBuffer.append(nl);
1313            outputBuffer.append(expectedString);
1323            outputBuffer.append(nl);
133  
134             //Use system.out because logger buffers, and mixes with junit out
135             // on error
136  
1373            System.out.println(outputBuffer.toString());
138  
139         }
140  
1413        assertTrue(expectedString.equals(processedResults));
142  
1433    }
144  
145 }

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.