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

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.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 */
213    private String nl = System.getProperty("line.separator");
22  
23     /** Logger */
246    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) {
323        super(testName);
333    }
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) {
420        junit.textui.TestRunner.run(suite());
430    }
44  
45     /**
46      * Return a new test suite
47      *
48      * @return a new test suite
49      */
50     public static Test suite() {
513        TestSuite suite = new TestSuite(MemFieldTest.class);
52  
533        return suite;
54     }
55  
56     /**
57      * Test that the User field properly renders XML
58      */
59     public void testMemFieldRenderer() {
603        String inputLine = "120kb";
61  
623        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 {
733            MemField memField = new MemField(FieldName.VMEM, inputLine);
74  
753            String output = memField.toXML();
76  
773            if (logger.isLoggable(Level.INFO)) {
783                StringBuffer outputBuffer = new StringBuffer();
793                outputBuffer.append(nl);
803                outputBuffer.append("CALCULATED");
813                outputBuffer.append(nl);
823                outputBuffer.append(output);
833                outputBuffer.append(nl);
843                outputBuffer.append("EXPECTED");
853                outputBuffer.append(nl);
863                outputBuffer.append(expectedOutput);
873                outputBuffer.append(nl);
88                 //Use system.out because logger buffers, and mixes with junit
89                 // out on error
903                System.out.println(outputBuffer.toString());
91             }
923            assertTrue(output.equals(expectedOutput));
930        } catch (Exception e) {
940            fail();
953        }
96  
973    }
98 }

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.