Merge "Bug 1029: Remove dead code: p2site"
[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 static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertNotEquals;
5 import org.junit.Test;
6
7 public class ModuleIdentifierTest {
8     String fact = new String("factory");
9     String inst = new String("instance");
10
11     @Test(expected = IllegalArgumentException.class)
12     public void testConstructor() throws Exception {
13         ModuleIdentifier m = new ModuleIdentifier(null, "instance");
14     }
15
16     @Test(expected = IllegalArgumentException.class)
17     public void testConstructor2() throws Exception {
18         ModuleIdentifier m = new ModuleIdentifier("name", null);
19     }
20
21     @Test
22     public void testEquals() throws Exception {
23
24         ModuleIdentifier m1 = new ModuleIdentifier(fact, inst);
25         assertEquals(m1, new ModuleIdentifier(fact, inst));
26     }
27
28     @Test
29     public void testEquals2() throws Exception {
30         assertNotEquals(new ModuleIdentifier(fact, inst), null);
31     }
32
33     @Test
34     public void testEquals3() throws Exception {
35         assertNotEquals(new ModuleIdentifier(fact, inst), new ModuleIdentifier(fact, "i"));
36     }
37
38     @Test
39     public void testEquals4() throws Exception {
40         assertNotEquals(new ModuleIdentifier(fact, inst), new ModuleIdentifier("f", inst));
41     }
42
43     @Test
44     public void testEquals5() throws Exception {
45         ModuleIdentifier m1 = new ModuleIdentifier(fact, inst);
46         assertEquals(m1, m1);
47     }
48
49     @Test
50     public void testHashCode() throws Exception {
51         int hash = new ModuleIdentifier(fact, inst).hashCode();
52         assertEquals(hash, new ModuleIdentifier("factory", "instance").hashCode());
53     }
54
55     @Test
56     public void testToString() throws Exception {
57         assertEquals( new ModuleIdentifier("factory", "instance").toString(),
58                 new ModuleIdentifier("factory", "instance").toString());
59     }
60 }