Fixed binding-parent groupId. It was causing build failure
[netvirt.git] / plugin / src / test / java / org / opendaylight / ovsdb / plugin / impl / ConnectionServiceImplTest.java
1 /*
2  *  Copyright (C) 2015 Red Hat, Inc.
3  *
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
7  *
8  *  Authors : Sam Hague
9  */
10 package org.opendaylight.ovsdb.plugin.impl;
11
12 import static org.junit.Assert.assertNotNull;
13 import static org.junit.Assert.assertNull;
14 import static org.junit.Assert.assertSame;
15 import static org.junit.Assert.fail;
16
17 import org.junit.BeforeClass;
18 import org.junit.Test;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
20 import org.opendaylight.ovsdb.plugin.api.Connection;
21
22 public class ConnectionServiceImplTest {
23     private static final String OVS = "OVS";
24     private static final String IDENTIFIER = "192.168.120.31:45001";
25     private static final String OVS_IDENTIFIER = OVS + "|" + IDENTIFIER;
26     private static final String BAD_IDENTIFIER = "BAD" + "|" + IDENTIFIER;
27     private static ConnectionServiceImpl connectionService;
28
29     @BeforeClass
30     public static void setUp () {
31         connectionService = new ConnectionServiceImpl();
32         Connection connection = new Connection(IDENTIFIER, null);
33         connectionService.putOvsdbConnection(IDENTIFIER, connection);
34     }
35
36     @Test
37     public void testGetNode () {
38         Node node = connectionService.getNode(IDENTIFIER);
39         assertNotNull("Node " + IDENTIFIER + " is null", node);
40
41         node = connectionService.getNode(OVS_IDENTIFIER);
42         assertNotNull("Node " + OVS_IDENTIFIER + " is null", node);
43
44         node = connectionService.getNode(IDENTIFIER + "extra");
45         assertNull("Node " + BAD_IDENTIFIER + " is not null", node);
46     }
47
48     @Test
49     public void testGetConnection () {
50         Node node = connectionService.getNode(IDENTIFIER);
51         assertNotNull("Node " + IDENTIFIER + " is null", node);
52
53         Connection connection = connectionService.getConnection(node);
54         assertNotNull("Connection " + IDENTIFIER + " is null", connection);
55
56         try {
57             connection = connectionService.getConnection(null);
58             fail("Expected a NullPointerException to be thrown");
59         } catch (NullPointerException e) {
60             assertSame(NullPointerException.class, e.getClass());
61         }
62     }
63 }