Class PublisherTest
java.lang.Object
org.opentrafficsim.sim0mq.publisher.PublisherTest
- All Implemented Interfaces:
Serializable
,nl.tudelft.simulation.dsol.model.DsolModel<org.djunits.value.vdouble.scalar.Duration,
,org.opentrafficsim.core.dsol.OtsSimulatorInterface> org.opentrafficsim.core.dsol.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
- See Also:
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
checkLastResult
(String expectedText) Verify thatlastResult
is not null, an Object array of length 1 and the one and only element is a String with the expected text.void
final String
final nl.tudelft.simulation.dsol.model.inputparameters.InputParameterMap
final org.opentrafficsim.core.network.Network
final List<nl.tudelft.simulation.dsol.statistics.SimulationStatistic<org.djunits.value.vdouble.scalar.Duration>>
final String
final org.opentrafficsim.core.dsol.OtsSimulatorInterface
nl.tudelft.simulation.dsol.experiment.StreamInformation
static String
readStringFromURL
(URL url) Open an URL, read it and store the contents in a string.void
setStreamInformation
(nl.tudelft.simulation.dsol.experiment.StreamInformation streamInformation) void
Test the Publisher class.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface nl.tudelft.simulation.dsol.model.DsolModel
getDefaultStream, getStream, getStreams, resetStreams
-
Field Details
-
lastResult
Object[] lastResultStorage for the last result submitted to the ReturnWrapper. -
TEST_Network_XML
The test network.- See Also:
-
-
Constructor Details
-
PublisherTest
public PublisherTest()
-
-
Method Details
-
testPublisher
@Test public void testPublisher() throws RemoteException, org.opentrafficsim.core.network.NetworkException, org.opentrafficsim.core.geometry.OtsGeometryException, nl.tudelft.simulation.dsol.SimRuntimeException, NamingException, org.sim0mq.Sim0MQException, org.djutils.serialization.SerializationExceptionTest the Publisher class.- Throws:
RemoteException
- when that happens this test has failedorg.opentrafficsim.core.network.NetworkException
- if that happens uncaught; this test has failedorg.opentrafficsim.core.geometry.OtsGeometryException
- if that happens uncaught; this test has failedNamingException
- on context errornl.tudelft.simulation.dsol.SimRuntimeException
- on DSOL errororg.djutils.serialization.SerializationException
- - when encoding an error message failsorg.sim0mq.Sim0MQException
- - when encoding an error message fails
-
checkLastResult
Verify thatlastResult
is 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 nl.tudelft.simulation.dsol.SimRuntimeException- Specified by:
constructModel
in interfacenl.tudelft.simulation.dsol.model.DsolModel<org.djunits.value.vdouble.scalar.Duration,
org.opentrafficsim.core.dsol.OtsSimulatorInterface> - Throws:
nl.tudelft.simulation.dsol.SimRuntimeException
-
getSimulator
public final org.opentrafficsim.core.dsol.OtsSimulatorInterface getSimulator()- Specified by:
getSimulator
in interfacenl.tudelft.simulation.dsol.model.DsolModel<org.djunits.value.vdouble.scalar.Duration,
org.opentrafficsim.core.dsol.OtsSimulatorInterface>
-
getInputParameterMap
public final nl.tudelft.simulation.dsol.model.inputparameters.InputParameterMap getInputParameterMap()- Specified by:
getInputParameterMap
in interfacenl.tudelft.simulation.dsol.model.DsolModel<org.djunits.value.vdouble.scalar.Duration,
org.opentrafficsim.core.dsol.OtsSimulatorInterface>
-
getOutputStatistics
public final List<nl.tudelft.simulation.dsol.statistics.SimulationStatistic<org.djunits.value.vdouble.scalar.Duration>> getOutputStatistics()- Specified by:
getOutputStatistics
in interfacenl.tudelft.simulation.dsol.model.DsolModel<org.djunits.value.vdouble.scalar.Duration,
org.opentrafficsim.core.dsol.OtsSimulatorInterface>
-
getNetwork
public final org.opentrafficsim.core.network.Network getNetwork()- Specified by:
getNetwork
in interfaceorg.opentrafficsim.core.dsol.OtsModelInterface
-
getShortName
- Specified by:
getShortName
in interfaceorg.opentrafficsim.core.dsol.OtsModelInterface
-
getDescription
- Specified by:
getDescription
in interfaceorg.opentrafficsim.core.dsol.OtsModelInterface
-
setStreamInformation
public void setStreamInformation(nl.tudelft.simulation.dsol.experiment.StreamInformation streamInformation) - Specified by:
setStreamInformation
in interfacenl.tudelft.simulation.dsol.model.DsolModel<org.djunits.value.vdouble.scalar.Duration,
org.opentrafficsim.core.dsol.OtsSimulatorInterface>
-
getStreamInformation
public nl.tudelft.simulation.dsol.experiment.StreamInformation getStreamInformation()- Specified by:
getStreamInformation
in interfacenl.tudelft.simulation.dsol.model.DsolModel<org.djunits.value.vdouble.scalar.Duration,
org.opentrafficsim.core.dsol.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
- URL; the URL- Returns:
- String
- Throws:
IOException
- when reading the file fails
-