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 @ 422

Revision 422, 2.2 KB checked in by jdalbey, 7 years ago (diff)

Remove ATMS functionality. Reworked and simplified the Highway model to use only VDS data from PeMS. Updated all unit tests.

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 static junit.framework.Assert.fail;
13import junit.framework.TestCase;
14import tmcsim.cadsimulator.CADServer;
15import tmcsim.common.ScriptException;
16import tmcsim.common.SimulationException;
17
18/**
19 *
20 * @author jdalbey
21 */
22public class ParamicsLogFileHandlerTest extends TestCase
23{
24
25    public ParamicsLogFileHandlerTest(String testName)
26    {
27        super(testName);
28    }
29
30    @Override
31    protected void setUp() throws Exception
32    {
33        super.setUp();
34    }
35    String propsfile = "config/paramics_communicator_logging.properties";
36
37    /**
38     * Test of getInstance method, of class ParamicsLog.
39     */
40    public void testGetInstance() throws ScriptException, SimulationException, RemoteException, FileNotFoundException, IOException
41    {
42        System.out.println("getInstance");
43        try
44        {
45            new CADServer("config/cad_simulator_console_config.properties");
46        } catch (Exception e)
47        {
48            fail("Couldn't launch CADSimulator");
49        }
50        //ParamicsLog plog = ParamicsLog.getInstance();
51        Properties paramicsLogProp = new Properties();
52        paramicsLogProp.load(new FileInputStream(propsfile));
53        String logFilename = paramicsLogProp.getProperty("LogFile");
54        // This test requires a CADSimulator running.
55        Logger logger = Logger.getLogger("tmcsim.parmicsLog");
56        ParamicsLogFileHandler fh = ParamicsLogFileHandler.getInstance();
57        logger.addHandler(fh);
58        // write a message to the log.
59        logger.info("Hello friendly log.");
60        // Read from the log file and see if the desired msg is there.
61        File logFile = new File(logFilename);
62        assertTrue("log file doesn't exist", logFile.exists());
63        String expected = "\n<!-- Time written to file: 00:00:00 -->\nHello friendly log.\n";
64        String actual = fh.getLog();
65        assertEquals("log written incorrectly", expected, actual);
66    }
67}
Note: See TracBrowser for help on using the repository browser.