Add the switchStorageImpl unit tests.
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/ISwitchStorage.java b/src/main/java/net/onrc/onos/ofcontroller/core/ISwitchStorage.java
index d008220..79a4f76 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/core/ISwitchStorage.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/core/ISwitchStorage.java
@@ -23,18 +23,6 @@
 	/*
 	 * Get all ports associated on a switch
 	 */
-	public Collection<OFPhysicalPort> getPorts(long dpid);
-	/*
-	 * Get Port by Number
-	 */
-	public OFPhysicalPort getPort(String dpid, short portnum);
-	/*
-	 * Get port by name
-	 */
-	public OFPhysicalPort getPort(String dpid, String portName);
-	/*
-	 * Add a switch
-	 */
 	public void addSwitch(String dpid);
 	/*
 	 * Delete switch and associated ports
@@ -45,12 +33,6 @@
 	 */
 	public void deletePort(String dpid, short port);
 	/*
-	 * Delete port on a switch by name
-	 */
-	public void deletePort(String dpid, String portName);
-	
-	
-	/*
 	 * Initialize
 	 */
 	public void init(String conf);
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImpl.java b/src/main/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImpl.java
index ea7fdf0..ec0c993 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImpl.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImpl.java
@@ -1,7 +1,5 @@
 package net.onrc.onos.ofcontroller.core.internal;
 
-import java.util.Collection;
-
 import net.onrc.onos.ofcontroller.core.ISwitchStorage;
 import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
 import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
