<cliche.version>1.0-SNAPSHOT</cliche.version>
<ssh.version>262</ssh.version>
<json.version>20090211</json.version>
+ <powermock.version>1.5.2</powermock.version>
</properties>
<dependencies>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-core</artifactId>
+ <version>${powermock.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <version>${powermock.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <version>${powermock.version}</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
--- /dev/null
+/*
+ * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.nemo.tool.sandbox;
+
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import asg.cliche.Command;
+import asg.cliche.Shell;
+import asg.cliche.ShellDependent;
+import static org.mockito.Mockito.*;
+/**
+ * Created by zhangmeng on 2016/1/14.
+ */
+public class CliTest extends TestCase {
+ private Cli cli;
+ @Before
+ public void setUp() throws Exception {
+ cli = new Cli();
+ }
+
+ @Test
+ public void testCliSetShell() throws Exception {
+ Shell shell = mock(Shell.class);
+ cli.cliSetShell(shell);
+ }
+
+ @Test
+ public void testInstall() throws Exception {
+ cli.install();
+ }
+
+ @Test
+ public void testUninstall() throws Exception {
+ cli.uninstall();
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.nemo.tool.sandbox;
+
+import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.awt.color.CMMException;
+
+import static org.junit.Assert.*;
+import ch.ethz.ssh2.Connection;
+import ch.ethz.ssh2.Session;
+import ch.ethz.ssh2.StreamGobbler;
+import org.junit.runner.RunWith;
+import org.opendaylight.nemo.tool.sandbox.utils.Config;
+import org.opendaylight.nemo.tool.sandbox.utils.FileUtils;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.api.support.membermodification.MemberMatcher;
+import org.powermock.api.support.membermodification.MemberModifier;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import static org.mockito.Mockito.*;
+/**
+ * Created by zhangmeng on 2016/1/14.
+ */
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(ch.ethz.ssh2.Connection.class)
+public class CmdExecutorTest extends TestCase {
+ private CmdExecutor cmdExecutor;
+ private Class<CmdExecutor> class1;
+ private Field field_sshConnection;
+ @Before
+ public void setUp() throws Exception {
+ class1 = CmdExecutor.class;
+ field_sshConnection = class1.getDeclaredField("sshConnection");
+ field_sshConnection.setAccessible(true);
+
+ cmdExecutor = new CmdExecutor();
+ }
+
+ @Test
+ public void testOpen() throws Exception {
+ String command = "cd ~";
+ Session session = mock(Session.class);
+ Connection sshConnection = mock(Connection.class);
+
+ Assert.assertTrue(CmdExecutor.open() == false);
+ PowerMockito.whenNew(Connection.class).withArguments(any(String.class)).thenReturn(sshConnection);
+ when(sshConnection.authenticateWithPassword(any(String.class), any(String.class))).thenReturn(true);
+ Assert.assertTrue(CmdExecutor.open() == false);
+// Assert.assertTrue(field_sshConnection.get(class1) == sshConnection);
+// verify(sshConnection).authenticateWithPassword(any(String.class), any(String.class));
+
+ field_sshConnection.set(class1, sshConnection);
+ when(sshConnection.openSession()).thenReturn(session);
+ doNothing().when(session).execCommand(command);
+ when(session.getStdout()).thenReturn(mock(InputStream.class));
+ Assert.assertTrue(CmdExecutor.sshExecute(command) != null);
+ verify(session).getStdout();
+ CmdExecutor.queryInterfaceMac("eth0");
+ CmdExecutor.queryInterfaceMac("1","eth0");
+
+ CmdExecutor.close();
+ }
+
+ @Test
+ public void testgetMacFromResult() throws Exception {
+ Method method = class1.getDeclaredMethod("getMacFromResult",new Class[]{
+ String.class
+ });
+ method.setAccessible(true);
+ Assert.assertTrue(method.invoke(class1,"HWaddr") != null);
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.nemo.tool.sandbox;
+
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import asg.cliche.Shell;
+import asg.cliche.ShellFactory;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import static org.mockito.Mockito.*;
+
+/**
+ * Created by zhangmeng on 2016/1/14.
+ */
+public class EasyCliTest extends TestCase {
+ private EasyCli easyCli;
+ @Before
+ public void setUp() throws Exception {
+ easyCli = new EasyCli("1","2","3");
+ }
+
+ @Test
+ public void testAdd() throws Exception {
+ easyCli.add("4");
+ }
+
+ @Test
+ public void testRun() throws Exception {
+ Field field = EasyCli.class.getDeclaredField("shell");
+ field.setAccessible(true);
+
+ Shell shell = mock(Shell.class);
+
+ field.set(easyCli,shell);
+ doNothing().when(shell).commandLoop();
+ easyCli.run();
+ verify(shell).commandLoop();
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.nemo.tool.sandbox;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import org.json.JSONObject;
+import org.junit.runner.RunWith;
+import org.opendaylight.nemo.tool.sandbox.models.*;
+import org.opendaylight.nemo.tool.sandbox.utils.PropertyLoader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.api.support.membermodification.MemberMatcher;
+import org.powermock.api.support.membermodification.MemberModifier;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.*;
+/**
+ * Created by zhangmeng on 2016/1/14.
+ */
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(CmdExecutor.class)
+public class SandBoxManagerTest extends TestCase {
+ private SandBoxManager sandBoxManager;
+ private Method method;
+ @Before
+ public void setUp() throws Exception {
+ sandBoxManager = SandBoxManager.getInstance();
+ }
+
+ @Test
+ public void testGetInstance() throws Exception {
+ sandBoxManager = SandBoxManager.getInstance();
+ }
+
+ @Test
+ public void testGets() throws Exception {
+ Field field = SandBoxManager.class.getDeclaredField("network");
+ field.setAccessible(true);
+
+ Network network = mock(Network.class);
+ JSONObject jsonObject = mock(JSONObject.class);
+
+ //no powermock and network=null
+ field.set(sandBoxManager, null);
+ org.junit.Assert.assertTrue(!sandBoxManager.createNetwork(null));
+ org.junit.Assert.assertTrue(!sandBoxManager.createNetwork());
+ org.junit.Assert.assertTrue(sandBoxManager.getHosts() == null);
+ org.junit.Assert.assertTrue(sandBoxManager.getExternals() == null);
+ org.junit.Assert.assertTrue(sandBoxManager.getSwitches() == null);
+ org.junit.Assert.assertTrue(sandBoxManager.getLinks() == null);
+ org.junit.Assert.assertTrue(sandBoxManager.destroyNetwork());
+
+ field.set(sandBoxManager, network);
+ PowerMockito.mockStatic(CmdExecutor.class);
+ PowerMockito.when(CmdExecutor.open()).thenReturn(true);
+ when(network.hostJsonNode()).thenReturn(jsonObject);
+ when(network.externalJsonNode()).thenReturn(jsonObject);
+ when(network.nodeJsonNode()).thenReturn(jsonObject);
+ when(network.innerLinkJsonNode()).thenReturn(jsonObject);
+ when(network.execute(any(String.class), any(String.class))).thenReturn("test");
+ org.junit.Assert.assertTrue(sandBoxManager.execute("1","1").equals("test"));
+ org.junit.Assert.assertTrue(sandBoxManager.getHosts() != null);
+ org.junit.Assert.assertTrue(sandBoxManager.getExternals() != null);
+ org.junit.Assert.assertTrue(sandBoxManager.getSwitches() != null);
+ org.junit.Assert.assertTrue(sandBoxManager.getLinks() != null);
+
+ org.junit.Assert.assertTrue(sandBoxManager.createNetwork(PropertyLoader.readLines("/Network", "Network file does not exist.")));
+ org.junit.Assert.assertTrue(sandBoxManager.createNetwork());
+ org.junit.Assert.assertTrue(sandBoxManager.destroyNetwork());
+ }
+ @Test
+ public void testGetNodeType() throws Exception {
+ method = SandBoxManager.class.getDeclaredMethod("getNodeType",new Class[]{String.class});
+ method.setAccessible(true);
+
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager, "Switch") == NodeType.SWITCH);
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager, "Router") == NodeType.ROUTER);
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager, "Cache") == NodeType.CACHE);
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager, "Firewall") == NodeType.FIREWALL);
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager, "Vm") == NodeType.VM);
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager,"1") == NodeType.UNKNOWN);
+
+ }
+
+ @Test
+ public void testHandleLink() throws Exception {
+ method = SandBoxManager.class.getDeclaredMethod("handleLink",new Class[]{String.class});
+ method.setAccessible(true);
+
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager, "12") == null);
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager,"1,2,3,4,5") != null);
+ }
+
+ @Test
+ public void testSaveConnector() throws Exception {
+ method = SandBoxManager.class.getDeclaredMethod("saveConnector",new Class[]{
+ Connector.class,
+ Map.class
+ });
+ method.setAccessible(true);
+
+ Connector connector = mock(Connector.class);
+ Map<String, List<Connector>> connectorMap = mock(Map.class);
+
+ when(connector.getNodeName()).thenReturn("test");
+ when(connectorMap.containsKey(any(String.class)))
+ .thenReturn(true)
+ .thenReturn(false);
+ when(connectorMap.get(any(String.class))).thenReturn(mock(List.class));
+ method.invoke(sandBoxManager, connector, connectorMap);
+ method.invoke(sandBoxManager, connector, connectorMap);
+ verify(connectorMap,times(2)).containsKey(any(String.class));
+ }
+
+ @Test
+ public void testParserHost() throws Exception {
+ method = SandBoxManager.class.getDeclaredMethod("parserHost",new Class[]{
+ String[].class,
+ Map.class,
+ Host.class
+ });
+ method.setAccessible(true);
+
+ String[] args = {"1","2","3","1:2"};
+ Map<String, List<Connector>> connectorMap = mock(Map.class);
+ Host host = mock(Host.class);
+ Connector connector = mock(Connector.class);
+ List<Connector> connectors = new ArrayList<Connector>();
+
+ connectors.add(connector);
+
+ when(host.getName()).thenReturn("test");
+ when(connectorMap.get(host.getName())).thenReturn(connectors);
+
+ method.invoke(sandBoxManager, args, connectorMap, host);
+ verify(host,times(2)).getName();
+ }
+
+ @Test
+ public void testHandleFirewall() throws Exception {
+ method = SandBoxManager.class.getDeclaredMethod("handleFirewall",new Class[]{
+ String.class,
+ Map.class
+ });
+ method.setAccessible(true);
+
+ String line = "test";
+ Map<String, List<Connector>> connectorMap = mock(Map.class);
+
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager,line,connectorMap) == null);
+ line = "1,2,3,1:2";
+ when(connectorMap.get(any(String.class))).thenReturn(null);
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager,line,connectorMap) != null);
+ }
+
+ @Test
+ public void testHandleCache() throws Exception {
+ method = SandBoxManager.class.getDeclaredMethod("handleCache",new Class[]{
+ String.class,
+ Map.class
+ });
+ method.setAccessible(true);
+
+ String line = "test";
+ Map<String, List<Connector>> connectorMap = mock(Map.class);
+
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager,line,connectorMap) == null);
+ line = "1,2,3,1:2";
+ when(connectorMap.get(any(String.class))).thenReturn(null);
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager,line,connectorMap) != null);
+
+ }
+
+ @Test
+ public void testHandleVirtualMachine() throws Exception {
+ method = SandBoxManager.class.getDeclaredMethod("handleVirtualMachine",new Class[]{
+ String.class,
+ Map.class
+ });
+ method.setAccessible(true);
+
+ String line = "test";
+ Map<String, List<Connector>> connectorMap = mock(Map.class);
+
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager,line,connectorMap) == null);
+ line = "1,2,3,1:2";
+ when(connectorMap.get(any(String.class))).thenReturn(null);
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager,line,connectorMap) != null);
+ }
+
+ @Test
+ public void testHandleSwitch() throws Exception {
+ method = SandBoxManager.class.getDeclaredMethod("handleSwitch",new Class[]{
+ String.class,
+ Map.class
+ });
+ method.setAccessible(true);
+
+ List<Connector> connectorList = new ArrayList<Connector>();
+ Connector connector = mock(Connector.class);
+ String line = "test";
+ Map<String, List<Connector>> connectorMap = mock(Map.class);
+
+ connectorList.add(connector);
+
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager, line, connectorMap) == null);
+ line = "Router,2,3";
+ when(connectorMap.get(any(String.class))).thenReturn(connectorList);
+ org.junit.Assert.assertTrue(method.invoke(sandBoxManager, line, connectorMap) != null);
+
+ }
+
+ @Test
+ public void testGenerateNetwork() throws Exception {
+ method = SandBoxManager.class.getDeclaredMethod("generateNetwork",new Class[]{List.class});
+ method.setAccessible(true);
+
+ List<String> list = new ArrayList<String>();
+ list.add("Switch");
+ method.invoke(sandBoxManager, list);
+ list.clear();
+ list.add("Vm");
+ method.invoke(sandBoxManager, list);
+ list.clear();
+ list.add("Cache");
+ method.invoke(sandBoxManager, list);
+ list.clear();
+ list.add("Firewall");
+ method.invoke(sandBoxManager, list);
+
+ }
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.nemo.tool.sandbox.models;\r
+\r
+import junit.framework.TestCase;\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import static org.mockito.Mockito.*;\r
+import static org.junit.Assert.*;\r
+\r
+import org.junit.runner.RunWith;\r
+import org.powermock.api.mockito.PowerMockito;\r
+import org.powermock.api.support.membermodification.MemberMatcher;\r
+import org.powermock.api.support.membermodification.MemberModifier;\r
+import org.powermock.core.classloader.annotations.PrepareForTest;\r
+import org.powermock.modules.junit4.PowerMockRunner;\r
+import org.opendaylight.nemo.tool.sandbox.CmdExecutor;\r
+\r
+import java.lang.reflect.Method;\r
+import java.lang.reflect.Field;\r
+\r
+/**\r
+ * Created by Thomas Liu on 2016/1/14.\r
+ */\r
+@RunWith(PowerMockRunner.class)\r
+@PrepareForTest({CmdExecutor.class})\r
+public class CacheTest extends TestCase {\r
+ String name,uuId;\r
+ Cache cacheTest;\r
+ private Method method;\r
+ private Class class1;\r
+ private Connector connector;\r
+\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ name = new String("name1");\r
+ uuId = new String("11111111-1111-1111-1111-111111111111");\r
+ cacheTest = new Cache(name,uuId);\r
+ class1 = Cache.class;\r
+ org.opendaylight.nemo.tool.sandbox.models.Connector connector = mock(org.opendaylight.nemo.tool.sandbox.models.Connector.class);\r
+ cacheTest.addConnectors(connector);\r
+ }\r
+\r
+ @Test\r
+ public void testGenerateCommands() throws Exception {\r
+ method = class1.getDeclaredMethod("generateCommands",new Class[]{});\r
+ method.setAccessible(true);\r
+ Assert.assertNotNull(method.invoke(cacheTest));\r
+ }\r
+\r
+ @Test\r
+ public void testUninstall() throws Exception {\r
+ PowerMockito.mockStatic(CmdExecutor.class);\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ cacheTest.uninstall();\r
+\r
+ }\r
+\r
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.nemo.tool.sandbox.models;\r
+\r
+import junit.framework.TestCase;\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.opendaylight.nemo.tool.sandbox.models.Connector;\r
+\r
+import static org.mockito.Mockito.*;\r
+import static org.junit.Assert.*;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+/**\r
+ * Created by Thomas Liu on 2016/1/14.\r
+ */\r
+public class ConnectorTest extends TestCase {\r
+ private int order;\r
+ private String nodeName;\r
+ private Connector connectorTest;\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ order = 10;\r
+ nodeName = "connector";\r
+ connectorTest = new Connector(nodeName,order);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testGetConnectorName() throws Exception {\r
+ Assert.assertNotNull(connectorTest.getConnectorName());\r
+ }\r
+\r
+ @Test\r
+ public void testGetOrder() throws Exception {\r
+ Assert.assertNotNull(connectorTest.getOrder());\r
+ }\r
+\r
+ @Test\r
+ public void testGetNodeName() throws Exception {\r
+ Assert.assertNotNull(connectorTest.getNodeName());\r
+ }\r
+\r
+ @Test\r
+ public void testEquals() throws Exception {\r
+ Assert.assertNotNull(connectorTest.equals(this));\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testHashCode() throws Exception {\r
+ Assert.assertNotNull(connectorTest.hashCode());\r
+ }\r
+\r
+ @Test\r
+ public void testToString() throws Exception {\r
+ Assert.assertNotNull(connectorTest.toString());\r
+ }\r
+\r
+ @Test\r
+ public void testCompareTo() throws Exception {\r
+ Assert.assertNotNull(connectorTest.compareTo(new Connector("connector2",5)));\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.nemo.tool.sandbox.models;\r
+\r
+import junit.framework.TestCase;\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import static org.mockito.Mockito.*;\r
+import static org.junit.Assert.*;\r
+\r
+import org.junit.runner.RunWith;\r
+import org.powermock.api.mockito.PowerMockito;\r
+import org.powermock.api.support.membermodification.MemberMatcher;\r
+import org.powermock.api.support.membermodification.MemberModifier;\r
+import org.powermock.core.classloader.annotations.PrepareForTest;\r
+import org.powermock.modules.junit4.PowerMockRunner;\r
+import org.opendaylight.nemo.tool.sandbox.CmdExecutor;\r
+import org.opendaylight.nemo.tool.sandbox.models.Firewall;\r
+\r
+import java.lang.reflect.Method;\r
+import java.lang.reflect.Field;\r
+\r
+/**\r
+ * Created by Thomas Liu on 2016/1/14.\r
+ */\r
+@RunWith(PowerMockRunner.class)\r
+@PrepareForTest({CmdExecutor.class})\r
+public class FirewallTest extends TestCase {\r
+\r
+ String name,uuId;\r
+ Firewall firewallTest;\r
+ private Method method;\r
+ private Class class1;\r
+ private Connector connector;\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ name = new String("name1");\r
+ uuId = new String("11111111-1111-1111-1111-111111111111");\r
+ firewallTest = new Firewall(name,uuId);\r
+ class1 = Firewall.class;\r
+ org.opendaylight.nemo.tool.sandbox.models.Connector connector = mock(org.opendaylight.nemo.tool.sandbox.models.Connector.class);\r
+ firewallTest.addConnectors(connector);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testGenerateCommands() throws Exception {\r
+ method = class1.getDeclaredMethod("generateCommands",new Class[]{});\r
+ method.setAccessible(true);\r
+ Assert.assertNotNull(method.invoke(firewallTest));\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testUninstall() throws Exception {\r
+ PowerMockito.mockStatic(CmdExecutor.class);\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ firewallTest.uninstall();\r
+\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.nemo.tool.sandbox.models;\r
+import junit.framework.TestCase;\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import static org.mockito.Mockito.*;\r
+import static org.junit.Assert.*;\r
+\r
+import org.opendaylight.nemo.tool.sandbox.CmdExecutor;\r
+import org.opendaylight.nemo.tool.sandbox.models.Connector;\r
+\r
+import org.junit.runner.RunWith;\r
+import org.powermock.api.mockito.PowerMockito;\r
+import org.powermock.api.support.membermodification.MemberMatcher;\r
+import org.powermock.api.support.membermodification.MemberModifier;\r
+import org.powermock.core.classloader.annotations.PrepareForTest;\r
+import org.powermock.modules.junit4.PowerMockRunner;\r
+\r
+/**\r
+ * Created by Thomas Liu on 2016/1/14.\r
+ */\r
+@RunWith(PowerMockRunner.class)\r
+@PrepareForTest({CmdExecutor.class})\r
+public class LinkTest extends TestCase {\r
+\r
+ private Connector srcInterface;\r
+ private Connector dstInterface;\r
+ private Link likeTest;\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ srcInterface = new Connector("src",1);\r
+ dstInterface = new Connector("dst",2);\r
+ likeTest = new Link(srcInterface,dstInterface);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testGetSrcConnector() throws Exception {\r
+ Assert.assertNotNull(likeTest.getSrcConnector());\r
+ }\r
+\r
+ @Test\r
+ public void testGetDstConnector() throws Exception {\r
+ Assert.assertNotNull(likeTest.getDstConnector());\r
+ }\r
+\r
+ @Test\r
+ public void testInstall() throws Exception {\r
+ PowerMockito.mockStatic(CmdExecutor.class);\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ likeTest.install();\r
+ }\r
+\r
+ @Test\r
+ public void testUninstall() throws Exception {\r
+ PowerMockito.mockStatic(CmdExecutor.class);\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ likeTest.uninstall();\r
+ }\r
+\r
+ @Test\r
+ public void testEquals() throws Exception {\r
+ Assert.assertNotNull(likeTest.equals(this));\r
+ }\r
+\r
+ @Test\r
+ public void testHashCode() throws Exception {\r
+ Assert.assertNotNull(likeTest.hashCode());\r
+ }\r
+\r
+ @Test\r
+ public void testToString() throws Exception {\r
+ Assert.assertNotNull(likeTest.toString());\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.nemo.tool.sandbox.models;\r
+\r
+import junit.framework.TestCase;\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import static org.mockito.Mockito.*;\r
+import static org.junit.Assert.*;\r
+import org.opendaylight.nemo.tool.sandbox.models.Cache;\r
+import org.opendaylight.nemo.tool.sandbox.models.Connector;\r
+import org.opendaylight.nemo.tool.sandbox.models.Network;\r
+\r
+import org.junit.runner.RunWith;\r
+import org.powermock.api.mockito.PowerMockito;\r
+import org.powermock.api.support.membermodification.MemberMatcher;\r
+import org.powermock.api.support.membermodification.MemberModifier;\r
+import org.powermock.core.classloader.annotations.PrepareForTest;\r
+import org.powermock.modules.junit4.PowerMockRunner;\r
+import org.opendaylight.nemo.tool.sandbox.CmdExecutor;\r
+\r
+import org.json.JSONArray;\r
+import org.json.JSONException;\r
+import org.json.JSONObject;\r
+import org.opendaylight.nemo.tool.sandbox.CmdExecutor;\r
+import org.opendaylight.nemo.tool.sandbox.utils.Config;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+\r
+\r
+/**\r
+ * Created by Thomas Liu on 2016/1/14.\r
+ */\r
+@RunWith(PowerMockRunner.class)\r
+@PrepareForTest({CmdExecutor.class})\r
+public class NetworkTest extends TestCase {\r
+ private Network networkTest;\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ networkTest = new Network();\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testAddHost() throws Exception {\r
+ networkTest.addHost(new Cache("src1","1"));\r
+ networkTest.addHost(new Cache("dst2","1"));\r
+ }\r
+\r
+ @Test\r
+ public void testAddSwitch() throws Exception {\r
+ networkTest.addSwitch(new Switch("dst1", 1L));\r
+ networkTest.addSwitch(new Switch("src2", 1L));\r
+ networkTest.addSwitch(new Switch("src3", 1L));\r
+ networkTest.addSwitch(new Switch("dst3", 1L));\r
+ }\r
+\r
+ @Test\r
+ public void testAddLink() throws Exception {\r
+ networkTest.addLink(new Link(new Connector("src1", 1), new Connector("dst1", 2)));\r
+ networkTest.addLink(new Link(new Connector("src2", 1), new Connector("dst2", 2)));\r
+ networkTest.addLink(new Link(new Connector("src3", 1), new Connector("dst3", 2)));\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testExecute() throws Exception {\r
+ PowerMockito.mockStatic(CmdExecutor.class);\r
+ PowerMockito.when(CmdExecutor.open()).thenReturn(true);\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ PowerMockito.doNothing().when(CmdExecutor.class);\r
+ CmdExecutor.close();\r
+ Assert.assertNotNull(networkTest.execute("cache", "command"));\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testInstall() throws Exception {\r
+ //test traversal\r
+ networkTest.install();\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testUninstall() throws Exception {\r
+ PowerMockito.mockStatic(CmdExecutor.class);\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+\r
+ networkTest.uninstall();\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testEchoConfig() throws Exception {\r
+ PowerMockito.mockStatic(CmdExecutor.class);\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+\r
+ networkTest.echoConfig();\r
+\r
+ //test hostJsonNode()\r
+\r
+\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testInnerLinkJsonNode() throws Exception {\r
+\r
+ Assert.assertNotNull(networkTest.innerLinkJsonNode());\r
+\r
+\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.nemo.tool.sandbox.models;\r
+\r
+import junit.framework.TestCase;\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import static org.mockito.Mockito.*;\r
+import static org.junit.Assert.*;\r
+\r
+/**\r
+ * Created by Thomas Liu on 2016/1/14.\r
+ */\r
+public class RouterTest extends TestCase {\r
+ private String name;\r
+ private long dataPathId;\r
+ private Router routerTest;\r
+ @Before\r
+ public void setUp() throws Exception {\r
+\r
+ }\r
+\r
+ @Test\r
+ public void test1() throws Exception {\r
+ name = new String("name1");\r
+ dataPathId = 1L;\r
+ routerTest = new Router(name,dataPathId);\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.nemo.tool.sandbox.models;\r
+\r
+\r
+import junit.framework.TestCase;\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import static org.mockito.Mockito.*;\r
+import static org.junit.Assert.*;\r
+\r
+import org.opendaylight.nemo.tool.sandbox.utils.Config;\r
+import org.opendaylight.nemo.tool.sandbox.utils.HexString;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collections;\r
+import java.util.List;\r
+\r
+import java.lang.reflect.Method;\r
+import java.lang.reflect.Field;\r
+\r
+/**\r
+ * Created by Thomas Liu on 2016/1/14.\r
+ */\r
+public class SwitchTest extends TestCase {\r
+\r
+ private String name;\r
+ private long dataPathId;\r
+ private Switch switchTest;\r
+ private Class class1;\r
+ private Method method;\r
+\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ name = new String("name1");\r
+ dataPathId = 1L;\r
+ switchTest = new Switch(name,dataPathId);\r
+ class1 = Switch.class;\r
+ org.opendaylight.nemo.tool.sandbox.models.Connector connector = new org.opendaylight.nemo.tool.sandbox.models.Connector("connectorname",1);\r
+ switchTest.addConnectors(connector);\r
+ }\r
+\r
+ @Test\r
+ public void testGetDataPathId() throws Exception {\r
+ Assert.assertNotNull(switchTest.getDataPathId());\r
+ }\r
+\r
+ @Test\r
+ public void testGenerateCommands() throws Exception {\r
+ method = class1.getDeclaredMethod("generateCommands",new Class[]{});\r
+ method.setAccessible(true);\r
+ Assert.assertNotNull(method.invoke(switchTest));\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testToString() throws Exception {\r
+ Assert.assertNotNull(switchTest.toString());\r
+\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.nemo.tool.sandbox.models;\r
+\r
+import junit.framework.TestCase;\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import static org.mockito.Mockito.*;\r
+import static org.junit.Assert.*;\r
+\r
+import org.opendaylight.nemo.tool.sandbox.CmdExecutor;\r
+import org.opendaylight.nemo.tool.sandbox.models.VirtualMachine;\r
+\r
+import java.lang.reflect.Method;\r
+import java.lang.reflect.Field;\r
+\r
+import org.junit.runner.RunWith;\r
+import org.powermock.api.mockito.PowerMockito;\r
+import org.powermock.api.support.membermodification.MemberMatcher;\r
+import org.powermock.api.support.membermodification.MemberModifier;\r
+import org.powermock.core.classloader.annotations.PrepareForTest;\r
+import org.powermock.modules.junit4.PowerMockRunner;\r
+import org.opendaylight.nemo.tool.sandbox.CmdExecutor;\r
+\r
+/**\r
+ * Created by Thomas Liu on 2016/1/14.\r
+ */\r
+@RunWith(PowerMockRunner.class)\r
+@PrepareForTest({CmdExecutor.class})\r
+public class VirtualMachineTest extends TestCase {\r
+ String name,uuId;\r
+ Cache cacheTest;\r
+ private VirtualMachine virtualMachineTest;\r
+ private Connector connector;\r
+ private Class class1;\r
+ private Method method;\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ name = new String("name1");\r
+ uuId = new String("11111111-1111-1111-1111-111111111111");\r
+ virtualMachineTest = new VirtualMachine(name,uuId);\r
+ org.opendaylight.nemo.tool.sandbox.models.Connector connector = mock(org.opendaylight.nemo.tool.sandbox.models.Connector.class);\r
+ virtualMachineTest.addConnectors(connector);\r
+ class1 = VirtualMachine.class;\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testGenerateCommands() throws Exception {\r
+ method = class1.getDeclaredMethod("generateCommands",new Class[]{});\r
+ method.setAccessible(true);\r
+ Assert.assertNotNull(method.invoke(virtualMachineTest));\r
+ }\r
+\r
+ @Test\r
+ public void testUninstall() throws Exception {\r
+ PowerMockito.mockStatic(CmdExecutor.class);\r
+ PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
+ virtualMachineTest.uninstall();\r
+\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.nemo.tool.sandbox.northbound;
+
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by zhangmeng on 2016/1/14.
+ */
+public class CreateRequestTest extends TestCase {
+ private CreateRequest createRequest;
+ @Before
+ public void setUp() throws Exception {
+
+ }
+
+ @Test
+ public void testInit()throws Exception{
+ createRequest = new CreateRequest();
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.nemo.tool.sandbox.northbound;
+
+import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by zhangmeng on 2016/1/14.
+ */
+public class ExecuteRequestTest extends TestCase {
+ private ExecuteRequest executeRequest;
+ @Before
+ public void setUp() throws Exception {
+ executeRequest = new ExecuteRequest();
+ }
+
+ @Test
+ public void testGet_Set() throws Exception {
+ Assert.assertTrue(executeRequest.getHostName() == null);
+ executeRequest.setHostName("test");
+ Assert.assertTrue(executeRequest.getHostName().equals("test"));
+
+ Assert.assertTrue(executeRequest.getCommand() == null);
+ executeRequest.setCommand("command");
+ Assert.assertTrue(executeRequest.getCommand().equals("command"));
+
+ //test to string
+ Assert.assertTrue(executeRequest.toString().equals("ExecuteRequest{" +
+ "hostName='" + "test" + '\'' +
+ ", command='" + "command" + '\'' +
+ '}'));
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.nemo.tool.sandbox.northbound;
+
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import org.glassfish.grizzly.http.server.HttpServer;
+import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
+import org.glassfish.jersey.server.ResourceConfig;
+
+import java.io.Reader;
+import java.net.URI;
+/**
+ * Created by zhangmeng on 2016/1/14.
+ */
+public class RestServerTest extends TestCase {
+ private RestServer restServer;
+ @Before
+ public void setUp() throws Exception {
+ restServer = new RestServer();
+ }
+
+ @Test
+ public void testStart() throws Exception {
+// RestServer.start("s1");
+ }
+
+ @Test
+ public void testStop() throws Exception {
+ RestServer.stop();
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.nemo.tool.sandbox.northbound;
+
+import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import org.codehaus.enunciate.jaxrs.ResponseCode;
+import org.codehaus.enunciate.jaxrs.StatusCodes;
+import org.codehaus.enunciate.jaxrs.TypeHint;
+import org.junit.runner.RunWith;
+import org.opendaylight.nemo.tool.sandbox.SandBoxManager;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
+import java.util.ArrayList;
+import java.util.List;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.api.support.membermodification.MemberMatcher;
+import org.powermock.api.support.membermodification.MemberModifier;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import static org.mockito.Mockito.*;
+/**
+ * Created by zhangmeng on 2016/1/14.
+ */
+
+public class SandboxNorthboundTest extends TestCase {
+ private SandboxNorthbound sandboxNorthbound;
+ @Before
+ public void setUp() throws Exception {
+ sandboxNorthbound = new SandboxNorthbound();
+ }
+
+ @Test
+ public void testCreate() throws Exception {
+ ExecuteRequest executeRequest = new ExecuteRequest();
+ Assert.assertTrue(sandboxNorthbound.create(null,"test") != null);
+ Assert.assertTrue(sandboxNorthbound.create(null,executeRequest) != null);
+ }
+
+ @Test
+ public void testDestroy() throws Exception {
+ Assert.assertTrue(sandboxNorthbound.destroy(null) != null);
+ }
+
+ @Test
+ public void testGetXml() throws Exception {
+ Assert.assertTrue(sandboxNorthbound.getXml() != null);
+ }
+
+ @Test
+ public void testGetHosts() throws Exception {
+ Assert.assertTrue(sandboxNorthbound.getHosts() == null);
+ }
+
+ @Test
+ public void testGetSwitches() throws Exception {
+ Assert.assertTrue(sandboxNorthbound.getSwitches() != null);
+ }
+
+ @Test
+ public void testGetLinks() throws Exception {
+ Assert.assertTrue(sandboxNorthbound.getLinks() != null);
+ }
+
+ @Test
+ public void testGetExternals() throws Exception {
+ Assert.assertTrue(sandboxNorthbound.getExternals() == null);
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.nemo.tool.sandbox.utils;
+
+import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by zhangmeng on 2016/1/14.
+ */
+public class ConfigTest extends TestCase {
+ private Config config;
+ @Before
+ public void setUp() throws Exception {
+ config = new Config();
+ }
+
+ @Test
+ public void testAll() throws Exception{
+ Assert.assertTrue(Config.getControllerSocket() != null);
+ Assert.assertTrue(Config.isPrintProcess() == false);
+ Assert.assertTrue(Config.getHostName() != null);
+ Assert.assertTrue(Config.getHostUser() != null);
+ Assert.assertTrue(Config.getHostPassword() != null);
+ Assert.assertTrue(Config.getConfigPath() != null);
+ Assert.assertTrue(Config.getConfigHostsFileName() != null);
+ Assert.assertTrue(Config.getConfigExternalsFileName() != null);
+ Assert.assertTrue(Config.getConfigLinksFileName() != null);
+ Assert.assertTrue(Config.getConfigNodesFileName() != null);
+ }
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.nemo.tool.sandbox.utils;\r
+\r
+import junit.framework.TestCase;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+/**\r
+ * Created by zhangmeng on 2016/1/14.\r
+ */\r
+public class FileUtilsTest extends TestCase {\r
+ private FileUtils fileUtils;\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ fileUtils = new FileUtils();\r
+ }\r
+\r
+ @Test\r
+ public void testWrite() throws Exception {\r
+ FileUtils.write("home","test");\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.nemo.tool.sandbox.utils;
+
+import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by zhangmeng on 2016/1/14.
+ */
+public class HexStringTest extends TestCase {
+ private HexString hexString;
+ @Test
+ public void testToHexString() throws Exception {
+ Assert.assertTrue(HexString.toHexString(1L,6) != null);
+ Assert.assertTrue(HexString.toHexString(1L) != null);
+ }
+
+ @Test
+ public void testFromHexString() throws Exception {
+ Assert.assertTrue(HexString.fromHexString("22:32") != null);
+ }
+
+ @Test
+ public void testToLong() throws Exception {
+// System.out.println(HexString.toLong("11:22"));
+ Assert.assertTrue(HexString.toLong("11:22") != 0);
+ }
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.nemo.tool.sandbox.utils;\r
+\r
+import junit.framework.TestCase;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+import static org.junit.Assert.*;\r
+import java.io.BufferedReader;\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+import java.io.InputStreamReader;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+/**\r
+ * Created by zhangmeng on 2016/1/14.\r
+ */\r
+public class PropertyLoaderTest extends TestCase {\r
+ private PropertyLoader propertyLoader;\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ propertyLoader = new PropertyLoader();\r
+ }\r
+\r
+ @Test\r
+ public void testLoadProperties() throws Exception {\r
+ PropertyLoader.loadProperties("home","no file!");\r
+ }\r
+\r
+ @Test\r
+ public void testReadLines() throws Exception {\r
+ PropertyLoader.readLines("home","no file!");\r
+ }\r
+}
\ No newline at end of file