Warning: Can't use blame annotator:
svn blame failed on trunk/test/tmcsim/paramicslog/ParamicsLogFileHandlerTest.java: ("Can't find a temporary directory: Internal error", 20014)

source: tmcsimulator/trunk/test/tmcsim/paramicslog/ParamicsLogFileHandlerTest.java @ 47

Revision 47, 1.8 KB checked in by jdalbey, 10 years ago (diff)

Merge 305 modifications into trunk.

RevLine 
1package tmcsim.paramicslog;
2
3import java.io.File;
4import java.io.FileInputStream;
5import java.io.FileNotFoundException;
6import java.io.IOException;
7import java.rmi.RemoteException;
8import java.util.Properties;
9import java.util.logging.Logger;
10import static junit.framework.Assert.assertEquals;
11import static junit.framework.Assert.assertTrue;
12import junit.framework.TestCase;
13import tmcsim.common.ScriptException;
14import tmcsim.common.SimulationException;
15
16/**
17 *
18 * @author jdalbey
19 */
20public class ParamicsLogFileHandlerTest extends TestCase
21{
22
23    public ParamicsLogFileHandlerTest(String testName)
24    {
25        super(testName);
26    }
27
28    @Override
29    protected void setUp() throws Exception
30    {
31        super.setUp();
32    }
33    String propsfile = "config/paramics_communicator_logging.properties";
34
35    /**
36     * Test of getInstance method, of class ParamicsLog.
37     */
38    public void testGetInstance() throws ScriptException, SimulationException, RemoteException, FileNotFoundException, IOException
39    {
40        System.out.println("getInstance");
41        //ParamicsLog plog = ParamicsLog.getInstance();
42        Properties paramicsLogProp = new Properties();
43        paramicsLogProp.load(new FileInputStream(propsfile));
44        String logFilename = paramicsLogProp.getProperty("LogFile");
45        // This test assumes there is NO CADSimulator running.
46        Logger logger = Logger.getLogger("tmcsim.parmicsLog");
47        ParamicsLogFileHandler fh = ParamicsLogFileHandler.getInstance();
48        logger.addHandler(fh);
49        logger.info("Hello friendly log.");
50        File logFile = new File(logFilename);
51        assertTrue("log file doesn't exist", logFile.exists());
52        String expected = "\n<!-- Time written to file: ? -->\nHello friendly log.\n";
53        String actual = fh.getLog();
54        assertEquals("log written incorrectly", expected, actual);
55    }
56}
Note: See TracBrowser for help on using the repository browser.