Class 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
    • Field Detail

      • lastResult

        Object[] lastResult
        Storage for the last result submitted to the ReturnWrapper.
    • Constructor Detail

      • PublisherTest

        public PublisherTest()
    • Method Detail

      • checkLastResult

        public void checkLastResult​(String expectedText)
        Verify that lastResult 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
      • getSimulator

        public final org.opentrafficsim.core.dsol.OTSSimulatorInterface getSimulator()
        Specified by:
        getSimulator in interface DSOLModel<Duration,​org.opentrafficsim.core.dsol.OTSSimulatorInterface>
      • getNetwork

        public final org.opentrafficsim.core.network.OTSNetwork getNetwork()
        Specified by:
        getNetwork in interface org.opentrafficsim.core.dsol.OTSModelInterface
      • getShortName

        public final String getShortName()
        Specified by:
        getShortName in interface org.opentrafficsim.core.dsol.OTSModelInterface
      • getDescription

        public final String getDescription()
        Specified by:
        getDescription in interface org.opentrafficsim.core.dsol.OTSModelInterface
      • 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