2 * Copyright (c) 2014, 2017 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.config.api;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotEquals;
14 import org.junit.Test;
16 public class ModuleIdentifierTest {
17 String fact = new String("factory");
18 String inst = new String("instance");
20 @Test(expected = IllegalArgumentException.class)
21 public void testConstructor() throws Exception {
22 ModuleIdentifier moduleIdentifier = new ModuleIdentifier(null, "instance");
25 @Test(expected = IllegalArgumentException.class)
26 public void testConstructor2() throws Exception {
27 ModuleIdentifier moduleIdentifier = new ModuleIdentifier("name", null);
31 public void testEquals() throws Exception {
33 ModuleIdentifier m1 = new ModuleIdentifier(fact, inst);
34 assertEquals(m1, new ModuleIdentifier(fact, inst));
38 public void testEquals2() throws Exception {
39 assertNotEquals(new ModuleIdentifier(fact, inst), null);
43 public void testEquals3() throws Exception {
44 assertNotEquals(new ModuleIdentifier(fact, inst), new ModuleIdentifier(fact, "i"));
48 public void testEquals4() throws Exception {
49 assertNotEquals(new ModuleIdentifier(fact, inst), new ModuleIdentifier("f", inst));
53 public void testEquals5() throws Exception {
54 ModuleIdentifier m1 = new ModuleIdentifier(fact, inst);
59 public void testHashCode() throws Exception {
60 int hash = new ModuleIdentifier(fact, inst).hashCode();
61 assertEquals(hash, new ModuleIdentifier("factory", "instance").hashCode());
65 public void testToString() throws Exception {
66 assertEquals(new ModuleIdentifier("factory", "instance").toString(),
67 new ModuleIdentifier("factory", "instance").toString());