View Javadoc
1   package org.djutils.draw;
2   
3   import static org.junit.Assert.assertEquals;
4   import static org.junit.Assert.assertTrue;
5   
6   import org.junit.Test;
7   
8   /**
9    * Test the constructors for ValueException.
10   * <p>
11   * Copyright (c) 2013-2022 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
12   * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>.
13   * <p>
14   * @version $Revision: 847 $, $LastChangedDate: 2020-01-17 15:57:08 +0100 (Fri, 17 Jan 2020) $, by $Author: pknoppers $, initial
15   *          version 27 sep. 2015 <br>
16   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
17   * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a>
18   */
19  public class DrawRuntimeExceptionTest
20  {
21      /**
22       * Test all constructors for DrawRuntimeException.
23       */
24      @Test
25      public final void testDrawRuntimeException()
26      {
27          String message = "MessageString";
28          Exception e = new DrawRuntimeException(message);
29          assertTrue("Exception should not be null", null != e);
30          assertEquals("message should be our message", message, e.getMessage());
31          assertEquals("cause should be null", null, e.getCause());
32          e = new DrawRuntimeException();
33          assertTrue("Exception should not be null", null != e);
34          assertEquals("cause should be null", null, e.getCause());
35          String causeString = "CauseString";
36          Throwable cause = new Throwable(causeString);
37          e = new DrawRuntimeException(cause);
38          assertTrue("Exception should not be null", null != e);
39          assertEquals("cause should not be our cause", cause, e.getCause());
40          assertEquals("cause description should be our cause string", causeString, e.getCause().getMessage());
41          e = new DrawRuntimeException(message, cause);
42          assertTrue("Exception should not be null", null != e);
43          assertEquals("message should be our message", message, e.getMessage());
44          assertEquals("cause should not be our cause", cause, e.getCause());
45          assertEquals("cause description should be our cause string", causeString, e.getCause().getMessage());
46      }
47  
48      /**
49       * Test all constructors for DrawRuntimeException.
50       */
51      @Test
52      public final void drawRuntimeExceptionTest()
53      {
54          String message = "MessageString";
55          Exception e = new DrawRuntimeException(message);
56          assertTrue("Exception should not be null", null != e);
57          assertEquals("message should be our message", message, e.getMessage());
58          assertEquals("cause should be null", null, e.getCause());
59          e = new DrawRuntimeException();
60          assertTrue("Exception should not be null", null != e);
61          assertEquals("cause should be null", null, e.getCause());
62          String causeString = "CauseString";
63          Throwable cause = new Throwable(causeString);
64          e = new DrawRuntimeException(cause);
65          assertTrue("Exception should not be null", null != e);
66          assertEquals("cause should not be our cause", cause, e.getCause());
67          assertEquals("cause description should be our cause string", causeString, e.getCause().getMessage());
68          e = new DrawRuntimeException(message, cause);
69          assertTrue("Exception should not be null", null != e);
70          assertEquals("message should be our message", message, e.getMessage());
71          assertEquals("cause should not be our cause", cause, e.getCause());
72          assertEquals("cause description should be our cause string", causeString, e.getCause().getMessage());
73      }
74  
75  }