Class PublisherTest
java.lang.Object
org.opentrafficsim.sim0mq.publisher.PublisherTest
- All Implemented Interfaces:
Serializable,DSOLModel<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-2023 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
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
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.voidfinal Stringfinal InputParameterMapfinal org.opentrafficsim.core.network.Networkfinal List<StatisticsInterface<Duration>>final Stringfinal org.opentrafficsim.core.dsol.OtsSimulatorInterfacestatic StringreadStringFromURL(URL url) Open an URL, read it and store the contents in a string.voidsetStreamInformation(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, 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
public void testPublisher() throws RemoteException, org.opentrafficsim.core.network.NetworkException, org.opentrafficsim.core.geometry.OtsGeometryException, SimRuntimeException, NamingException, Sim0MQException, 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 errorSimRuntimeException- 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- String; the expected text
-
constructModel
- Specified by:
constructModelin interfaceDSOLModel<Duration,org.opentrafficsim.core.dsol.OtsSimulatorInterface> - Throws:
SimRuntimeException
-
getSimulator
public final org.opentrafficsim.core.dsol.OtsSimulatorInterface getSimulator()- Specified by:
getSimulatorin interfaceDSOLModel<Duration,org.opentrafficsim.core.dsol.OtsSimulatorInterface>
-
getInputParameterMap
- Specified by:
getInputParameterMapin interfaceDSOLModel<Duration,org.opentrafficsim.core.dsol.OtsSimulatorInterface>
-
getOutputStatistics
- Specified by:
getOutputStatisticsin interfaceDSOLModel<Duration,org.opentrafficsim.core.dsol.OtsSimulatorInterface>
-
getNetwork
public final org.opentrafficsim.core.network.Network getNetwork()- Specified by:
getNetworkin interfaceorg.opentrafficsim.core.dsol.OtsModelInterface
-
getShortName
- Specified by:
getShortNamein interfaceorg.opentrafficsim.core.dsol.OtsModelInterface
-
getDescription
- Specified by:
getDescriptionin interfaceorg.opentrafficsim.core.dsol.OtsModelInterface
-
setStreamInformation
- Specified by:
setStreamInformationin interfaceDSOLModel<Duration,org.opentrafficsim.core.dsol.OtsSimulatorInterface>
-
getStreamInformation
- Specified by:
getStreamInformationin interfaceDSOLModel<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
-