Merge "BUG-1493: activate recursion elision"
[controller.git] / opendaylight / config / config-api / src / test / java / org / opendaylight / controller / config / api / ModuleIdentifierTest.java
1 package org.opendaylight.controller.config.api;
2
3 import junit.framework.Assert;
4 import org.junit.Test;
5
6 import static org.junit.Assert.assertEquals;
7 import static org.junit.Assert.assertFalse;
8 import static org.junit.Assert.assertNotEquals;
9
10 public class ModuleIdentifierTest {
11     String fact = new String("factory");
12     String inst = new String("instance");
13
14     @Test(expected = IllegalArgumentException.class)
15     public void testConstructor() throws Exception {
16         ModuleIdentifier m = new ModuleIdentifier(null, "instance");
17     }
18
19     @Test(expected = IllegalArgumentException.class)
20     public void testConstructor2() throws Exception {
21         ModuleIdentifier m = new ModuleIdentifier("name", null);
22     }
23
24     @Test
25     public void testEquals() throws Exception {
26
27         ModuleIdentifier m1 = new ModuleIdentifier(fact, inst);
28         assertEquals(m1, new ModuleIdentifier(fact, inst));
29     }
30
31     @Test
32     public void testEquals2() throws Exception {
33         assertNotEquals(new ModuleIdentifier(fact, inst), null);
34     }
35
36     @Test
37     public void testEquals3() throws Exception {
38         assertNotEquals(new ModuleIdentifier(fact, inst), new ModuleIdentifier(fact, "i"));
39     }
40
41     @Test
42     public void testEquals4() throws Exception {
43         assertNotEquals(new ModuleIdentifier(fact, inst), new ModuleIdentifier("f", inst));
44     }
45
46     @Test
47     public void testEquals5() throws Exception {
48         ModuleIdentifier m1 = new ModuleIdentifier(fact, inst);
49         assertEquals(m1, m1);
50     }
51
52     @Test
53     public void testHashCode() throws Exception {
54         int hash = new ModuleIdentifier(fact, inst).hashCode();
55         assertEquals(hash, new ModuleIdentifier("factory", "instance").hashCode());
56     }
57
58     @Test
59     public void testToString() throws Exception {
60         assertEquals( new ModuleIdentifier("factory", "instance").toString(),
61                 new ModuleIdentifier("factory", "instance").toString());
62     }
63 }