Merge "Refactor TenantManage"
[nemo.git] / nemo-renderers / openflow-renderer / src / test / java / org / opendaylight / nemo / renderer / openflow / physicalnetwork / UtilsTest.java
1 package org.opendaylight.nemo.renderer.openflow.physicalnetwork;
2 import org.junit.Assert;
3 import org.junit.Test;
4 import org.opendaylight.nemo.renderer.openflow.physicalnetwork.Utils;
5
6 import static org.junit.Assert.*;
7 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.PhysicalNodeInstance;
8 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.PhysicalPortInstance;
9
10 import java.io.BufferedReader;
11 import java.io.FileInputStream;
12 import java.io.IOException;
13 import java.io.InputStreamReader;
14
15 import static org.mockito.Mockito.*;
16 /**
17  * Created by zhangmeng on 2015/11/30.
18  */
19 public class UtilsTest extends Utils {
20
21     @Test
22     public void testGetNodeType() throws Exception {
23         String strType = "switch";
24         Assert.assertTrue(Utils.getNodeType(strType) == PhysicalNodeInstance.NodeType.Switch);
25         strType = "router";
26         Assert.assertTrue(Utils.getNodeType(strType) == PhysicalNodeInstance.NodeType.Router);
27         strType = "firewall";
28         Assert.assertTrue(Utils.getNodeType(strType) == PhysicalNodeInstance.NodeType.Firewall);
29         strType = "loadbalancer";
30         Assert.assertTrue(Utils.getNodeType(strType) == PhysicalNodeInstance.NodeType.Loadbalancer);
31         strType = "test";
32         Assert.assertTrue(Utils.getNodeType(strType) == null);
33     }
34
35     @Test
36     public void testGetPortType() throws Exception {
37         String strType = "external";
38         Assert.assertTrue(Utils.getPortType(strType) == PhysicalPortInstance.PortType.External);
39         strType = "test";
40         Assert.assertTrue(Utils.getPortType(strType) == PhysicalPortInstance.PortType.Internal);
41     }
42
43     @Test
44     public void testReadFile() throws Exception {
45         String Path = new String(".");
46         Assert.assertNotNull(Utils.readFile(Path));
47         Path = "./test";
48         Assert.assertNotNull(Utils.readFile(Path));
49         Assert.assertTrue(Utils.readFile(Path) == "");
50     }
51 }