| Line | Hits | Source |
|---|---|---|
| 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.StartRecord; | |
| 10 | import umich.cac.util.FileUtil; | |
| 11 | ||
| 12 | /** | |
| 13 | * Tests for StartRecord class. | |
| 14 | * | |
| 15 | * @author rmach@umich.edu | |
| 16 | * @version $Header: /cvsroot/pbsaccounting/pbsaccounting/src/umich/cac/pbs/test/StartRecordTest.java,v 1.4 2003/10/21 19:08:00 rodmach Exp $ | |
| 17 | */ | |
| 18 | public class StartRecordTest extends TestCase { | |
| 19 | ||
| 20 | ||
| 21 | /** Logger */ | |
| 22 | 6 | private Logger logger = Logger.getLogger(StartRecordTest.class.getName()); |
| 23 | ||
| 24 | /** The new line seperator for this system */ | |
| 25 | 3 | private String nl = System.getProperty("line.separator"); |
| 26 | ||
| 27 | ||
| 28 | /** | |
| 29 | * Constructor | |
| 30 | * | |
| 31 | * @param testName name of test suite | |
| 32 | */ | |
| 33 | public StartRecordTest(java.lang.String testName) { | |
| 34 | 3 | super(testName); |
| 35 | 3 | } |
| 36 | ||
| 37 | ||
| 38 | /** | |
| 39 | * Main - for running stand-alone test | |
| 40 | * | |
| 41 | * @param args command line arguments | |
| 42 | */ | |
| 43 | public static void main(java.lang.String[] args) { | |
| 44 | 0 | junit.textui.TestRunner.run(suite()); |
| 45 | 0 | } |
| 46 | ||
| 47 | ||
| 48 | /** | |
| 49 | * Return a new test suite | |
| 50 | * | |
| 51 | * @return a new test suite | |
| 52 | */ | |
| 53 | public static Test suite() { | |
| 54 | 3 | TestSuite suite = new TestSuite(StartRecordTest.class); |
| 55 | ||
| 56 | 3 | return suite; |
| 57 | } | |
| 58 | ||
| 59 | ||
| 60 | /** | |
| 61 | * Test that StartRecord returns the correct XML given a example D record | |
| 62 | */ | |
| 63 | public void testStartXML() { | |
| 64 | 3 | String expectedString = FileUtil.getFile("testcases/srecord.xml"); |
| 65 | 3 | String inputString = FileUtil.getFile("testcases/srecord.txt"); |
| 66 | ||
| 67 | //Must do split to test processRecord | |
| 68 | 3 | String[] fields = inputString.split(";"); |
| 69 | ||
| 70 | 3 | StartRecord startRecord = new StartRecord(); |
| 71 | 3 | String processedResults = startRecord.processRecord(fields); |
| 72 | ||
| 73 | ||
| 74 | 3 | if (logger.isLoggable(Level.INFO)) { |
| 75 | 3 | StringBuffer outputBuffer = new StringBuffer(); |
| 76 | 3 | outputBuffer.append(nl); |
| 77 | 3 | outputBuffer.append("CALCULATED"); |
| 78 | 3 | outputBuffer.append(nl); |
| 79 | 3 | outputBuffer.append(processedResults); |
| 80 | 3 | outputBuffer.append(nl); |
| 81 | 3 | outputBuffer.append("EXPECTED"); |
| 82 | 3 | outputBuffer.append(nl); |
| 83 | 3 | outputBuffer.append(expectedString); |
| 84 | 3 | outputBuffer.append(nl); |
| 85 | //Use system.out because logger buffers, and mixes with junit out on error | |
| 86 | 3 | System.out.println(outputBuffer.toString()); |
| 87 | } | |
| 88 | ||
| 89 | 3 | assertTrue(expectedString.equals(processedResults)); |
| 90 | ||
| 91 | 3 | } |
| 92 | ||
| 93 | ||
| 94 | } | |
| 95 |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |