diff --git a/src/test/java/net/floodlightcontroller/core/internal/SwitchStorageImplTest.java b/src/test/java/net/floodlightcontroller/core/internal/SwitchStorageImplTest.java
deleted file mode 100644
index fb6b086..0000000
--- a/src/test/java/net/floodlightcontroller/core/internal/SwitchStorageImplTest.java
+++ /dev/null
@@ -1,278 +0,0 @@
-package net.floodlightcontroller.core.internal;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import net.onrc.onos.ofcontroller.core.ISwitchStorage;
-import net.onrc.onos.ofcontroller.core.ISwitchStorage.SwitchState;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.openflow.protocol.OFPhysicalPort;
-
-import com.thinkaurelius.titan.core.TitanGraph;
-import com.tinkerpop.blueprints.Vertex;
-import com.tinkerpop.gremlin.java.GremlinPipeline;
-import com.tinkerpop.pipes.PipeFunction;
-import com.tinkerpop.pipes.branch.LoopPipe.LoopBundle;
-
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptException;
-import com.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine;
-
-
-public class SwitchStorageImplTest {
-
-	private ISwitchStorage switchStorage;
-	private TitanGraph titanGraph;
-	
-	@Before
-	public void setUp() throws Exception {
-		titanGraph = TestDatabaseManager.getTestDatabase();
-		TestDatabaseManager.populateTestData(titanGraph);
-		
-		switchStorage = new TestableSwitchStorageImpl();
-	}
-
-	@After
-	public void tearDown() throws Exception {
-		titanGraph.shutdown();
-	}
-
-	@Ignore @Test
-	public void testUpdate() {
-		fail("Not yet implemented");
-	}
-
-	@Test
-	public void testAddPort() {
-		
-		String dpid = "00:00:00:00:00:00:0a:01";
-		short portNumber = 5;
-		
-		OFPhysicalPort portToAdd = new OFPhysicalPort();
-		portToAdd.setName("port 5 at SEA switch");
-		portToAdd.setCurrentFeatures(OFPhysicalPort.OFPortFeatures.OFPPF_100MB_FD.getValue());
-		portToAdd.setPortNumber(portNumber);
-		
-		switchStorage.addPort(dpid, portToAdd);
-		
-		Vertex sw = titanGraph.getVertices("dpid", dpid).iterator().next();
-		
-		GremlinPipeline<Vertex, Vertex> pipe = new GremlinPipeline<Vertex, Vertex>();
-		pipe.start(sw).out("on").has("number", portNumber);
-		
-		assertTrue(pipe.hasNext());
-		Vertex addedPort = pipe.next();
-		assertFalse(pipe.hasNext());
-		
-		assertEquals(addedPort.getProperty("number"), portNumber);
-	}
-
-	@Ignore @Test
-	public void testGetPorts() {
-		fail("Not yet implemented");
-	}
-
-	@Ignore @Test
-	public void testGetPortStringShort() {
-		fail("Not yet implemented");
-	}
-
-	@Ignore @Test
-	public void testGetPortStringString() {
-		fail("Not yet implemented");
-	}
-
-	@Test
-	public void testAddSwitch() {
-		String dpid = "00:00:00:00:00:00:0a:07";
-		
-		switchStorage.addSwitch(dpid);
-		
-		Iterator<Vertex> it = titanGraph.getVertices("dpid", dpid).iterator();
-		assertTrue(it.hasNext());
-		Vertex addedSwitch = it.next();
-		assertFalse(it.hasNext());
-		
-		assertEquals(addedSwitch.getProperty("type"), "switch");
-		assertEquals(addedSwitch.getProperty("dpid"), dpid);
-		assertEquals(addedSwitch.getProperty("state"), SwitchState.ACTIVE.toString());
-	}
-
-	
-	@Test
-	public void testDeleteSwitch() {
-		String dpid = "00:00:00:00:00:00:0a:01";
-		
-		switchStorage.deleteSwitch(dpid);
-		
-		Iterator<Vertex> it = titanGraph.getVertices("dpid", dpid).iterator();
-		assertFalse(it.hasNext());
-	}
-
-	@Test
-	public void testDeletePortByPortNum() {
-		//FIXME fails because query for the port is wrong in SwitchStorageImpl
-		
-		String dpid = "00:00:00:00:00:00:0a:01";
-		short portNum = 3;
-		
-		switchStorage.deletePort(dpid, portNum);
-		
-		Vertex sw = titanGraph.getVertices("dpid", dpid).iterator().next();
-		
-		/*
-		Iterator<Vertex> it = sw.getVertices(Direction.OUT, "on").iterator();
-		
-		while (it.hasNext()){
-			System.out.println(it.next());
-		}
-		*/
-		
-		GremlinPipeline<Vertex, Vertex> pipe = new GremlinPipeline<Vertex, Vertex>();
-		pipe.start(sw).out("on").has("number", portNum);
-		assertFalse(pipe.hasNext());
-	}
-
-	@Ignore @Test
-	public void testDeletePortStringString() {
-		fail("Not yet implemented");
-	}
-
-	@Ignore @Test
-	public void testGetActiveSwitches() {
-		fail("Not yet implemented");
-	}
-
-	static class MyLoopFunction implements PipeFunction<LoopBundle<Vertex>, Boolean> {
-	    String dpid;
-	    public MyLoopFunction(String dpid) {
-		super();
-		this.dpid = dpid;
-	    }
-	    public Boolean compute(LoopBundle<Vertex> bundle) {
-		Boolean output = false;
-		if (! bundle.getObject().getProperty("dpid").equals(dpid)) {
-		    output = true;
-		}
-		return output;
-	    }
-	}
-
-	@Test
-	public void testShortestPath() {
-	    String dpid_src = "00:00:00:00:00:00:0a:01";
-	    String dpid_dest = "00:00:00:00:00:00:0a:06";
-
-	    //
-	    // Implement the Shortest Path between two vertices by using
-	    // the following Gremlin CLI code:
-	    //   v_src.as("x").out("on").out("link").in("on").dedup().loop("x"){it.object.dpid != v_dest.dpid}.path(){it.dpid}{it.number}{it.number}
-	    // The equivalent code used here is:
-	    //   results = []; v_src.as("x").out("on").out("link").in("on").dedup().loop("x"){it.object.dpid != v_dest.dpid}.path().fill(results)
-	    //
-
-	    // Get the source vertex
-	    Iterator<Vertex> iter = titanGraph.getVertices("dpid", dpid_src).iterator();
-	    if (! iter.hasNext())
-		return;			// Source vertex not found
-	    Vertex v_src = iter.next();
-
-	    // Get the destination vertex
-	    iter = titanGraph.getVertices("dpid", dpid_dest).iterator();
-	    if (! iter.hasNext())
-		return;			// Destination vertex not found
-	    Vertex v_dest = iter.next();
-
-	    //
-	    // Implement the Gremlin script and run it
-	    //
-	    // NOTE: This mechanism is slower. The code is kept here
-	    // for future reference.
-	    //
-	    /*
-	    String gremlin = "v_src.as(\"x\").out(\"on\").out(\"link\").in(\"on\").dedup().loop(\"x\"){it.object.dpid != v_dest.dpid}.path().fill(results)";
-
-	    String gremlin_nopath = "v_src.as(\"x\").out(\"on\").out(\"link\").in(\"on\").dedup().loop(\"x\"){it.object.dpid != \"NO-SUCH-DPID\"}.path().fill(results)";
-
-	    ScriptEngine engine = new GremlinGroovyScriptEngine();
-	    ArrayList<ArrayList<Vertex>> results = new ArrayList<ArrayList<Vertex>>();
-	    engine.getBindings(ScriptContext.ENGINE_SCOPE).put("g", titanGraph);
-	    engine.getBindings(ScriptContext.ENGINE_SCOPE).put("v_src", v_src);
-	    engine.getBindings(ScriptContext.ENGINE_SCOPE).put("v_dest", v_dest);
-	    engine.getBindings(ScriptContext.ENGINE_SCOPE).put("results", results);
-
-	    try {
-		engine.eval(gremlin);
-	    } catch (ScriptException e) {
-		System.err.println("Caught ScriptException running Gremlin script: " + e.getMessage());
-		return;
-	    }
-
-	    for (ArrayList<Vertex> lv : results) {
-		...
-	    }
-	    */
-
-	    MyLoopFunction whileFunction = new MyLoopFunction(dpid_dest);
-	    GremlinPipeline<Vertex, Vertex> pipe = new GremlinPipeline<Vertex, Vertex>();
-	    Collection<List> results = new ArrayList<List>();
-	    GremlinPipeline<Vertex, List> path;
-	    path = pipe.start(v_src).as("x").out("on").out("link").in("on").dedup().loop("x", whileFunction).path();
-	    path.fill(results);
-
-	    //
-	    // Extract the result and compose it into a string
-	    //
-	    String results_str = "";
-	    // System.out.println("BEGIN " + results.size());
-	    for (List l : results) {
-		for (Object o: l) {
-		    Vertex v = (Vertex)(o);
-		    // System.out.println(v);
-		    String type = v.getProperty("type").toString();
-		    results_str += "[type: " + type;
-		    // System.out.println("type: " + type);
-		    if (type.equals("port")) {
-			String number = v.getProperty("number").toString();
-			// System.out.println("number: " + number);
-			results_str += " number: " + number + "]";
-		    }
-		    if (type.equals("switch")) {
-			String dpid = v.getProperty("dpid").toString();
-			// System.out.println("dpid: " + dpid);
-			results_str += " dpid: " + dpid + "]";
-		    }
-		}
-	    }
-	    // System.out.println("END\n");
-	    System.out.println(results_str);
-
-	    //
-	    // Check the result
-	    //
-	    String expected_result = "[type: switch dpid: 00:00:00:00:00:00:0a:01][type: port number: 2][type: port number: 1][type: switch dpid: 00:00:00:00:00:00:0a:03][type: port number: 2][type: port number: 2][type: switch dpid: 00:00:00:00:00:00:0a:04][type: port number: 3][type: port number: 1][type: switch dpid: 00:00:00:00:00:00:0a:06]";
-
-	    assertEquals(results_str, expected_result);
-
-	    //
-	    // Test Shortest-Path computation to non-existing destination
-	    //
-	    results.clear();
-	    MyLoopFunction noDestWhileFunction = new MyLoopFunction("NO-SUCH-DPID");
-	    path = pipe.start(v_src).as("x").out("on").out("link").in("on").dedup().loop("x", noDestWhileFunction).path();
-	    path.fill(results);
-	    assertTrue(results.size() == 0);
-	}
-}
diff --git a/src/test/java/net/floodlightcontroller/core/internal/TestDatabaseManager.java b/src/test/java/net/floodlightcontroller/core/internal/TestDatabaseManager.java
index 3d5e03b..f811c9d 100644
--- a/src/test/java/net/floodlightcontroller/core/internal/TestDatabaseManager.java
+++ b/src/test/java/net/floodlightcontroller/core/internal/TestDatabaseManager.java
@@ -58,8 +58,17 @@
         Iterator<Vertex> it = titanGraph.getVertices("type", "port").iterator();
         while (it.hasNext()){
         	Vertex port = it.next();
-        	Integer portNum = (Integer) port.getProperty("number");
-        	port.setProperty("number", portNum.shortValue());
+
+        	if(port.getProperty("number") instanceof Short)
+        	{
+        		Short portNum = (Short) port.getProperty("number");
+        		port.setProperty("number", portNum.shortValue());
+        	}
+        	else{
+        		Integer portNum = (Integer) port.getProperty("number");	
+        		port.setProperty("number", portNum.shortValue());
+        	}
+
         }
         titanGraph.stopTransaction(Conclusion.SUCCESS);
 	}
diff --git a/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceStorageImplTest.java b/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceStorageImplTest.java
deleted file mode 100644
index cd1651f..0000000
--- a/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceStorageImplTest.java
+++ /dev/null
@@ -1,833 +0,0 @@
-package net.floodlightcontroller.devicemanager.internal;
-
-import static org.junit.Assert.*;
-import static org.easymock.EasyMock.*;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IDeviceObject;
-import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
-import net.onrc.onos.ofcontroller.core.internal.SwitchStorageImpl;
-import net.onrc.onos.ofcontroller.devicemanager.internal.DeviceStorageImpl;
-import net.onrc.onos.util.GraphDBConnection;
-import net.onrc.onos.util.GraphDBOperation;
-import net.floodlightcontroller.devicemanager.IDevice;
-import net.floodlightcontroller.devicemanager.SwitchPort;
-import net.floodlightcontroller.packet.IPv4;
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.openflow.util.HexString;
-import org.powermock.api.easymock.PowerMock;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.thinkaurelius.titan.core.TitanFactory;
-
-//Add Powermock preparation
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({TitanFactory.class, GraphDBConnection.class, GraphDBOperation.class, DeviceStorageImpl.class})
-public class DeviceStorageImplTest{ //extends FloodlightTestCase{
-	
-	protected static Logger log = LoggerFactory.getLogger(SwitchStorageImpl.class);
-	
-	String conf;
-	DeviceStorageImpl deviceImpl;
-    private GraphDBConnection mockConn;
-    private GraphDBOperation mockOpe;
-    
-	@Before
-	public void setUp() throws Exception {
-
-		PowerMock.mockStatic(GraphDBConnection.class);
-		mockConn = createMock(GraphDBConnection.class);
-		PowerMock.suppress(PowerMock.constructor(GraphDBConnection.class));
-		EasyMock.expect(GraphDBConnection.getInstance((String)EasyMock.anyObject())).andReturn(mockConn);
-		PowerMock.replay(GraphDBConnection.class);
-			
-		//PowerMock.mockStatic(GraphDBOperation.class);
-		mockOpe = PowerMock.createMock(GraphDBOperation.class);
-		PowerMock.expectNew(GraphDBOperation.class, mockConn).andReturn(mockOpe);
-		PowerMock.replay(GraphDBOperation.class);
-        // Replace the conf to dummy conf
-		// String conf = "/tmp/cassandra.titan";
-		conf = "/dummy/path/to/db";
-		
-        deviceImpl = new DeviceStorageImpl();
-	}
-
-	@After
-	public void tearDown() throws Exception {	
-		deviceImpl.close();
-		deviceImpl = null;
-	}
-	
-	private String makeIPStringFromArray(Integer[] ipaddresses){
-        String multiIntString = "";
-        for(Integer intValue : ipaddresses)
-        {
-        	if (multiIntString == null || multiIntString.isEmpty()){
-        		multiIntString = "[" + IPv4.fromIPv4Address(intValue);
-        	}
-        	else{
-           		multiIntString += "," + IPv4.fromIPv4Address(intValue);
-        	}
-        }
-        return multiIntString + "]";
-	}
-	
-
-	/**
-	 * Desc:
-	 *  Test method for addDevice method.
-	 * Codition:
-	 *  N/A
-	 * Expect:
-	 * 	Get proper IDeviceObject
-	 */
-	//@Ignore
-	@Test
-	public void testAddNewDevice() {
-		try 
-		{	   
-			//Make mockDevice
-			IDevice mockDev = createMock(Device.class);
-			// Mac addr for test device.
-			String macAddr = "99:99:99:99:99:99";
-			// IP addr for test device
-			String ip = "192.168.100.1";
-			Integer[] ipaddrs = {IPv4.toIPv4Address(ip)};
-			// Mac addr for attached switch
-			String switchMacAddr = "00:00:00:00:00:00:0a:01";		
-			long switchMacAddrL = HexString.toLong(switchMacAddr);
-			// Port number for attached switch
-			short portNum = 2; 
-			SwitchPort sp1 = new SwitchPort(switchMacAddrL, portNum);
-			SwitchPort[] sps = {sp1};
-		
-			expect(mockDev.getMACAddressString()).andReturn(macAddr).anyTimes();
-			expect(mockDev.getIPv4Addresses()).andReturn(ipaddrs).anyTimes();
-			expect(mockDev.getAttachmentPoints()).andReturn(sps).anyTimes();
-			replay(mockDev);
-			
-			//Mock IPortObject 1 with dpid "00:00:00:00:00:00:0a:01" and port "1"
-			IPortObject mockIPort = createMock(IPortObject.class);
-			mockIPort.setNumber(portNum);
-			mockIPort.setType("port");
-			String iPortDesc = "port 1 at SEA Switch";
-			expect(mockIPort.getNumber()).andReturn(portNum).anyTimes();
-			expect(mockIPort.getDesc()).andReturn(iPortDesc).anyTimes();
-			replay(mockIPort);
-			
-			//Make Iterator for mockIport
-			List<IPortObject> portList = new ArrayList<IPortObject>();
-			portList.add(mockIPort);
-			
-			//Expectation for mockIDeviceObject
-			IDeviceObject mockIDev = createMock(IDeviceObject.class);	
-			expect(mockIDev.getAttachedPorts()).andReturn(portList);
-			mockIDev.setIPAddress(makeIPStringFromArray(ipaddrs));
-			mockIDev.setMACAddress(macAddr);
-			mockIDev.setType("device");
-			mockIDev.setState("ACTIVE");
-			replay(mockIDev);	
-			
-			//Expectation for mockOpe
-			expect(mockOpe.searchDevice(macAddr)).andReturn(null);
-			expect(mockOpe.newDevice()).andReturn(mockIDev);
-			expect(mockOpe.searchPort(switchMacAddr, portNum)).andReturn(mockIPort);
-			mockOpe.commit();
-
-			replay(mockOpe);				
-			
-			deviceImpl.init(conf);
-			
-			//Add the device
-	        IDeviceObject obj = deviceImpl.addDevice(mockDev);	
-			assertNotNull(obj);
-			
-			verify(mockIDev);
-			verify(mockOpe);
-			
-		} catch(Exception e) {
-			fail(e.getMessage());
-		}
-	}
-	
-	/**
-	 * Desc:
-	 * 	Test method for addDevice method.
-	 * Condition:
-	 * 	Already added device is existed.
-	 * Expect:
-	 * 	Get proper IDeviceObject still.
-	 *  Check the IDeviceObject properties set expectedly. 
-	 */
-	//@Ignore
-	@Test
-	public void testAddDeviceExisting() {
-		try 
-		{	   
-			IDevice mockDev = createMock(Device.class);
-			String macAddr = "99:99:99:99:99:99";
-			String ip = "192.168.100.1";
-			Integer[] ipaddrs = {IPv4.toIPv4Address(ip)};
-			String switchMacAddr = "00:00:00:00:00:00:0a:01";		
-			long switchMacAddrL = HexString.toLong(switchMacAddr);
-			short portNum = 2; 
-			SwitchPort sp1 = new SwitchPort(switchMacAddrL, portNum);
-			SwitchPort[] sps = {sp1};
-		
-			expect(mockDev.getMACAddressString()).andReturn(macAddr).anyTimes();
-			expect(mockDev.getIPv4Addresses()).andReturn(ipaddrs).times(2);
-			expect(mockDev.getAttachmentPoints()).andReturn(sps).times(2);
-			replay(mockDev);
-			
-			//Mock IPortObject 1 with dpid "00:00:00:00:00:00:0a:01" and port "1"
-			IPortObject mockIPort = createMock(IPortObject.class);
-			mockIPort.setNumber(portNum);
-			mockIPort.setType("port");
-			String iPortDesc = "port 1 at SEA Switch";
-			expect(mockIPort.getNumber()).andReturn(portNum).anyTimes();
-			expect(mockIPort.getDesc()).andReturn(iPortDesc).anyTimes();
-			replay(mockIPort);
-			
-			//Make Iterator for mockIport
-			List<IPortObject> portList = new ArrayList<IPortObject>();
-			portList.add(mockIPort);
-			
-			//Expectation for mockIDeviceObject
-			IDeviceObject mockIDev = createMock(IDeviceObject.class);	
-			expect(mockIDev.getAttachedPorts()).andReturn(portList).anyTimes();
-			mockIDev.setIPAddress(makeIPStringFromArray(ipaddrs));
-			mockIDev.setMACAddress(macAddr);
-			mockIDev.setType("device");
-			mockIDev.setState("ACTIVE");
-			mockIDev.setIPAddress(makeIPStringFromArray(ipaddrs));
-			mockIDev.setMACAddress(macAddr);
-			mockIDev.setType("device");
-			mockIDev.setState("ACTIVE");
-			replay(mockIDev);	
-			
-			//Expectation for mockOpe
-			expect(mockOpe.searchDevice(macAddr)).andReturn(null);
-			expect(mockOpe.newDevice()).andReturn(mockIDev);
-			expect(mockOpe.searchPort(switchMacAddr, portNum)).andReturn(mockIPort);
-			mockOpe.commit();
-			expect(mockOpe.searchDevice(macAddr)).andReturn(mockIDev);
-			expect(mockOpe.searchPort(switchMacAddr, portNum)).andReturn(mockIPort);
-			mockOpe.commit();
-			replay(mockOpe);				
-			
-			deviceImpl.init(conf);
-			
-			//Add the device
-	        IDeviceObject obj = deviceImpl.addDevice(mockDev);	
-			assertNotNull(obj);
-			
-			//Add the same device
-	        IDeviceObject obj2 = deviceImpl.addDevice(mockDev);
-			assertNotNull(obj2);
-			
-			verify(mockIDev);
-			verify(mockOpe);
-			
-		} catch(Exception e) {
-			fail(e.getMessage());
-		}
-	}
-	
-	/**
-	 * Desc:
-	 * 	Test method for updateDevice method.
-	 * Condition:
-	 * 	The mac address and attachment point are the same. 
-	 *  All of the other parameter are different.
-	 * Expect:
-	 * 	Changed parameters are set expectedly.
-	 */
-	//@Ignore
-	@Test
-	public void testUpdateDevice() {
-		try
-		{
-			IDevice mockDev = createMock(Device.class);
-			String macAddr = "99:99:99:99:99:99";
-			String ip = "192.168.100.1";
-			Integer ipInt = IPv4.toIPv4Address(ip);
-			Integer[] ipaddrs = {ipInt};
-			String switchMacAddr = "00:00:00:00:00:00:0a:01";		
-			long switchMacAddrL = HexString.toLong(switchMacAddr);
-			short portNum = 2; 
-			SwitchPort sp1 = new SwitchPort(switchMacAddrL, portNum);
-			SwitchPort[] sps = {sp1};
-			
-			expect(mockDev.getMACAddressString()).andReturn(macAddr).anyTimes();
-			expect(mockDev.getIPv4Addresses()).andReturn(ipaddrs);
-			expect(mockDev.getAttachmentPoints()).andReturn(sps);
-			replay(mockDev);
-			
-			//Dev2 (attached port is the same)
-			IDevice mockDev2 = createMock(Device.class);
-			String ip2 = "192.168.100.2";
-			Integer ipInt2 = IPv4.toIPv4Address(ip2);
-			Integer[] ipaddrs2 = {ipInt2};
-			
-			expect(mockDev2.getMACAddressString()).andReturn(macAddr).anyTimes();
-			expect(mockDev2.getIPv4Addresses()).andReturn(ipaddrs2);
-			expect(mockDev2.getAttachmentPoints()).andReturn(sps);
-			replay(mockDev2);
-			
-			//Mock IPortObject 1 with dpid "00:00:00:00:00:00:0a:01" and port "1"
-			IPortObject mockIPort = createMock(IPortObject.class);
-			mockIPort.setNumber(portNum);
-			mockIPort.setType("port");
-			String iPortDesc = "port 1 at SEA Switch";
-			expect(mockIPort.getNumber()).andReturn(portNum).anyTimes();
-			expect(mockIPort.getDesc()).andReturn(iPortDesc).anyTimes();
-			replay(mockIPort);
-			
-			//Make Iterator for mockIport
-			List<IPortObject> portList = new ArrayList<IPortObject>();
-			portList.add(mockIPort);
-			
-			//Expectation for mockIDeviceObject
-			IDeviceObject mockIDev = createMock(IDeviceObject.class);	
-			expect(mockIDev.getAttachedPorts()).andReturn(portList).anyTimes();
-			mockIDev.setIPAddress(makeIPStringFromArray(ipaddrs));
-			mockIDev.setMACAddress(macAddr);
-			mockIDev.setType("device");
-			mockIDev.setState("ACTIVE");
-			mockIDev.setIPAddress(makeIPStringFromArray(ipaddrs2));
-			mockIDev.setMACAddress(macAddr);
-			mockIDev.setType("device");
-			mockIDev.setState("ACTIVE");
-			replay(mockIDev);	
-			
-			//Expectation for mockOpe
-			expect(mockOpe.searchDevice(macAddr)).andReturn(null);
-			expect(mockOpe.newDevice()).andReturn(mockIDev);
-			expect(mockOpe.searchPort(switchMacAddr, portNum)).andReturn(mockIPort);
-			mockOpe.commit();
-			expect(mockOpe.searchDevice(macAddr)).andReturn(mockIDev);
-			expect(mockOpe.searchPort(switchMacAddr, portNum)).andReturn(mockIPort);
-			mockOpe.commit();
-			replay(mockOpe);				
-			
-			deviceImpl.init(conf);
-			
-	        IDeviceObject obj = deviceImpl.addDevice(mockDev);	
-			assertNotNull(obj);
-			
-			//update theDevice
-			IDeviceObject obj2 = deviceImpl.updateDevice(mockDev2);
-			assertNotNull(obj2);
-			
-			verify(mockIDev);
-			verify(mockOpe);
-			
-		} catch(Exception e) {
-			fail(e.getMessage());
-		}
-	}
-
-	/**
-	 * Desc:
-	 * 	Test method for testRemoveDevice method.
-	 * Condition:
-	 * 	1. Unregistered IDeviceObject argument is put. 
-	 * Expect:
-	 *  1. Nothing happen when unregistered IDeviceObject is put
-	 * 	2. IDeviceObject will be removed.
-	 */
-	//@Ignore
-	@Test
-	public void testRemoveDevice() {
-		try
-		{
-			IDevice mockDev = createMock(Device.class);
-			String macAddr = "99:99:99:99:99:99";
-			String ip = "192.168.100.1";
-			Integer ipInt = IPv4.toIPv4Address(ip);
-			Integer[] ipaddrs = {ipInt};
-			String switchMacAddr = "00:00:00:00:00:00:0a:01";		
-			long switchMacAddrL = HexString.toLong(switchMacAddr);
-			short portNum = 2; 
-			SwitchPort sp1 = new SwitchPort(switchMacAddrL, portNum);
-			SwitchPort[] sps = {sp1};
-			
-			expect(mockDev.getMACAddressString()).andReturn(macAddr).anyTimes();
-			expect(mockDev.getAttachmentPoints()).andReturn(sps);
-			expect(mockDev.getIPv4Addresses()).andReturn(ipaddrs);
-			replay(mockDev);
-			
-			//Dev2 (attached port is the same)
-			IDevice mockDev2 = createMock(Device.class);
-			String macAddr2 = "33:33:33:33:33:33";
-			expect(mockDev2.getMACAddressString()).andReturn(macAddr2).anyTimes();
-			expect(mockDev2.getIPv4Addresses()).andReturn(ipaddrs);
-			expect(mockDev2.getAttachmentPoints()).andReturn(sps);
-			replay(mockDev2);
-			
-			//Mock IPortObject 1 with dpid "00:00:00:00:00:00:0a:01" and port "1"
-			IPortObject mockIPort = createMock(IPortObject.class);
-			mockIPort.setNumber(portNum);
-			mockIPort.setType("port");
-			String iPortDesc = "port 1 at SEA Switch";
-			expect(mockIPort.getNumber()).andReturn(portNum).anyTimes();
-			expect(mockIPort.getDesc()).andReturn(iPortDesc).anyTimes();
-			replay(mockIPort);
-			
-			//Make Iterator for mockIport
-			List<IPortObject> portList = new ArrayList<IPortObject>();
-			portList.add(mockIPort);
-			
-			//Expectation for mockIDeviceObject
-			IDeviceObject mockIDev = createMock(IDeviceObject.class);	
-			expect(mockIDev.getAttachedPorts()).andReturn(portList);
-			mockIDev.setIPAddress(makeIPStringFromArray(ipaddrs));
-			mockIDev.setMACAddress(macAddr);
-			mockIDev.setType("device");
-			mockIDev.setState("ACTIVE");
-			replay(mockIDev);	
-			
-			//Expectation for mockOpe
-			expect(mockOpe.searchDevice(macAddr)).andReturn(null);
-			expect(mockOpe.newDevice()).andReturn(mockIDev);
-			expect(mockOpe.searchPort(switchMacAddr, portNum)).andReturn(mockIPort);
-			mockOpe.commit();
-			expect(mockOpe.searchDevice(macAddr2)).andReturn(null);
-			expect(mockOpe.searchDevice(macAddr)).andReturn(mockIDev);
-			expect(mockOpe.searchDevice(macAddr)).andReturn(mockIDev);
-			mockOpe.removeDevice(mockIDev);	
-			mockOpe.commit();
-			expect(mockOpe.searchDevice(macAddr)).andReturn(null);
-			replay(mockOpe);				
-			
-			deviceImpl.init(conf);
-			
-	        IDeviceObject obj = deviceImpl.addDevice(mockDev);	
-			assertNotNull(obj);
-
-			deviceImpl.removeDevice(mockDev2);
-		    IDeviceObject dev = deviceImpl.getDeviceByMac(macAddr);
-		    assertNotNull(dev);
-			
-			deviceImpl.removeDevice(mockDev);		
-		    IDeviceObject dev2 = deviceImpl.getDeviceByMac(macAddr);
-		    assertNull(dev2);
-		    
-			verify(mockIDev);
-			verify(mockOpe);
-		} catch(Exception e) {
-			fail(e.getMessage());
-		}
-	}
-
-	/**
-	 * Desc:
-	 * 	Test method for getDeviceByMac
-	 * Condition:
-	 * 	1. Unregistered mac address argument is set
-	 * Expect:
-	 * 	1.Nothing happen when you put unregistered mac address
-	 *  2.Get the proper IDeviceObject.
-	 *  3.Check the IDeviceObject properties set expectedly.
-	 */
-	//@Ignore
-	@Test
-	public void testGetDeviceByMac() {
-		try
-		{
-			IDevice mockDev = createMock(Device.class);
-			String macAddr = "99:99:99:99:99:99";
-			String ip = "192.168.100.1";
-			Integer ipInt = IPv4.toIPv4Address(ip);
-			Integer[] ipaddrs = {ipInt};
-			String switchMacAddr = "00:00:00:00:00:00:0a:01";		
-			long switchMacAddrL = HexString.toLong(switchMacAddr);
-			short portNum = 2; 
-			SwitchPort sp1 = new SwitchPort(switchMacAddrL, portNum);
-			SwitchPort[] sps = {sp1};
-			
-			String dummyMac = "33:33:33:33:33:33";
-			
-			expect(mockDev.getMACAddressString()).andReturn(macAddr).anyTimes();
-			expect(mockDev.getIPv4Addresses()).andReturn(ipaddrs);
-			expect(mockDev.getAttachmentPoints()).andReturn(sps);
-			replay(mockDev);
-			
-			//Mock IPortObject 1 with dpid "00:00:00:00:00:00:0a:01" and port "1"
-			IPortObject mockIPort = createMock(IPortObject.class);
-			mockIPort.setNumber(portNum);
-			mockIPort.setType("port");
-			String iPortDesc = "port 1 at SEA Switch";
-			expect(mockIPort.getNumber()).andReturn(portNum).anyTimes();
-			expect(mockIPort.getDesc()).andReturn(iPortDesc).anyTimes();
-			replay(mockIPort);
-			
-			//Make Iterator for mockIport
-			List<IPortObject> portList = new ArrayList<IPortObject>();
-			portList.add(mockIPort);
-			
-			//Expectation for mockIDeviceObject
-			IDeviceObject mockIDev = createMock(IDeviceObject.class);	
-			expect(mockIDev.getAttachedPorts()).andReturn(portList);
-			mockIDev.setIPAddress(makeIPStringFromArray(ipaddrs));
-			mockIDev.setMACAddress(macAddr);
-			mockIDev.setType("device");
-			mockIDev.setState("ACTIVE");
-			replay(mockIDev);	
-			
-			//Expectation for mockOpe
-			expect(mockOpe.searchDevice(macAddr)).andReturn(null);
-			expect(mockOpe.newDevice()).andReturn(mockIDev);
-			expect(mockOpe.searchPort(switchMacAddr, portNum)).andReturn(mockIPort);
-			mockOpe.commit();
-			expect(mockOpe.searchDevice(dummyMac)).andReturn(null);
-			expect(mockOpe.searchDevice(macAddr)).andReturn(mockIDev);
-			replay(mockOpe);				
-			
-			deviceImpl.init(conf);
-			
-	        IDeviceObject obj = deviceImpl.addDevice(mockDev);	
-			assertNotNull(obj);
-			
-		    IDeviceObject dummyDev = deviceImpl.getDeviceByMac(dummyMac);
-		    assertNull(dummyDev);	
-			
-		    IDeviceObject dev = deviceImpl.getDeviceByMac(macAddr);
-		    assertNotNull(dev);
-		    
-			verify(mockIDev);
-			verify(mockOpe);   
-		} catch(Exception e) {
-			fail(e.getMessage());
-		}
-	}
-
-	/**
-	 * Desc:
-	 * 	Test method for getDeviceByIP method.
-	 * Condition:
-	 * 	1. Unregistered ip address argument is set
-	 * Expect:
-	 * 	1. Nothing happen when you put unregistered mac address
-	 * 	2. Get the proper IDeviceObject.
-	 *  3. Check the IDeviceObject properties set expectedly.
-	 */
-	//@Ignore
-	@Test
-	public void testGetDeviceByIP() {
-		try
-		{
-			IDevice mockDev = createMock(Device.class);
-			String macAddr = "99:99:99:99:99:99";
-			String ip = "192.168.100.1";
-			String ip2 = "192.168.100.2";
-			Integer ipInt = IPv4.toIPv4Address(ip);
-			Integer ipInt2 = IPv4.toIPv4Address(ip2);
-			Integer[] ipaddrs = {ipInt, ipInt2};
-			String switchMacAddr = "00:00:00:00:00:00:0a:01";		
-			long switchMacAddrL = HexString.toLong(switchMacAddr);
-			short portNum = 2; 
-			SwitchPort sp1 = new SwitchPort(switchMacAddrL, portNum);
-			SwitchPort[] sps = {sp1};
-			
-			String dummyIP = "222.222.222.222";
-			
-			expect(mockDev.getMACAddressString()).andReturn(macAddr).anyTimes();
-			expect(mockDev.getIPv4Addresses()).andReturn(ipaddrs);
-			expect(mockDev.getAttachmentPoints()).andReturn(sps);
-			replay(mockDev);
-			
-			//Mock IPortObject 1 with dpid "00:00:00:00:00:00:0a:01" and port "1"
-			IPortObject mockIPort = createMock(IPortObject.class);
-			mockIPort.setNumber(portNum);
-			mockIPort.setType("port");
-			String iPortDesc = "port 1 at SEA Switch";
-			expect(mockIPort.getNumber()).andReturn(portNum).anyTimes();
-			expect(mockIPort.getDesc()).andReturn(iPortDesc).anyTimes();
-			replay(mockIPort);
-			
-			//Make Iterator for mockIport
-			List<IPortObject> portList = new ArrayList<IPortObject>();
-			portList.add(mockIPort);
-			
-			//Expectation for mockIDeviceObject
-			IDeviceObject mockIDev = createMock(IDeviceObject.class);	
-			expect(mockIDev.getAttachedPorts()).andReturn(portList);
-			expect(mockIDev.getIPAddress()).andReturn(makeIPStringFromArray(ipaddrs)).times(2);
-			mockIDev.setIPAddress(makeIPStringFromArray(ipaddrs));
-			mockIDev.setMACAddress(macAddr);
-			mockIDev.setType("device");
-			mockIDev.setState("ACTIVE");
-			replay(mockIDev);	
-			
-			
-			//Make mock Iterator for IDeviceObject
-			List<IDeviceObject> deviceList = new ArrayList<IDeviceObject>();
-			deviceList.add(mockIDev);	
-			
-			//Expectation for mockOpe
-			expect(mockOpe.searchDevice(macAddr)).andReturn(null);
-			expect(mockOpe.newDevice()).andReturn(mockIDev);
-			expect(mockOpe.searchPort(switchMacAddr, portNum)).andReturn(mockIPort);
-			mockOpe.commit();
-			expect(mockOpe.getDevices()).andReturn(deviceList).times(2);
-			replay(mockOpe);				
-			
-			deviceImpl.init(conf);
-	
-	        IDeviceObject obj = deviceImpl.addDevice(mockDev);	
-			assertNotNull(obj);
-			
-		    IDeviceObject dummyDev = deviceImpl.getDeviceByIP(dummyIP);
-		    assertNull(dummyDev);
-			
-		    IDeviceObject dev = deviceImpl.getDeviceByIP(ip);
-		    assertNotNull(dev);
-		    
-			verify(mockIDev);
-			verify(mockOpe);
-			
-		} catch(Exception e) {
-			fail(e.getMessage());
-		}
-	}
-
-	/**
-	 * Desc:
-	 * 	Test method for testChangeDeviceAttachmentsIDevice
-	 * Condition:
-	 * 	1. Unexisting attachment point argument is set
-	 * Expect:
-	 * 	1. Nothing happen when you put unexisting attachment point.
-	 * 	2. Set the attachment point expectedly;
-	 */
-	//@Ignore
-	@Test
-	public void testChangeDeviceAttachmentsIDevice() {
-		try
-		{
-			IDevice mockDev = createMock(Device.class);
-			String macAddr = "99:99:99:99:99:99";
-			String ip = "192.168.100.1";
-			Integer ipInt = IPv4.toIPv4Address(ip);
-			Integer[] ipaddrs = {ipInt};
-			String switchMacAddr = "00:00:00:00:00:00:0a:01";		
-			long switchMacAddrL = HexString.toLong(switchMacAddr);
-			short portNum = 2; 
-			SwitchPort sp1 = new SwitchPort(switchMacAddrL, portNum);
-			SwitchPort[] sps = {sp1};
-			
-			expect(mockDev.getMACAddressString()).andReturn(macAddr).anyTimes();
-			expect(mockDev.getIPv4Addresses()).andReturn(ipaddrs);
-			expect(mockDev.getAttachmentPoints()).andReturn(sps);
-			replay(mockDev);
-			
-			//Dev2
-			IDevice mockDev2 = createMock(Device.class);
-			String switchMacAddr2 = "00:00:00:00:00:00:0a:02";
-			long lSwitchMacAddr2 = HexString.toLong(switchMacAddr2);
-			short portNum2 = 2; 
-			SwitchPort sp2 = new SwitchPort(lSwitchMacAddr2, portNum2);
-			SwitchPort sps2[] = {sp2};
-			
-			expect(mockDev2.getMACAddressString()).andReturn(macAddr).anyTimes();
-			expect(mockDev2.getIPv4Addresses()).andReturn(ipaddrs);
-			expect(mockDev2.getAttachmentPoints()).andReturn(sps2);
-			replay(mockDev2);
-			
-			//Dev3
-			IDevice mockDev3 = createMock(Device.class);
-			String switchMacAddr3 = "00:00:00:00:00:00:00:00";
-			long lSwitchMacAddr3 = HexString.toLong(switchMacAddr3);
-			short portNum3 = 1; 
-			SwitchPort sp3 = new SwitchPort(lSwitchMacAddr3, portNum3);
-			SwitchPort sps3[] = {sp3};
-			
-			expect(mockDev3.getMACAddressString()).andReturn(macAddr).anyTimes();
-			expect(mockDev3.getIPv4Addresses()).andReturn(ipaddrs);
-			expect(mockDev3.getAttachmentPoints()).andReturn(sps3);
-			replay(mockDev3);
-			
-			IDeviceObject mockIDev = createMock(IDeviceObject.class);	
-			
-			//Mock IPortObject 1 with dpid "00:00:00:00:00:00:0a:01" and port "1"
-			IPortObject mockIPort = createMock(IPortObject.class);
-			mockIPort.setNumber(portNum);
-			mockIPort.setType("port");
-			String iPortDesc = "port 1 at SEA Switch";
-			expect(mockIPort.getNumber()).andReturn(portNum).anyTimes();
-			expect(mockIPort.getDesc()).andReturn(iPortDesc).anyTimes();
-			mockIPort.removeDevice(mockIDev);
-			mockIPort.removeDevice(mockIDev);
-			replay(mockIPort);
-			
-			//Make Iterator for mockIport
-			List<IPortObject> portList = new ArrayList<IPortObject>();
-			portList.add(mockIPort);
-			
-			//Expectation for mockIDeviceObject
-			expect(mockIDev.getAttachedPorts()).andReturn(portList).anyTimes();
-			mockIDev.setIPAddress(makeIPStringFromArray(ipaddrs));
-			mockIDev.setMACAddress(macAddr);
-			mockIDev.setType("device");
-			mockIDev.setState("ACTIVE");
-			replay(mockIDev);	
-			
-			//Mock IPortObject 2 with dpid "00:00:00:00:00:00:0a:02" and port "2"
-			IPortObject mockIPort2 = createMock(IPortObject.class);
-			mockIPort2.setNumber(portNum2);
-			mockIPort2.setType("port");
-			String iPortDesc2 = "port 2 at LAX Switch";
-			expect(mockIPort2.getNumber()).andReturn(portNum2).anyTimes();
-			expect(mockIPort2.getDesc()).andReturn(iPortDesc2).anyTimes();
-			mockIPort2.setDevice(mockIDev);
-			replay(mockIPort2);
-			
-			//Make Iterator for mockIport
-			List<IPortObject> portList2 = new ArrayList<IPortObject>();
-			portList2.add(mockIPort2);
-			
-			//Mock IPortObject 3 with dpid "00:00:00:00:00:00:00:00" and port "1"
-			IPortObject mockIPort3 = createMock(IPortObject.class);
-			mockIPort3.setNumber(portNum3);
-			mockIPort3.setType("port");
-			String iPortDesc3 = "n/a";
-			expect(mockIPort3.getNumber()).andReturn(portNum3).anyTimes();
-			expect(mockIPort3.getDesc()).andReturn(iPortDesc3).anyTimes();
-			mockIPort3.setDevice(mockIDev);
-			replay(mockIPort3);
-			
-			//Expectation for mockOpe
-			expect(mockOpe.searchDevice(macAddr)).andReturn(null);
-			expect(mockOpe.newDevice()).andReturn(mockIDev);
-			expect(mockOpe.searchPort(switchMacAddr, portNum)).andReturn(mockIPort);
-			mockOpe.commit();
-			expect(mockOpe.searchDevice(macAddr)).andReturn(mockIDev);
-			expect(mockOpe.searchPort(switchMacAddr2, portNum2)).andReturn(mockIPort2);
-			mockOpe.commit();
-			expect(mockOpe.searchDevice(macAddr)).andReturn(mockIDev);
-			expect(mockOpe.searchPort(switchMacAddr3, portNum3)).andReturn(null);
-			mockOpe.commit();
-			replay(mockOpe);				
-			
-			deviceImpl.init(conf);
-	
-	        IDeviceObject obj = deviceImpl.addDevice(mockDev);	
-			assertNotNull(obj);
-			
-		    deviceImpl.changeDeviceAttachments(mockDev2);
-			
-		    deviceImpl.changeDeviceAttachments(mockDev3);
-		    
-			verify(mockIDev);
-			verify(mockOpe);
-			
-		} catch(Exception e) {
-			fail(e.getMessage());
-		}
-	}
-
-	//@Ignore
-	@Test
-	public void testChangeDeviceAttachmentsIDeviceIDeviceObject() {
-		//It is tested by the testChangeDeviceAttachmentsIDevice
-		deviceImpl.init(conf);
-	}
-
-	/**
-	 * Desc:
-	 * 	Test method for testChangeDeviceIPv4Address
-	 * Condition:
-	 * 	N/A
-	 * Expect:
-	 *  1. Set the ipadress expectedly.
-	 */
-	//@Ignore
-	@Test
-	public void testChangeDeviceIPv4Address() {
-		try
-		{
-			//Dev1
-			IDevice mockDev = createMock(Device.class);
-			String macAddr = "99:99:99:99:99:99";
-			String ip = "192.168.100.1";
-			Integer ipInt = IPv4.toIPv4Address(ip);
-			Integer[] ipaddrs = {ipInt};
-			String switchMacAddr = "00:00:00:00:00:00:0a:01";		
-			long switchMacAddrL = HexString.toLong(switchMacAddr);
-			short portNum = 2; 
-			SwitchPort sp1 = new SwitchPort(switchMacAddrL, portNum);
-			SwitchPort[] sps = {sp1};
-			
-			expect(mockDev.getMACAddressString()).andReturn(macAddr).anyTimes();
-			expect(mockDev.getIPv4Addresses()).andReturn(ipaddrs);
-			expect(mockDev.getAttachmentPoints()).andReturn(sps);
-			replay(mockDev);
-			
-			//Dev2
-			IDevice mockDev2 = createMock(Device.class);
-			String ip2 = "192.168.100.2";
-			Integer ipInt2 = IPv4.toIPv4Address(ip2);
-			Integer[] ipaddrs2 = {ipInt2};
-			expect(mockDev2.getMACAddressString()).andReturn(macAddr);
-			expect(mockDev2.getIPv4Addresses()).andReturn(ipaddrs2);
-			replay(mockDev2);
-			
-			//Mock IPortObject 1 with dpid "00:00:00:00:00:00:0a:01" and port "1"
-			IPortObject mockIPort = createMock(IPortObject.class);
-			mockIPort.setNumber(portNum);
-			mockIPort.setType("port");
-			String iPortDesc = "port 1 at SEA Switch";
-			expect(mockIPort.getNumber()).andReturn(portNum).anyTimes();
-			expect(mockIPort.getDesc()).andReturn(iPortDesc).anyTimes();
-			replay(mockIPort);
-			
-			//Make Iterator for mockIport
-			List<IPortObject> portList = new ArrayList<IPortObject>();
-			portList.add(mockIPort);
-			
-			//Expectation for mockIDeviceObject
-			IDeviceObject mockIDev = createMock(IDeviceObject.class);	
-			expect(mockIDev.getAttachedPorts()).andReturn(portList);
-			mockIDev.setIPAddress(makeIPStringFromArray(ipaddrs));
-			mockIDev.setMACAddress(macAddr);
-			mockIDev.setType("device");
-			mockIDev.setState("ACTIVE");
-			mockIDev.setIPAddress(makeIPStringFromArray(ipaddrs2));
-			replay(mockIDev);	
-			
-			//Expectation for mockOpe
-			expect(mockOpe.searchDevice(macAddr)).andReturn(null);
-			expect(mockOpe.newDevice()).andReturn(mockIDev);
-			expect(mockOpe.searchPort(switchMacAddr, portNum)).andReturn(mockIPort);
-			mockOpe.commit();
-			expect(mockOpe.searchDevice(macAddr)).andReturn(mockIDev);
-			mockOpe.commit();
-			replay(mockOpe);				
-			
-			deviceImpl.init(conf);
-			
-	        IDeviceObject obj = deviceImpl.addDevice(mockDev);	
-			assertNotNull(obj);
-
-	        deviceImpl.changeDeviceIPv4Address(mockDev2);	
-	        
-			verify(mockIDev);
-			verify(mockOpe);
-					
-		} 
-		catch(Exception e) {
-			fail(e.getMessage());
-		}
-	}
-
-}
