View Javadoc
1   package trafficcontrol;
2   
3   import static org.junit.jupiter.api.Assertions.assertEquals;
4   import static org.junit.jupiter.api.Assertions.assertNotNull;
5   
6   import org.junit.jupiter.api.Test;
7   import org.opentrafficsim.trafficcontrol.TrafficControlException;
8   
9   /**
10   * Test the TrafficControlException class.
11   * <p>
12   * Copyright (c) 2013-2026 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
13   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
14   * </p>
15   * @author Alexander Verbraeck
16   * @author Peter Knoppers
17   * @author Wouter Schakel
18   */
19  public final class TrafficControlExceptionTest
20  {
21  
22      /** */
23      private TrafficControlExceptionTest()
24      {
25          // do not instantiate test class
26      }
27  
28      /**
29       * Test the TrafficControlException class.
30       */
31      @Test
32      public void trafficControlExceptionTest()
33      {
34          TrafficControlException e = new TrafficControlException();
35          assertNotNull(e, "result should not be null");
36          String message = "test message";
37          e = new TrafficControlException(message);
38          assertEquals(message, e.getMessage(), "message should be " + message);
39          String causeMessage = "cause message";
40          Throwable cause = new Throwable(causeMessage);
41          e = new TrafficControlException(cause);
42          assertEquals(causeMessage, e.getCause().getMessage(), "cause message should be" + causeMessage);
43          e = new TrafficControlException(message, cause);
44          assertEquals(message, e.getMessage(), "message should be " + message);
45          assertEquals(causeMessage, e.getCause().getMessage(), "cause message should be" + causeMessage);
46      }
47  
48  }