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-2024 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 <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
16   * @author <a href="https://github.com/peter-knoppers">Peter Knoppers</a>
17   * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
18   */
19  public class TrafficControlExceptionTest
20  {
21  
22      /**
23       * Test the TrafficControlException class.
24       */
25      @Test
26      public final void trafficControlExceptionTest()
27      {
28          TrafficControlException e = new TrafficControlException();
29          assertNotNull(e, "result should not be null");
30          String message = "test message";
31          e = new TrafficControlException(message);
32          assertEquals(message, e.getMessage(), "message should be " + message);
33          String causeMessage = "cause message";
34          Throwable cause = new Throwable(causeMessage);
35          e = new TrafficControlException(cause);
36          assertEquals(causeMessage, e.getCause().getMessage(), "cause message should be" + causeMessage);
37          e = new TrafficControlException(message, cause);
38          assertEquals(message, e.getMessage(), "message should be " + message);
39          assertEquals(causeMessage, e.getCause().getMessage(), "cause message should be" + causeMessage);
40      }
41  
42  }