View Javadoc
1   package org.djutils.logger;
2   
3   import static org.junit.Assert.assertEquals;
4   import static org.junit.Assert.assertNotEquals;
5   import static org.junit.Assert.assertNotNull;
6   import static org.junit.Assert.assertTrue;
7   
8   import org.junit.Test;
9   
10  /**
11   * LogCategoryTest.java.
12   * <p>
13   * Copyright (c) 2019-2022 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
14   * BSD-style license. See <a href="https://djutils.org/docs/current/djutils/licenses.html">DJUTILS License</a>.
15   * <p>
16   * @author <a href="https://www.tudelft.nl/averbraeck" target="_blank">Alexander Verbraeck</a>
17   */
18  public class LogCategoryTest
19  {
20      /**
21       * Test the LogCategory.
22       */
23      @Test
24      public void testLogCategory()
25      {
26          LogCategory lc1a = new LogCategory("LC1");
27          assertNotNull(lc1a);
28          LogCategory lc1b = new LogCategory("LC1");
29          assertEquals(lc1a, lc1b);
30          assertEquals(lc1a, lc1a);
31          LogCategory lcnull = new LogCategory(null);
32          assertNotNull(lcnull);
33          assertNotEquals(lcnull, lc1b);
34          assertNotEquals(lc1a, lcnull);
35          assertEquals(lcnull, lcnull);
36          // random factor in hashCode for null or "" object
37          assertNotEquals(new LogCategory(""), new LogCategory(""));
38          assertNotEquals(lcnull, new LogCategory(null));
39          assertNotEquals(lcnull, new LogCategory(""));
40          assertNotEquals(lc1a, new Object());
41          assertNotEquals(lc1a, null);
42          assertTrue(lc1a.toString().contains("LC1"));
43      }
44  
45  }