| 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.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 */ | |
| 21 | 3 | private String nl = System.getProperty("line.separator"); |
| 22 | ||
| 23 | /** Logger */ | |
| 24 | 6 | 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) { | |
| 33 | 3 | super(testName); |
| 34 | 3 | } |
| 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) { | |
| 43 | 0 | junit.textui.TestRunner.run(suite()); |
| 44 | 0 | } |
| 45 | ||
| 46 | /** | |
| 47 | * Return a new test suite | |
| 48 | * | |
| 49 | * @return a new test suite | |
| 50 | */ | |
| 51 | public static Test suite() { | |
| 52 | 3 | TestSuite suite = new TestSuite(ExecHostFieldTest.class); |
| 53 | ||
| 54 | 3 | return suite; |
| 55 | } | |
| 56 | ||
| 57 | /** | |
| 58 | * Test that the User field properly renders XML | |
| 59 | */ | |
| 60 | public void testExecHostFieldRenderer() { | |
| 61 | 3 | String inputLine = "node127m/0+node126m/2"; |
| 62 | ||
| 63 | 3 | 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 { | |
| 86 | 3 | ExecHostField needNodesField = |
| 87 | new ExecHostField(FieldName.EXEC_HOST, inputLine); | |
| 88 | ||
| 89 | 3 | String output = needNodesField.toXML(); |
| 90 | ||
| 91 | 3 | if (logger.isLoggable(Level.INFO)) { |
| 92 | 3 | StringBuffer outputBuffer = new StringBuffer(); |
| 93 | 3 | outputBuffer.append(nl); |
| 94 | 3 | outputBuffer.append("CALCULATED"); |
| 95 | 3 | outputBuffer.append(nl); |
| 96 | 3 | outputBuffer.append(output); |
| 97 | 3 | outputBuffer.append(nl); |
| 98 | 3 | outputBuffer.append("EXPECTED"); |
| 99 | 3 | outputBuffer.append(nl); |
| 100 | 3 | outputBuffer.append(expectedOutput); |
| 101 | 3 | outputBuffer.append(nl); |
| 102 | //Use system.out because logger buffers, and mixes with junit | |
| 103 | // out on error | |
| 104 | 3 | System.out.println(outputBuffer.toString()); |
| 105 | } | |
| 106 | 3 | assertTrue(output.equals(expectedOutput)); |
| 107 | 0 | } catch (Exception e) { |
| 108 | 0 | fail(); |
| 109 | 3 | } |
| 110 | ||
| 111 | 3 | } |
| 112 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |