1 package org.opendaylight.nemo.renderer.openflow.physicalnetwork;
2 import org.junit.Assert;
4 import org.opendaylight.nemo.renderer.openflow.physicalnetwork.Utils;
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;
10 import java.io.BufferedReader;
11 import java.io.FileInputStream;
12 import java.io.IOException;
13 import java.io.InputStreamReader;
15 import static org.mockito.Mockito.*;
17 * Created by zhangmeng on 2015/11/30.
19 public class UtilsTest extends Utils {
22 public void testGetNodeType() throws Exception {
23 String strType = "switch";
24 Assert.assertTrue(Utils.getNodeType(strType) == PhysicalNodeInstance.NodeType.Switch);
26 Assert.assertTrue(Utils.getNodeType(strType) == PhysicalNodeInstance.NodeType.Router);
28 Assert.assertTrue(Utils.getNodeType(strType) == PhysicalNodeInstance.NodeType.Firewall);
29 strType = "loadbalancer";
30 Assert.assertTrue(Utils.getNodeType(strType) == PhysicalNodeInstance.NodeType.Loadbalancer);
32 Assert.assertTrue(Utils.getNodeType(strType) == null);
36 public void testGetPortType() throws Exception {
37 String strType = "external";
38 Assert.assertTrue(Utils.getPortType(strType) == PhysicalPortInstance.PortType.External);
40 Assert.assertTrue(Utils.getPortType(strType) == PhysicalPortInstance.PortType.Internal);
44 public void testReadFile() throws Exception {
45 String Path = new String(".");
46 Assert.assertNotNull(Utils.readFile(Path));
48 Assert.assertNotNull(Utils.readFile(Path));
49 Assert.assertTrue(Utils.readFile(Path) == "");