Added test files for nemo-tool
[nemo.git] / nemo-tools / sandbox / src / test / java / org / opendaylight / nemo / tool / sandbox / models / SwitchTest.java
1 /*\r
2  * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 package org.opendaylight.nemo.tool.sandbox.models;\r
9 \r
10 \r
11 import junit.framework.TestCase;\r
12 import org.junit.Assert;\r
13 import org.junit.Before;\r
14 import org.junit.Test;\r
15 import static org.mockito.Mockito.*;\r
16 import static org.junit.Assert.*;\r
17 \r
18 import org.opendaylight.nemo.tool.sandbox.utils.Config;\r
19 import org.opendaylight.nemo.tool.sandbox.utils.HexString;\r
20 import org.slf4j.Logger;\r
21 import org.slf4j.LoggerFactory;\r
22 \r
23 import java.util.ArrayList;\r
24 import java.util.Collections;\r
25 import java.util.List;\r
26 \r
27 import java.lang.reflect.Method;\r
28 import java.lang.reflect.Field;\r
29 \r
30 /**\r
31  * Created by Thomas Liu on 2016/1/14.\r
32  */\r
33 public class SwitchTest extends TestCase {\r
34 \r
35     private String name;\r
36     private long dataPathId;\r
37     private Switch switchTest;\r
38     private Class class1;\r
39     private Method method;\r
40 \r
41 \r
42     @Before\r
43     public void setUp() throws Exception {\r
44         name = new String("name1");\r
45         dataPathId = 1L;\r
46         switchTest = new Switch(name,dataPathId);\r
47         class1 = Switch.class;\r
48         org.opendaylight.nemo.tool.sandbox.models.Connector connector = new org.opendaylight.nemo.tool.sandbox.models.Connector("connectorname",1);\r
49         switchTest.addConnectors(connector);\r
50     }\r
51 \r
52     @Test\r
53     public void testGetDataPathId() throws Exception {\r
54         Assert.assertNotNull(switchTest.getDataPathId());\r
55     }\r
56 \r
57     @Test\r
58     public void testGenerateCommands() throws Exception {\r
59         method = class1.getDeclaredMethod("generateCommands",new Class[]{});\r
60         method.setAccessible(true);\r
61         Assert.assertNotNull(method.invoke(switchTest));\r
62 \r
63     }\r
64 \r
65     @Test\r
66     public void testToString() throws Exception {\r
67         Assert.assertNotNull(switchTest.toString());\r
68 \r
69     }\r
70 }