@@ -14,16 +12,99 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+/**
+ * This is the class for storing the information of switches into CassandraDB
+ */
 public class SwitchStorageImpl implements ISwitchStorage {
 	protected GraphDBOperation op;
 	protected static Logger log = LoggerFactory.getLogger(SwitchStorageImpl.class);
-
+	
+	/***
+	 * Initialize function. Before you use this class, please call this method
+	 * @param conf configuration file for Cassandra DB
+	 */
 	@Override
-	public void update(String dpid, SwitchState state, DM_OPERATION op) {
-		// TODO Auto-generated method stub
-		log.info("SwitchStorage:update dpid:{} state: {} ", dpid, state);
-        switch(op) {
+	public void init(String conf) {
+		GraphDBConnection conn = GraphDBConnection.getInstance(conf);
+		op = new GraphDBOperation(conn);
+	}
 
+	/***
+	 * Finalize/close function. After you use this class, please call this method.
+	 * It will close the DB connection.
+	 */
+	public void finalize() {
+		close();
+	}
+	
+	/***
+	 * Finalize/close function. After you use this class, please call this method.
+	 * It will close the DB connection. This is for Java gabage collection.
+	 */
+	@Override
+	public void close() {
+		op.close();		
+	}
+	
+	private void setStatus(String dpid, SwitchState state) {
+		ISwitchObject sw = op.searchSwitch(dpid);
+		
+		try {
+			if (sw != null) {
+				sw.setState(state.toString());
+				op.commit();
+				log.info("SwitchStorage:setStatus dpid:{} state: {} done", dpid, state);
+			}
+		} catch(Exception e) {
+			e.printStackTrace();
+			op.rollback();
+			log.info("SwitchStorage:setStatus dpid:{} state: {} failed: switch not found", dpid, state);	
+		}
+	}
+
+	/***
+	 * This function is for adding the switch into the DB.
+	 * @param dpid The switch dpid you want to add into the DB.
+	 */
+	@Override
+	public void addSwitch(String dpid) {
+		
+		log.info("SwitchStorage:addSwitch(): dpid {} ", dpid);
+		try {
+			ISwitchObject sw = op.searchSwitch(dpid);
+			if (sw != null) {
+				//If existing the switch. set The SW state ACTIVE. 
+				log.info("SwitchStorage:addSwitch dpid:{} already exists", dpid);
+				sw.setState(SwitchState.ACTIVE.toString());
+				op.commit();
+			} else {
+				sw = op.newSwitch(dpid);
+
+				if (sw != null) {
+					sw.setState(SwitchState.ACTIVE.toString());
+					op.commit();
+					log.info("SwitchStorage:addSwitch dpid:{} added", dpid);
+				} else {
+					log.error("switchStorage:addSwitch dpid:{} failed -> newSwitch failed", dpid);
+				}
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+			op.rollback();
+			log.info("SwitchStorage:addSwitch dpid:{} failed", dpid);
+		}
+	}
+	
+	/***
+	 * This function is for updating the switch into the DB.
+	 * @param dpid The switch dpid you want to update from the DB
+	 * @param state The state of the switch like ACTIVE, INACTIVE
+	 * @param dmope	The DM_OPERATION of the switch
+	 */
+	@Override
+	public void update(String dpid, SwitchState state, DM_OPERATION dmope) {
+		log.info("SwitchStorage:update dpid:{} state: {} ", dpid, state);
+        switch(dmope) {
         	case UPDATE:
         	case INSERT:
         	case CREATE:
@@ -39,29 +120,41 @@
         }
 	}
 
-	private void setStatus(String dpid, SwitchState state) {
-		ISwitchObject sw = op.searchSwitch(dpid);
-		if (sw != null) {
-			sw.setState(state.toString());
-			op.commit();
-			log.info("SwitchStorage:setStatus dpid:{} state: {} done", dpid, state);
-		} 	else {
-			op.rollback();
-			log.info("SwitchStorage:setStatus dpid:{} state: {} failed: switch not found", dpid, state);
+	/***
+	 * This function is for deleting the switch into the DB.
+	 * @param dpid The switch dpid you want to delete from the DB.
+	 */
+	@Override
+	public void deleteSwitch(String dpid) {
+		try {
+			ISwitchObject sw = op.searchSwitch(dpid);
+            if (sw  != null) {
+            	op.removeSwitch(sw);
+            	op.commit();
+            	log.info("SwitchStorage:DeleteSwitch dpid:{} done", dpid);
+            }
+		} catch (Exception e) {
+			e.printStackTrace();
+			op.rollback();			
+			log.error("SwitchStorage:deleteSwitch {} failed", dpid);
 		}
+
 	}
 
+	/***
+	 * This function is for adding the switch port into the DB.
+	 * @param dpid The switch dpid that has the port.
+	 * @param port The port you want to add the switch.
+	 */
 	@Override
 	public void addPort(String dpid, OFPhysicalPort port) {
-		// TODO Auto-generated method stub
 		
-        boolean portDown = ((OFPortConfig.OFPPC_PORT_DOWN.getValue() & port.getConfig()) > 0) ||
-        		((OFPortState.OFPPS_LINK_DOWN.getValue() & port.getState()) > 0);
-       if (portDown) {
-             deletePort(dpid, port.getPortNumber());
-             return;
+       if(((OFPortConfig.OFPPC_PORT_DOWN.getValue() & port.getConfig()) > 0) ||
+        					((OFPortState.OFPPS_LINK_DOWN.getValue() & port.getState()) > 0)) {
+    	     deletePort(dpid, port.getPortNumber());
+             return;  
        }
-             
+
 		try {
 			ISwitchObject sw = op.searchSwitch(dpid);
 
@@ -82,95 +175,20 @@
         		log.error("SwitchStorage:addPort dpid:{} port:{} : failed switch does not exist", dpid, port.getPortNumber());
             }
 		} catch (Exception e) {
-             // TODO: handle exceptions
 			e.printStackTrace();
 			op.rollback();
 			log.error("SwitchStorage:addPort dpid:{} port:{} failed", dpid, port.getPortNumber());
 		}	
 
 	}
-
-	@Override
-	public Collection<OFPhysicalPort> getPorts(long dpid) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public OFPhysicalPort getPort(String dpid, short portnum) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public OFPhysicalPort getPort(String dpid, String portName) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public void addSwitch(String dpid) {
-		
-		log.info("SwitchStorage:addSwitch(): dpid {} ", dpid);
-		
-		try {
-			ISwitchObject sw = op.searchSwitch(dpid);
-			if (sw != null) {
-				/*
-				 *  Do nothing or throw exception?
-				 */
-
-				log.info("SwitchStorage:addSwitch dpid:{} already exists", dpid);
-				sw.setState(SwitchState.ACTIVE.toString());
-				op.commit();
-			} else {
-				sw = op.newSwitch(dpid);
-
-				if (sw != null) {
-					sw.setState(SwitchState.ACTIVE.toString());
-					op.commit();
-					log.info("SwitchStorage:addSwitch dpid:{} added", dpid);
-				} else {
-					log.error("switchStorage:addSwitch dpid:{} failed -> newSwitch failed", dpid);
-				}
-			}
-		} catch (Exception e) {
-			/*
-			 * retry?
-			 */
-			e.printStackTrace();
-			op.rollback();
-			log.info("SwitchStorage:addSwitch dpid:{} failed", dpid);
-		}
-
-
-	}
-
-	@Override
-	public void deleteSwitch(String dpid) {
-		// TODO Setting inactive but we need to eventually remove data
-
-		try {
-
-			ISwitchObject sw = op.searchSwitch(dpid);
-            if (sw  != null) {
-            	op.removeSwitch(sw);
- 
-            	op.commit();
-            	log.info("SwitchStorage:DeleteSwitch dpid:{} done", dpid);
-            }
-		} catch (Exception e) {
-             // TODO: handle exceptions
-			e.printStackTrace();
-			op.rollback();			
-			log.error("SwitchStorage:deleteSwitch {} failed", dpid);
-		}
-
-	}
-
+	
+	/***
+	 * This function is for deleting the switch port from the DB.
+	 * @param dpid The switch dpid that has the port.
+	 * @param port The port you want to delete the switch.
+	 */
 	@Override
 	public void deletePort(String dpid, short port) {
-		// TODO Auto-generated method stub
 		try {
 			ISwitchObject sw = op.searchSwitch(dpid);
 
@@ -184,37 +202,9 @@
             	}
             }
 		} catch (Exception e) {
-             // TODO: handle exceptions
 			e.printStackTrace();
 			op.rollback();
 			log.info("SwitchStorage:deletePort dpid:{} port:{} failed", dpid, port);
 		}	
 	}
-
-	@Override
-	public void deletePort(String dpid, String portName) {
-		// TODO Auto-generated method stub
-
-	}
-
-
-
-	@Override
-	public void init(String conf) {
-		GraphDBConnection conn = GraphDBConnection.getInstance(conf);
-		op = new GraphDBOperation(conn);
-	}
-
-
-
-	public void finalize() {
-		close();
-	}
-	
-	@Override
-	public void close() {
-		op.close();		
-	}
-
-	
 }
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());
-		}
-	}
-
-}