Class PublisherTest
java.lang.Object
org.opentrafficsim.sim0mq.publisher.PublisherTest
- All Implemented Interfaces:
nl.tudelft.simulation.dsol.model.DsolModel<Duration,,OtsSimulatorInterface> 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-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Peter Knoppers
-
Method Summary
Modifier and TypeMethodDescriptionvoidcheckLastResult(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.voidnl.tudelft.simulation.dsol.model.inputparameters.InputParameterMapnl.tudelft.simulation.dsol.experiment.StreamInformationstatic StringreadStringFromURL(URL url) Open an URL, read it and store the contents in a string.voidvoidsetInputParameterMap(nl.tudelft.simulation.dsol.model.inputparameters.InputParameterMap inputParameterMap) voidsetResetApplicationExecutable(Runnable resetApplicationExecutable) voidsetStreamInformation(nl.tudelft.simulation.dsol.experiment.StreamInformation streamInformation) voidTest the Publisher class.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface nl.tudelft.simulation.dsol.model.DsolModel
getDefaultStream, getInputParameterBoolean, getInputParameterDouble, getInputParameterDoubleScalar, getInputParameterFloat, getInputParameterFloatScalar, getInputParameterInteger, getInputParameterLocalDateTime, getInputParameterLong, getInputParameterString, getInputParameterUnit, getStream, getStreams, resetStreams
-
Method Details
-
testPublisher
@Test public void testPublisher() throws RemoteException, NetworkException, nl.tudelft.simulation.dsol.SimRuntimeException, NamingException, Sim0MQException, SerializationExceptionTest the Publisher class.- Throws:
RemoteException- when that happens this test has failedNetworkException- if that happens uncaught; this test has failedNamingException- on context errornl.tudelft.simulation.dsol.SimRuntimeException- on DSOL errorSerializationException- - when encoding an error message failsSim0MQException- - when encoding an error message fails
-
checkLastResult
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- the expected text
-
constructModel
public void constructModel() throws nl.tudelft.simulation.dsol.SimRuntimeException- Specified by:
constructModelin interfacenl.tudelft.simulation.dsol.model.DsolModel<Duration,OtsSimulatorInterface> - Throws:
nl.tudelft.simulation.dsol.SimRuntimeException
-
getSimulator
- Specified by:
getSimulatorin interfacenl.tudelft.simulation.dsol.model.DsolModel<Duration,OtsSimulatorInterface>
-
getInputParameterMap
public nl.tudelft.simulation.dsol.model.inputparameters.InputParameterMap getInputParameterMap()- Specified by:
getInputParameterMapin interfacenl.tudelft.simulation.dsol.model.DsolModel<Duration,OtsSimulatorInterface>
-
getOutputStatistics
public List<nl.tudelft.simulation.dsol.statistics.SimulationStatistic<Duration>> getOutputStatistics()- Specified by:
getOutputStatisticsin interfacenl.tudelft.simulation.dsol.model.DsolModel<Duration,OtsSimulatorInterface>
-
getNetwork
- Specified by:
getNetworkin interfaceOtsModelInterface
-
getShortName
- Specified by:
getShortNamein interfaceOtsModelInterface
-
getDescription
- Specified by:
getDescriptionin interfaceOtsModelInterface
-
setStreamInformation
public void setStreamInformation(nl.tudelft.simulation.dsol.experiment.StreamInformation streamInformation) - Specified by:
setStreamInformationin interfacenl.tudelft.simulation.dsol.model.DsolModel<Duration,OtsSimulatorInterface>
-
getStreamInformation
public nl.tudelft.simulation.dsol.experiment.StreamInformation getStreamInformation()- Specified by:
getStreamInformationin interfacenl.tudelft.simulation.dsol.model.DsolModel<Duration,OtsSimulatorInterface>
-
readStringFromURL
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- the URL- Returns:
- String
- Throws:
IOException- when reading the file fails
-
setResetApplicationExecutable
- Specified by:
setResetApplicationExecutablein interfacenl.tudelft.simulation.dsol.model.DsolModel<Duration,OtsSimulatorInterface>
-
getResetApplicationExecutable
- Specified by:
getResetApplicationExecutablein interfacenl.tudelft.simulation.dsol.model.DsolModel<Duration,OtsSimulatorInterface>
-
resetApplication
public void resetApplication()- Specified by:
resetApplicationin interfacenl.tudelft.simulation.dsol.model.DsolModel<Duration,OtsSimulatorInterface>
-
setInputParameterMap
public void setInputParameterMap(nl.tudelft.simulation.dsol.model.inputparameters.InputParameterMap inputParameterMap) - Specified by:
setInputParameterMapin interfacenl.tudelft.simulation.dsol.model.DsolModel<Duration,OtsSimulatorInterface>
-