Fix NPEs on switch disconnect in cluster mode
[controller.git] / opendaylight / containermanager / implementation / src / test / java / org / opendaylight / controller / containermanager / internal / ContainerImplTest.java
1 \r
2 /*\r
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
4  *\r
5  * This program and the accompanying materials are made available under the\r
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
7  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
8  */\r
9 \r
10 package org.opendaylight.controller.containermanager.internal;\r
11 \r
12 import static org.junit.Assert.*;\r
13 \r
14 import java.util.Hashtable;\r
15 \r
16 import org.apache.felix.dm.impl.ComponentImpl;\r
17 import org.junit.Test;\r
18 import org.opendaylight.controller.sal.core.Node;\r
19 import org.opendaylight.controller.sal.utils.NodeCreator;\r
20 \r
21 public class ContainerImplTest {\r
22 \r
23         @Test\r
24         public void test() {\r
25 \r
26                 ContainerImpl container1 = new ContainerImpl();\r
27 \r
28                 //Create Component for init\r
29                 ComponentImpl component1 = new ComponentImpl(null, null, null);\r
30                 component1.setInterface("serviceTestName", null);\r
31 \r
32                 //container1 does not have name yet\r
33                 container1.init(component1);\r
34                 assertNull(container1.getName());\r
35 \r
36                 //Sets container1 name to TestName\r
37                 Hashtable<String, String> properties = new Hashtable<String, String>();\r
38                 properties.put("dummyKey", "dummyValue");\r
39                 properties.put("containerName", "TestName");\r
40                 component1.setInterface("serviceTestName", properties);\r
41 \r
42                 container1.init(component1);\r
43                 assertEquals("TestName", container1.getName());\r
44 \r
45                 //getContainerFlows always returns null for now\r
46                 assertNull(container1.getContainerFlows());\r
47 \r
48                 //getTag always returns 0 for now\r
49                 Node n = NodeCreator.createOFNode(1L);\r
50                 assertEquals(0, container1.getTag(n));\r
51 \r
52                 //getNodeConnectors always returns null for now\r
53                 assertNull(container1.getNodeConnectors());\r
54 \r
55                 //getNodes always returns null for now\r
56                 assertNull(container1.getNodes());\r
57 \r
58         }\r
59 \r
60 }\r