Class PublisherTest
- java.lang.Object
-
- org.opentrafficsim.sim0mq.publisher.PublisherTest
-
- All Implemented Interfaces:
Serializable,DSOLModel<Time,Duration,SimTimeDoubleUnit,OTSSimulatorInterface>,DSOLModel.TimeDoubleUnit<OTSSimulatorInterface>,OTSModelInterface
public class PublisherTest extends Object implements OTSModelInterface
Unit tests. This requires half of OTS in the imports because it sets up a simulation and runs that for a couple of seconds.Copyright (c) 2020-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.$LastChangedDate: 2020-02-13 11:08:16 +0100 (Thu, 13 Feb 2020) $, @version $Revision: 6383 $, by $Author: pknoppers $,
- Author:
- Peter Knoppers
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface nl.tudelft.simulation.dsol.model.DSOLModel
DSOLModel.CalendarDouble<S extends SimulatorInterface.CalendarDouble>, DSOLModel.CalendarFloat<S extends SimulatorInterface.CalendarFloat>, DSOLModel.CalendarLong<S extends SimulatorInterface.CalendarLong>, DSOLModel.TimeDouble<S extends SimulatorInterface.TimeDouble>, DSOLModel.TimeDoubleUnit<S extends SimulatorInterface.TimeDoubleUnit>, DSOLModel.TimeFloat<S extends SimulatorInterface.TimeFloat>, DSOLModel.TimeFloatUnit<S extends SimulatorInterface.TimeFloatUnit>, DSOLModel.TimeLong<S extends SimulatorInterface.TimeLong>
-
-
Constructor Summary
Constructors Constructor Description PublisherTest()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckLastResult(String expectedText)Verify thatlastResultis not null, an Object array of length 1 and the one and only element is a String with the expected text.voidconstructModel()StringgetDescription()InputParameterMapgetInputParameterMap()OTSNetworkgetNetwork()List<OutputStatistic<?>>getOutputStatistics()StringgetShortName()OTSSimulatorInterfacegetSimulator()static StringreadStringFromURL(URL url)Open an URL, read it and store the contents in a string.voidtestPublisher()Test the Publisher class.
-
-
-
Method Detail
-
testPublisher
public void testPublisher() throws RemoteException, NetworkException, OTSGeometryException, SimRuntimeException, NamingException, Sim0MQException, SerializationExceptionTest the Publisher class.- Throws:
RemoteException- when that happens this test has failedNetworkException- if that happens uncaught; this test has failedOTSGeometryException- if that happens uncaught; this test has failedNamingException- on context errorSimRuntimeException- on DSOL errorSerializationException- - when encoding an error message failsSim0MQException- - when encoding an error message fails
-
checkLastResult
public void checkLastResult(String expectedText)
Verify thatlastResultis not null, an Object array of length 1 and the one and only element is a String with the expected text.- Parameters:
expectedText- String; the expected text
-
constructModel
public void constructModel() throws SimRuntimeException- Specified by:
constructModelin interfaceDSOLModel<Time,Duration,SimTimeDoubleUnit,OTSSimulatorInterface>- Throws:
SimRuntimeException
-
getSimulator
public final OTSSimulatorInterface getSimulator()
- Specified by:
getSimulatorin interfaceDSOLModel<Time,Duration,SimTimeDoubleUnit,OTSSimulatorInterface>
-
getInputParameterMap
public final InputParameterMap getInputParameterMap()
- Specified by:
getInputParameterMapin interfaceDSOLModel<Time,Duration,SimTimeDoubleUnit,OTSSimulatorInterface>
-
getOutputStatistics
public final List<OutputStatistic<?>> getOutputStatistics()
- Specified by:
getOutputStatisticsin interfaceDSOLModel<Time,Duration,SimTimeDoubleUnit,OTSSimulatorInterface>
-
getNetwork
public final OTSNetwork getNetwork()
- Specified by:
getNetworkin interfaceOTSModelInterface
-
getShortName
public final String getShortName()
- Specified by:
getShortNamein interfaceOTSModelInterface
-
getDescription
public final String getDescription()
- Specified by:
getDescriptionin interfaceOTSModelInterface
-
readStringFromURL
public static String readStringFromURL(URL url) throws IOException
Open an URL, read it and store the contents in a string. Adapted from https://stackoverflow.com/questions/4328711/read-url-to-string-in-few-lines-of-java-code- Parameters:
url- URL; the URL- Returns:
- String
- Throws:
IOException- when reading the file fails
-
-