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
public class PublisherTest extends Object implements 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-2022 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 Modifier and Type Class Description (package private) class
PublisherTest.TestModel
The Model.
-
Field Summary
Fields Modifier and Type Field Description (package private) Object[]
lastResult
Storage for the last result submitted to the ReturnWrapper.(package private) static String
TEST_NETWORK_XML
The test network.
-
Constructor Summary
Constructors Constructor Description PublisherTest()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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
constructModel()
String
getDescription()
InputParameterMap
getInputParameterMap()
org.opentrafficsim.core.network.OTSNetwork
getNetwork()
List<StatisticsInterface<Duration>>
getOutputStatistics()
String
getShortName()
org.opentrafficsim.core.dsol.OTSSimulatorInterface
getSimulator()
StreamInformation
getStreamInformation()
static String
readStringFromURL(URL url)
Open an URL, read it and store the contents in a string.void
setStreamInformation(StreamInformation streamInformation)
void
testPublisher()
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 Detail
-
lastResult
Object[] lastResult
Storage for the last result submitted to the ReturnWrapper.
-
TEST_NETWORK_XML
static final String TEST_NETWORK_XML
The test network.- See Also:
- Constant Field Values
-
-
Method Detail
-
testPublisher
public void testPublisher() throws RemoteException, org.opentrafficsim.core.network.NetworkException, org.opentrafficsim.core.geometry.OTSGeometryException, SimRuntimeException, NamingException, Sim0MQException, SerializationException
Test 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
public void 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.- Parameters:
expectedText
- String; the expected text
-
constructModel
public void constructModel() throws SimRuntimeException
- Specified by:
constructModel
in interfaceDSOLModel<Duration,org.opentrafficsim.core.dsol.OTSSimulatorInterface>
- Throws:
SimRuntimeException
-
getSimulator
public final org.opentrafficsim.core.dsol.OTSSimulatorInterface getSimulator()
- Specified by:
getSimulator
in interfaceDSOLModel<Duration,org.opentrafficsim.core.dsol.OTSSimulatorInterface>
-
getInputParameterMap
public final InputParameterMap getInputParameterMap()
- Specified by:
getInputParameterMap
in interfaceDSOLModel<Duration,org.opentrafficsim.core.dsol.OTSSimulatorInterface>
-
getOutputStatistics
public final List<StatisticsInterface<Duration>> getOutputStatistics()
- Specified by:
getOutputStatistics
in interfaceDSOLModel<Duration,org.opentrafficsim.core.dsol.OTSSimulatorInterface>
-
getNetwork
public final org.opentrafficsim.core.network.OTSNetwork getNetwork()
- Specified by:
getNetwork
in interfaceorg.opentrafficsim.core.dsol.OTSModelInterface
-
getShortName
public final String getShortName()
- Specified by:
getShortName
in interfaceorg.opentrafficsim.core.dsol.OTSModelInterface
-
getDescription
public final String getDescription()
- Specified by:
getDescription
in interfaceorg.opentrafficsim.core.dsol.OTSModelInterface
-
setStreamInformation
public void setStreamInformation(StreamInformation streamInformation)
- Specified by:
setStreamInformation
in interfaceDSOLModel<Duration,org.opentrafficsim.core.dsol.OTSSimulatorInterface>
-
getStreamInformation
public StreamInformation getStreamInformation()
- Specified by:
getStreamInformation
in interfaceDSOLModel<Duration,org.opentrafficsim.core.dsol.OTSSimulatorInterface>
-
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
-
-