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 2e9ea60..b12ccfa 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,10 +1,9 @@
 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;
+import net.onrc.onos.util.GraphDBConnection;
 import net.onrc.onos.util.GraphDBOperation;
 
 import org.openflow.protocol.OFPhysicalPort;
@@ -13,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:
@@ -38,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);
 
@@ -81,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);
 
@@ -183,36 +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) {
-		op = new GraphDBOperation(conf);
-	}
-
-
-
-	public void finalize() {
-		close();
-	}
-	
-	@Override
-	public void close() {
-		op.close();		
-	}
-
-	
-}
+}
\ No newline at end of file
diff --git a/src/test/java/net/floodlightcontroller/core/internal/TestDatabaseManager.java b/src/test/java/net/floodlightcontroller/core/internal/TestDatabaseManager.java
index 8a09139..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);
 	}
@@ -73,4 +82,4 @@
 		}
 	}
 	
-}
\ No newline at end of file
+}
diff --git a/src/test/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImplTest.java b/src/test/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImplTest.java
index ebfb532..daac980 100644
--- a/src/test/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImplTest.java
+++ b/src/test/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImplTest.java
@@ -1,278 +1,768 @@
 package net.onrc.onos.ofcontroller.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 static org.easymock.EasyMock.*;
 
 import net.onrc.onos.ofcontroller.core.ISwitchStorage;
 import net.onrc.onos.ofcontroller.core.ISwitchStorage.SwitchState;
-
+import net.onrc.onos.ofcontroller.core.internal.SwitchStorageImpl;
+import net.onrc.onos.util.GraphDBConnection;
+import net.onrc.onos.util.GraphDBOperation;
+import net.onrc.onos.ofcontroller.core.INetMapStorage.DM_OPERATION;
+import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
+import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
+import org.easymock.EasyMock;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.openflow.protocol.OFPhysicalPort;
+import org.openflow.protocol.OFPhysicalPort.OFPortState;
+import org.powermock.api.easymock.PowerMock;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.slf4j.LoggerFactory;
 
+import com.thinkaurelius.titan.core.TitanFactory;
 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;
-
-
+//Add Powermock preparation
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({TitanFactory.class, GraphDBConnection.class, GraphDBOperation.class, SwitchStorageImpl.class})
 public class SwitchStorageImplTest {
 
-	private ISwitchStorage switchStorage;
-	private TitanGraph titanGraph;
-	
+	protected static org.slf4j.Logger log = LoggerFactory.getLogger(SwitchStorageImpl.class);
+
+	String conf;
+    private GraphDBConnection mockConn = null;
+    private GraphDBOperation mockOpe = null;
+    private GraphDBOperation realOpe = null;
+    private TitanGraph titanGraph = null;
+    ISwitchStorage swSt = null;
+    
 	@Before
 	public void setUp() throws Exception {
-		titanGraph = TestDatabaseManager.getTestDatabase();
-		TestDatabaseManager.populateTestData(titanGraph);
 		
-		switchStorage = new TestableSwitchStorageImpl();
+		swSt = new SwitchStorageImpl();
+		conf = "/dummy/path/to/db";
+		
+        // Make mock cassandra DB
+		// Replace TitanFactory.open() to return mock DB
+
+		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.createStrictMock(GraphDBOperation.class);
+		PowerMock.expectNew(GraphDBOperation.class, mockConn).andReturn(mockOpe);
+		PowerMock.replay(GraphDBOperation.class);
+        // Replace the conf to dummy conf
+		// String conf = "/tmp/cassandra.titan";
+		
+
 	}
 
 	@After
 	public void tearDown() throws Exception {
-		titanGraph.shutdown();
+		swSt.close();
+		swSt = null;
+		
 	}
-
-	@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");
-	}
-
+	
+	/**
+	 * Desc:
+	 *  Test method for addSwitch method.
+	 * Condition:
+	 *  Normal
+	 * Expect:
+	 * 	Call SwitchStorageImpl.addSwitch func with proper properties.
+	 */
+	@Ignore 
 	@Test
 	public void testAddSwitch() {
 		String dpid = "00:00:00:00:00:00:0a:07";
+		String state = "ACTIVE";
 		
-		switchStorage.addSwitch(dpid);
+		//Mock Switch
+		ISwitchObject mockISw = createMock(ISwitchObject.class);
+		mockISw.setState(state);
+		replay(mockISw);
 		
-		Iterator<Vertex> it = titanGraph.getVertices("dpid", dpid).iterator();
-		assertTrue(it.hasNext());
-		Vertex addedSwitch = it.next();
-		assertFalse(it.hasNext());
+		//Expectation of mock operation.
+		expect(mockOpe.searchSwitch(dpid)).andReturn(null);
+		expect(mockOpe.newSwitch(dpid)).andReturn(mockISw);
+		mockOpe.commit();
+		mockOpe.close();
+		replay(mockOpe);
 		
-		assertEquals(addedSwitch.getProperty("type"), "switch");
-		assertEquals(addedSwitch.getProperty("dpid"), dpid);
-		assertEquals(addedSwitch.getProperty("state"), SwitchState.ACTIVE.toString());
+		swSt.init(conf);
+		swSt.addSwitch(dpid);
 	}
-
 	
+	/**
+	 * Desc:
+	 *  Test method for addSwitch method.
+	 * Condition:
+	 *  The switch is already existing.
+	 * Expect:
+	 * 	Call SwitchStorageImpl.addSwitch func with proper properties.
+	 */
+	//@Ignore 
+	@Test
+	public void testAddSwitchExisting() {
+		String dpid = "00:00:00:00:00:00:0a:07";
+		String state = "ACTIVE";
+		
+		//Mock Switch
+		ISwitchObject mockISw = createMock(ISwitchObject.class);
+		mockISw.setState(state);
+		mockISw.setState(state);
+		replay(mockISw);
+		
+		//Expectation of mock operation.
+		expect(mockOpe.searchSwitch(dpid)).andReturn(null);
+		expect(mockOpe.newSwitch(dpid)).andReturn(mockISw);
+		mockOpe.commit();
+		expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw);
+		mockOpe.commit();
+		mockOpe.close();
+		replay(mockOpe);
+		
+		swSt.init(conf);
+		swSt.addSwitch(dpid);
+		swSt.addSwitch(dpid);
+	}
+	
+	/**
+	 * Desc:
+	 *  Test method for addSwitch method.
+	 * Condition:
+	 *  The switch construction is fail and return null
+	 * Expect:
+	 * 	Write the status as info log.
+	 */
+	//@Ignore 
+	@Test
+	public void testAddSwitchAbnormal() {
+		String dpid = "00:00:00:00:00:00:0a:07";
+		
+		//Expectation of mock operation.
+		expect(mockOpe.searchSwitch(dpid)).andReturn(null);
+		expect(mockOpe.newSwitch(dpid)).andReturn(null);
+		mockOpe.close();
+		replay(mockOpe);
+		
+		swSt.init(conf);
+		swSt.addSwitch(dpid);
+	}
+	
+	/**
+	 * Desc:
+	 *  Test method for addSwitch method.
+	 * Condition:
+	 *  Tthrow runtimeException. 
+	 * Expect:
+	 * 	The rollback method is called.
+	 */
+	//@Ignore 
+	@Test
+	public void testAddSwitchException() {
+		String dpid = "00:00:00:00:00:00:0a:07";
+		String state = "ACTIVE";
+		
+		//Mock Switch
+		ISwitchObject mockISw = createMock(ISwitchObject.class);
+		mockISw.setState(state);
+		replay(mockISw);
+		
+		//Expectation of mock operation.
+		expect(mockOpe.searchSwitch(dpid)).andReturn(null);
+		expect(mockOpe.newSwitch(dpid)).andReturn(mockISw);
+		mockOpe.commit();
+		expectLastCall().andThrow(new RuntimeException());
+		mockOpe.rollback();
+		mockOpe.close();
+		replay(mockOpe);
+		
+		swSt.init(conf);
+		swSt.addSwitch(dpid);
+	}
+	
+	/**
+	 * Desc:
+	 *  Test method for updateSwitch method.
+	 * Condition:
+	 *  SwitchState : INACTIVE
+	 *  DMOPERATION : UPDATE
+	 * Expect:
+	 * 	Should call addSwitch function and commit.
+	 */
+	//@Ignore 
+	@Test
+	public void testUpdateUPDATE() {
+		String dpid = "00:00:00:00:00:00:0a:07";
+		SwitchState stateINACTIVE = SwitchState.INACTIVE;
+		DM_OPERATION opUPDATE = DM_OPERATION.UPDATE;
+		
+		//Mock Switch
+		ISwitchObject mockISw = createMock(ISwitchObject.class);
+		mockISw.setState("ACTIVE");
+		mockISw.setState(stateINACTIVE.toString());
+		replay(mockISw);
+		
+		//Expectation of mock operation.
+		expect(mockOpe.searchSwitch(dpid)).andReturn(null);
+		expect(mockOpe.newSwitch(dpid)).andReturn(mockISw);	
+		mockOpe.commit();
+		expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw);
+		mockOpe.commit();
+		mockOpe.close();
+		replay(mockOpe);
+		
+		swSt.init(conf);
+		swSt.update(dpid, stateINACTIVE, opUPDATE);
+	}
+	
+	/**
+	 * Desc:
+	 *  Test method for updateSwitch method.
+	 * Condition:
+	 *  SwitchState : INACTIVE
+	 *  DMOPERATION : CREATE
+	 * Expect:
+	 * 	Should call addSwitch function and commit.
+	 */
+	//@Ignore 
+	@Test
+	public void testUpdateCREATE() {
+		String dpid = "00:00:00:00:00:00:0a:07";
+		SwitchState stateINACTIVE = SwitchState.INACTIVE;
+		DM_OPERATION opCREATE = DM_OPERATION.CREATE;
+		
+		//Mock Switch
+		ISwitchObject mockISw = createMock(ISwitchObject.class);
+		mockISw.setState("ACTIVE");
+		mockISw.setState(stateINACTIVE.toString());
+		replay(mockISw);
+		
+		//Expectation of mock operation.
+		expect(mockOpe.searchSwitch(dpid)).andReturn(null);
+		expect(mockOpe.newSwitch(dpid)).andReturn(mockISw);	
+		mockOpe.commit();
+		expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw);
+		mockOpe.commit();
+		mockOpe.close();
+		replay(mockOpe);
+		
+		swSt.init(conf);
+		swSt.update(dpid, stateINACTIVE, opCREATE);
+	}
+	
+	/**
+	 * Desc:
+	 *  Test method for updateSwitch method.
+	 * Condition:
+	 *  SwitchState : INACTIVE
+	 *  DMOPERATION : INSERT
+	 * Expect:
+	 * 	Should call addSwitch function and commit.
+	 */
+	//@Ignore 
+	@Test
+	public void testUpdateINSERT() {
+		String dpid = "00:00:00:00:00:00:0a:07";
+		SwitchState stateINACTIVE = SwitchState.INACTIVE;
+		DM_OPERATION opINSERT = DM_OPERATION.INSERT;
+		
+		//Mock Switch
+		ISwitchObject mockISw = createMock(ISwitchObject.class);
+		mockISw.setState("ACTIVE");
+		mockISw.setState(stateINACTIVE.toString());
+		replay(mockISw);
+		
+		//Expectation of mock operation.
+		expect(mockOpe.searchSwitch(dpid)).andReturn(null);
+		expect(mockOpe.newSwitch(dpid)).andReturn(mockISw);
+		mockOpe.commit();
+		expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw);
+		mockOpe.commit();
+		mockOpe.close();
+		replay(mockOpe);
+		
+		swSt.init(conf);
+		swSt.update(dpid, stateINACTIVE, opINSERT);
+	}
+	
+	/**
+	 * Desc:
+	 *  Test method for updateSwitch method.
+	 * Condition:
+	 *  SwitchState : ACTIVE
+	 *  DMOPERATION : DELETE
+	 * Expect:
+	 * 	Should call removeSwitch function and commit.
+	 */
+	//@Ignore 
+	@Test
+	public void testUpdateDELETE() {
+		String dpid = "00:00:00:00:00:00:0a:07";
+		SwitchState stateACTIVE = SwitchState.ACTIVE;
+		DM_OPERATION opDELETE = DM_OPERATION.DELETE;
+		
+		//Mock Switch
+		ISwitchObject mockISw = createMock(ISwitchObject.class);
+		mockISw.setState(stateACTIVE.toString());
+		replay(mockISw);
+		
+		//Expectation of mock operation.
+		expect(mockOpe.searchSwitch(dpid)).andReturn(null);
+		expect(mockOpe.newSwitch(dpid)).andReturn(mockISw);
+		mockOpe.commit();
+		expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw);
+		mockOpe.removeSwitch(mockISw);
+		mockOpe.commit();
+		mockOpe.close();
+		replay(mockOpe);
+		
+		swSt.init(conf);
+		swSt.addSwitch(dpid);
+		swSt.update(dpid, stateACTIVE, opDELETE);
+	}
+	
+	/**
+	 * Desc:
+	 *  Test method for deleteSwitch method.
+	 * Condition:
+	 *  The switch is existing.
+	 * Expect:
+	 * 	Should call removeSwitch function and commit.
+	 */
+	//@Ignore
 	@Test
 	public void testDeleteSwitch() {
-		String dpid = "00:00:00:00:00:00:0a:01";
+		String dpid = "00:00:00:00:00:00:0a:07";
+		String state = "ACTIVE";
+	
+		//Mock Switch
+		ISwitchObject mockISw = createMock(ISwitchObject.class);
+		mockISw.setState(state);
+		replay(mockISw);
 		
-		switchStorage.deleteSwitch(dpid);
+		//Expectation of mock operation.
+		expect(mockOpe.searchSwitch(dpid)).andReturn(null);
+		expect(mockOpe.newSwitch(dpid)).andReturn(mockISw);
+		mockOpe.commit();
+		expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw);
+    	mockOpe.removeSwitch(mockISw);
+    	mockOpe.commit();
+		mockOpe.close();
+		replay(mockOpe);
 		
-		Iterator<Vertex> it = titanGraph.getVertices("dpid", dpid).iterator();
-		assertFalse(it.hasNext());
+		swSt.init(conf);
+		swSt.addSwitch(dpid);
+		swSt.deleteSwitch(dpid);
+		
+		//Iterator<Vertex> it = titanGraph.getVertices("dpid", dpid).iterator();
+		//assertFalse(it.hasNext());
 	}
-
+	
+	/**
+	 * Desc:
+	 *  Test method for deleteSwitch method.
+	 * Condition:
+	 *  The commit func throw exception.
+	 * Expect:
+	 * 	Should call rollback.
+	 */
+	//@Ignore
 	@Test
-	public void testDeletePortByPortNum() {
-		//FIXME fails because query for the port is wrong in SwitchStorageImpl
+	public void testDeleteSwitchException() {
+		String dpid = "00:00:00:00:00:00:0a:07";
+		String state = "ACTIVE";
+		String type = "";
 		
-		String dpid = "00:00:00:00:00:00:0a:01";
-		short portNum = 3;
+		//Mock Switch
+		ISwitchObject mockISw = createMock(ISwitchObject.class);
+		mockISw.setState(state);
+		replay(mockISw);
 		
-		switchStorage.deletePort(dpid, portNum);
+		//Expectation of mock operation.
+		expect(mockOpe.searchSwitch(dpid)).andReturn(null);
+		expect(mockOpe.newSwitch(dpid)).andReturn(mockISw);
+		mockOpe.commit();
+		expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw);
+    	mockOpe.removeSwitch(mockISw);
+    	mockOpe.commit();
+		expectLastCall().andThrow(new RuntimeException());
+		mockOpe.rollback();
+		mockOpe.close();
+		replay(mockOpe);
 		
-		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());
+		swSt.init(conf);
+		swSt.addSwitch(dpid);
+		swSt.deleteSwitch(dpid);
 	}
-
-	@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;
-	    }
-	}
-
+	
+	/**
+	 * Desc:
+	 *  Test method for addPort method.
+	 * Condition:
+	 *  port is existing.
+	 * Expect:
+	 * 	Should call addPort and commit.
+	 */
+	//@Ignore
 	@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";
+	public void testAddPort() {
+		String dpid = "00:00:00:00:00:00:0a:01";
+		short portNumber = 5;
+		String state = "ACTIVE";
+		String name = "port 5 at SEA switch";
+		
+		OFPhysicalPort portToAdd = new OFPhysicalPort();
+		portToAdd.setName(name);
+		portToAdd.setCurrentFeatures(OFPhysicalPort.OFPortFeatures.OFPPF_100MB_FD.getValue());
+		portToAdd.setPortNumber(portNumber);
+		portToAdd.setState(OFPortState.OFPPS_STP_FORWARD.getValue());
+		
+		//Expectation of  mock Port
+		IPortObject mockIPort = createMock(IPortObject.class);
+		mockIPort.setState(state);
+		mockIPort.setPortState(OFPortState.OFPPS_STP_FORWARD.getValue());
+		mockIPort.setDesc(name);
+		replay(mockIPort);
+		
+		//Expectation of mock Switch
+		ISwitchObject mockISw = createMock(ISwitchObject.class);
+		mockISw.setState(state);
+		mockISw.addPort(mockIPort);
+		replay(mockISw);
+		
+		//Expectation of mock operation.
+		expect(mockOpe.searchSwitch(dpid)).andReturn(null);
+		expect(mockOpe.newSwitch(dpid)).andReturn(mockISw);
+		mockOpe.commit();
+		expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw);
+		expect(mockOpe.searchPort(dpid, portNumber)).andReturn(null);
+		expect(mockOpe.newPort(portNumber)).andReturn(mockIPort);	
+		mockOpe.commit();
+		mockOpe.close();
+		replay(mockOpe);
 
-	    //
-	    // 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);
+		swSt.init(conf);
+		swSt.addSwitch(dpid);
+		swSt.addPort(dpid, portToAdd);
 	}
-}
+	
+	/**
+	 * Desc:
+	 *  Test method for addPort method.
+	 * Condition:
+	 *  Port status is down.
+	 * Expect:
+	 * 	Should call removePort and commit.
+	 */
+	//@Ignore
+	@Test
+	public void testAddPortWithPortLinkDown() {
+		String dpid = "00:00:00:00:00:00:0a:01";
+		short portNumber = 5;
+		String state = "ACTIVE";
+		String name = "port 5 at SEA switch";
+		
+		OFPhysicalPort portToAdd = new OFPhysicalPort();
+		portToAdd.setName(name);
+		portToAdd.setCurrentFeatures(OFPhysicalPort.OFPortFeatures.OFPPF_100MB_FD.getValue());
+		portToAdd.setPortNumber(portNumber);
+		portToAdd.setState(OFPortState.OFPPS_LINK_DOWN.getValue());
+		
+		//Expectation of  mock Port
+		IPortObject mockIPort = createMock(IPortObject.class);
+		mockIPort.setState(state);
+		mockIPort.setPortState(OFPortState.OFPPS_STP_FORWARD.getValue());
+		mockIPort.setDesc(name);
+		replay(mockIPort);
+		
+		//Expectation of mock Switch
+		ISwitchObject mockISw = createMock(ISwitchObject.class);
+		mockISw.setState(state);
+		mockISw.removePort(mockIPort);
+		replay(mockISw);
+		
+		//Expectation of mock operation.
+		expect(mockOpe.searchSwitch(dpid)).andReturn(null);
+		expect(mockOpe.newSwitch(dpid)).andReturn(mockISw);	
+		mockOpe.commit();	
+		expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw);
+		expect(mockOpe.searchPort(dpid, portNumber)).andReturn(mockIPort);
+		mockOpe.removePort(mockIPort);
+		mockOpe.commit();
+		mockOpe.close();
+		replay(mockOpe);
+
+		swSt.init(conf);
+		swSt.addSwitch(dpid);
+		swSt.addPort(dpid, portToAdd);
+	}
+	
+	/**
+	 * Desc:
+	 *  Test method for addPort method.
+	 * Condition:
+	 *  The switch is not existing.
+	 * Expect:
+	 * 	Nothing happens.
+	 */
+	//@Ignore
+	@Test
+	public void testAddPortAbnormalNoSwitch() {
+		String dpid = "00:00:00:00:00:00:0a:01";
+		short portNumber = 5;
+		String state = "ACTIVE";
+		String name = "port 5 at SEA switch";
+		
+		OFPhysicalPort portToAdd = new OFPhysicalPort();
+		portToAdd.setName(name);
+		portToAdd.setCurrentFeatures(OFPhysicalPort.OFPortFeatures.OFPPF_100MB_FD.getValue());
+		portToAdd.setPortNumber(portNumber);
+		portToAdd.setState(OFPortState.OFPPS_STP_FORWARD.getValue());
+		
+		//Expectation of  mock Port
+		IPortObject mockIPort = createStrictMock(IPortObject.class);
+		replay(mockIPort);
+		
+		//Expectation of mock Switch
+		ISwitchObject mockISw = createStrictMock(ISwitchObject.class);
+		replay(mockISw);
+		
+		//Expectation of mock operation.
+		expect(mockOpe.searchSwitch(dpid)).andReturn(null);
+		mockOpe.close();
+		replay(mockOpe);
+
+		swSt.init(conf);
+		swSt.addPort(dpid, portToAdd);
+	}
+	
+	/**
+	 * Desc:
+	 *  Test method for addPort method.
+	 * Condition:
+	 *  port is not existing.
+	 * Expect:
+	 * 	Should call addPort and commit.
+	 */
+	//@Ignore
+	@Test
+	public void testAddPortAbnormalNoPort() {
+		String dpid = "00:00:00:00:00:00:0a:01";
+		short portNumber = 5;
+		String state = "ACTIVE";
+		String name = "port 5 at SEA switch";
+		
+		OFPhysicalPort portToAdd = new OFPhysicalPort();
+		portToAdd.setName(name);
+		portToAdd.setCurrentFeatures(OFPhysicalPort.OFPortFeatures.OFPPF_100MB_FD.getValue());
+		portToAdd.setPortNumber(portNumber);
+		portToAdd.setState(OFPortState.OFPPS_STP_FORWARD.getValue());
+		
+		//Expectation of  mock Port
+		IPortObject mockIPort = createMock(IPortObject.class);
+		mockIPort.setState(state);
+		mockIPort.setPortState(OFPortState.OFPPS_STP_FORWARD.getValue());
+		mockIPort.setDesc(name);
+		replay(mockIPort);
+		
+		//Expectation of mock Switch
+		ISwitchObject mockISw = createMock(ISwitchObject.class);
+		mockISw.setState(state);
+		mockISw.addPort(mockIPort);
+		replay(mockISw);
+		
+		//Expectation of mock operation.
+		expect(mockOpe.searchSwitch(dpid)).andReturn(null);
+		expect(mockOpe.newSwitch(dpid)).andReturn(mockISw);
+		mockOpe.commit();
+		expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw);
+		expect(mockOpe.searchPort(dpid, portNumber)).andReturn(null);
+		expect(mockOpe.newPort(portNumber)).andReturn(null);	
+		mockOpe.rollback();
+		mockOpe.close();
+		replay(mockOpe);
+
+		swSt.init(conf);
+		swSt.addSwitch(dpid);
+		swSt.addPort(dpid, portToAdd);
+	}
+	
+	/**
+	 * Desc:
+	 *  Test method for addPort method.
+	 * Condition:
+	 *  commit throw the exception.
+	 * Expect:
+	 * 	Should call rollback.
+	 */
+	//@Ignore
+	@Test
+	public void testAddPortWithException() {
+		String dpid = "00:00:00:00:00:00:0a:01";
+		short portNumber = 5;
+		String state = "ACTIVE";
+		String name = "port 5 at SEA switch";
+		
+		OFPhysicalPort portToAdd = new OFPhysicalPort();
+		portToAdd.setName(name);
+		portToAdd.setCurrentFeatures(OFPhysicalPort.OFPortFeatures.OFPPF_100MB_FD.getValue());
+		portToAdd.setPortNumber(portNumber);
+		portToAdd.setState(OFPortState.OFPPS_STP_FORWARD.getValue());
+		
+		//Expectation of  mock Port
+		IPortObject mockIPort = createMock(IPortObject.class);
+		mockIPort.setState(state);
+		mockIPort.setPortState(OFPortState.OFPPS_STP_FORWARD.getValue());
+		mockIPort.setDesc(name);
+		replay(mockIPort);
+		
+		//Expectation of mock Switch
+		ISwitchObject mockISw = createMock(ISwitchObject.class);
+		mockISw.setState(state);
+		mockISw.addPort(mockIPort);
+		replay(mockISw);
+		
+		//Expectation of mock operation.
+		expect(mockOpe.searchSwitch(dpid)).andReturn(null);
+		expect(mockOpe.newSwitch(dpid)).andReturn(mockISw);
+		mockOpe.commit();
+		expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw);
+		expect(mockOpe.searchPort(dpid, portNumber)).andReturn(null);
+		expect(mockOpe.newPort(portNumber)).andReturn(mockIPort);	
+		mockOpe.commit();
+		expectLastCall().andThrow(new RuntimeException());
+		mockOpe.rollback();
+		mockOpe.close();
+		replay(mockOpe);
+
+		swSt.init(conf);
+		swSt.addSwitch(dpid);
+		swSt.addPort(dpid, portToAdd);
+	}
+
+	/**
+	 * Desc:
+	 *  Test method for deletePort method.
+	 * Condition:
+	 *  port is existing.
+	 * Expect:
+	 * 	Should call removePort and commit.
+	 */
+	//@Ignore
+	@Test
+	public void testDeletePort() {
+		String dpid = "00:00:00:00:00:00:0a:01";
+		short portNumber = 5;
+		String state = "ACTIVE";
+		String name = "port 5 at SEA switch";
+		
+		OFPhysicalPort portToAdd = new OFPhysicalPort();
+		portToAdd.setName(name);
+		portToAdd.setCurrentFeatures(OFPhysicalPort.OFPortFeatures.OFPPF_100MB_FD.getValue());
+		portToAdd.setPortNumber(portNumber);
+		portToAdd.setState(OFPortState.OFPPS_STP_FORWARD.getValue());
+		
+		//Expectation of  mock Port
+		IPortObject mockIPort = createMock(IPortObject.class);
+		mockIPort.setState(state);
+		mockIPort.setPortState(OFPortState.OFPPS_STP_FORWARD.getValue());
+		mockIPort.setDesc(name);
+		replay(mockIPort);
+		
+		//Expectation of mock Switch
+		ISwitchObject mockISw = createMock(ISwitchObject.class);
+		mockISw.setState(state);
+		mockISw.addPort(mockIPort);
+		mockISw.removePort(mockIPort);
+		replay(mockISw);
+		
+		//Expectation of mock operation.
+		expect(mockOpe.searchSwitch(dpid)).andReturn(null);
+		expect(mockOpe.newSwitch(dpid)).andReturn(mockISw);
+		mockOpe.commit();
+		expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw);
+		expect(mockOpe.searchPort(dpid, portNumber)).andReturn(null);
+		expect(mockOpe.newPort(portNumber)).andReturn(mockIPort);	
+		mockOpe.commit();
+		expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw);
+		expect(mockOpe.searchPort(dpid, portNumber)).andReturn(mockIPort);
+		mockOpe.removePort(mockIPort);
+		mockOpe.commit();
+		mockOpe.close();
+		replay(mockOpe);
+
+		swSt.init(conf);
+		swSt.addSwitch(dpid);
+		swSt.addPort(dpid, portToAdd);
+		swSt.deletePort(dpid, portNumber);
+	}
+
+	/**
+	 * Desc:
+	 *  Test method for addPort method.
+	 * Condition:
+	 *  commit throws the exception.
+	 * Expect:
+	 * 	Should call rollback.
+	 */
+	//@Ignore
+	@Test
+	public void testDeletePortException() {
+		String dpid = "00:00:00:00:00:00:0a:01";
+		short portNumber = 5;
+		String state = "ACTIVE";
+		String name = "port 5 at SEA switch";
+		
+		OFPhysicalPort portToAdd = new OFPhysicalPort();
+		portToAdd.setName(name);
+		portToAdd.setCurrentFeatures(OFPhysicalPort.OFPortFeatures.OFPPF_100MB_FD.getValue());
+		portToAdd.setPortNumber(portNumber);
+		portToAdd.setState(OFPortState.OFPPS_STP_FORWARD.getValue());
+		
+		//Expectation of  mock Port
+		IPortObject mockIPort = createMock(IPortObject.class);
+		mockIPort.setState(state);
+		mockIPort.setPortState(OFPortState.OFPPS_STP_FORWARD.getValue());
+		mockIPort.setDesc(name);
+		replay(mockIPort);
+		
+		//Expectation of mock Switch
+		ISwitchObject mockISw = createMock(ISwitchObject.class);
+		mockISw.setState(state);
+		mockISw.addPort(mockIPort);
+		mockISw.removePort(mockIPort);
+		replay(mockISw);
+		
+		//Expectation of mock operation.
+		expect(mockOpe.searchSwitch(dpid)).andReturn(null);
+		expect(mockOpe.newSwitch(dpid)).andReturn(mockISw);
+		mockOpe.commit();
+		expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw);
+		expect(mockOpe.searchPort(dpid, portNumber)).andReturn(null);
+		expect(mockOpe.newPort(portNumber)).andReturn(mockIPort);	
+		mockOpe.commit();
+		expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw);
+		expect(mockOpe.searchPort(dpid, portNumber)).andReturn(mockIPort);
+		mockOpe.removePort(mockIPort);
+		expectLastCall().andThrow(new RuntimeException());
+		mockOpe.rollback();
+		mockOpe.close();
+		replay(mockOpe);
+	
+		swSt.init(conf);
+		swSt.addSwitch(dpid);
+		swSt.addPort(dpid, portToAdd);
+		swSt.deletePort(dpid, portNumber);
+	}
+}
\ No newline at end of file
diff --git a/src/test/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImplTestBB.java b/src/test/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImplTestBB.java
new file mode 100644
index 0000000..f6f70ae
--- /dev/null
+++ b/src/test/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImplTestBB.java
@@ -0,0 +1,334 @@
+package net.onrc.onos.ofcontroller.core.internal;
+
+import static org.junit.Assert.*;
+
+import net.floodlightcontroller.core.internal.TestDatabaseManager;
+import net.onrc.onos.ofcontroller.core.ISwitchStorage;
+import net.onrc.onos.ofcontroller.core.ISwitchStorage.SwitchState;
+import net.onrc.onos.ofcontroller.core.internal.SwitchStorageImpl;
+import net.onrc.onos.util.GraphDBConnection;
+import net.onrc.onos.util.GraphDBOperation;
+import net.onrc.onos.ofcontroller.core.INetMapStorage;
+import net.onrc.onos.ofcontroller.core.INetMapStorage.DM_OPERATION;
+import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
+import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
+import org.easymock.EasyMock;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openflow.protocol.OFPhysicalPort;
+import org.openflow.protocol.OFPhysicalPort.OFPortState;
+import org.powermock.api.easymock.PowerMock;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.slf4j.LoggerFactory;
+
+import com.thinkaurelius.titan.core.TitanFactory;
+import com.thinkaurelius.titan.core.TitanGraph;
+
+//Add Powermock preparation
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({TitanFactory.class, GraphDBConnection.class, GraphDBOperation.class, SwitchStorageImpl.class})
+public class SwitchStorageImplTestBB {
+
+	protected static org.slf4j.Logger log = LoggerFactory.getLogger(SwitchStorageImpl.class);
+
+	String conf;
+    private GraphDBConnection conn = null;
+    private GraphDBOperation ope = null;
+    private TitanGraph titanGraph = null;
+    ISwitchStorage swSt = null;
+    
+	@Before
+	public void setUp() throws Exception {
+		
+		swSt = new SwitchStorageImpl();
+		conf = "/dummy/path/to/db";
+		
+		// Make mock cassandra DB
+		// Replace TitanFactory.open() to return mock DB
+		titanGraph = TestDatabaseManager.getTestDatabase();
+		TestDatabaseManager.populateTestData(titanGraph);
+		PowerMock.mockStatic(TitanFactory.class);
+		EasyMock.expect(TitanFactory.open((String)EasyMock.anyObject())).andReturn(titanGraph);
+		PowerMock.replay(TitanFactory.class);
+		
+		conn = GraphDBConnection.getInstance(conf);
+		ope = new GraphDBOperation(conn);
+		
+		swSt.init(conf);
+	}
+
+	@After
+	public void tearDown() throws Exception {
+		
+		titanGraph.shutdown();
+		TestDatabaseManager.deleteTestDatabase();
+
+		swSt.close();
+		swSt = null;
+	}
+	
+	/**
+	 * Desc:
+	 *  Test method for addSwitch method.
+	 * Condition:
+	 *  Normal
+	 * Expect:
+	 * 1. Switch should be generated.
+	 * 2. The status of switch should be ACTIVE
+	 */
+	//@Ignore 
+	@Test
+	public void testAddSwitch() {
+		String dpid = "00:00:00:00:00:00:0a:07";
+		
+		ISwitchObject sw = ope.searchSwitch(dpid);
+		assertTrue(sw == null);
+		swSt.addSwitch(dpid);
+		ISwitchObject sw2 = ope.searchSwitch(dpid);
+		assertTrue(sw2 != null);
+		assertEquals(sw2.getState(), "ACTIVE");
+	}
+	
+	/**
+	 * Desc:
+	 *  Test method for addSwitch method.
+	 * Condition:
+	 *  The existing switch status is INACTIVE.
+	 *  The switch is already existing.
+	 * Expect:
+	 * 1. After add the same switch, the status of switch should be ACTIVE
+	 */
+	//@Ignore 
+	@Test
+	public void testAddSwitchExisting() {
+		String dpid = "00:00:00:00:00:00:0a:06";
+		
+		swSt.update(dpid, SwitchState.INACTIVE, DM_OPERATION.UPDATE);
+		ISwitchObject sw = ope.searchSwitch(dpid);
+		assertTrue(sw != null);
+		assertEquals(sw.getState(), SwitchState.INACTIVE.toString());
+		swSt.addSwitch(dpid);
+		ISwitchObject sw2 = ope.searchSwitch(dpid);
+		assertTrue(sw2 != null);
+		assertEquals(sw2.getState(), SwitchState.ACTIVE.toString());
+	}
+	
+	/**
+	 * Desc:
+	 *  Test method for testUpdate method.
+	 * Condition:
+	 *  The switch is not existing.
+	 *  The status of added switch is INACTIVE.
+	 *  DM_OPERATION is CREATE.
+	 * Expect:
+	 * 1. Switch should be created.
+	 * 2. The status of switch should be INACTIVE.
+	 */
+	//@Ignore 
+	@Test
+	public void testUpdate() {
+		String dpid = "00:00:00:00:00:00:0a:07";
+		SwitchState state = ISwitchStorage.SwitchState.INACTIVE;
+		DM_OPERATION dmope = INetMapStorage.DM_OPERATION.CREATE;
+		
+		ISwitchObject sw = ope.searchSwitch(dpid);
+		assertTrue(sw == null);
+		swSt.update(dpid, state, dmope);
+		ISwitchObject sw2 = ope.searchSwitch(dpid);
+		assertTrue(sw2 != null);
+		assertEquals(sw2.getState(), state.toString());
+	}
+	
+	/**
+	 * Desc:
+	 *  Test method for testUpdate method.
+	 * Condition:
+	 *  The switch is existing.
+	 *  The status of added switch is ACTIVE.
+	 *  DM_OPERATION is DELETE.
+	 * Expect:
+	 * 1. Switch should be deleted.
+	 */
+	//@Ignore 
+	@Test
+	public void testUpdateWithDELETE() {
+		String dpid = "00:00:00:00:00:00:0a:06";
+		SwitchState state = ISwitchStorage.SwitchState.ACTIVE;
+		DM_OPERATION dmope = INetMapStorage.DM_OPERATION.DELETE;
+		
+		ISwitchObject sw = ope.searchSwitch(dpid);
+		assertTrue(sw != null);
+		swSt.update(dpid, state, dmope);
+		ISwitchObject sw2 = ope.searchSwitch(dpid);
+		assertTrue(sw2 == null);
+	}
+	
+	/**
+	 * Desc:
+	 *  Test method for delete switch method.
+	 * Condition:
+	 *  The switch is existing.
+	 * Expect:
+	 * 1. Switch should be deleted.
+	 */
+	//@Ignore 
+	@Test
+	public void testDeleteSwitch() {
+		String dpid = "00:00:00:00:00:00:0a:06";
+		
+		ISwitchObject sw = ope.searchSwitch(dpid);
+		assertTrue(sw != null);
+		swSt.deleteSwitch(dpid);
+		ISwitchObject sw2 = ope.searchSwitch(dpid);
+		assertTrue(sw2 == null);
+	}
+	
+	/**
+	 * Desc:
+	 *  Test method for delete switch method.
+	 * Condition:
+	 *  The switch is not existing.
+	 * Expect:
+	 * Nothing happens.
+	 */
+	//@Ignore 
+	@Test
+	public void testDeleteNonExistingSwitch() {
+		String dpid = "00:00:00:00:00:00:0a:07";
+		
+		ISwitchObject sw = ope.searchSwitch(dpid);
+		assertTrue(sw == null);
+		swSt.deleteSwitch(dpid);
+		ISwitchObject sw2 = ope.searchSwitch(dpid);
+		assertTrue(sw2 == null);
+	}
+	
+	/**
+	 * Desc:
+	 *  Test method for delete port method.
+	 * Condition:
+	 *  The port is existing.
+	 * Expect:
+	 *  Deleted the port.
+	 */
+	//@Ignore 
+	@Test
+	public void testDeletePort() {
+		String dpid = "00:00:00:00:00:00:0a:06";
+		short portNumber = 3;
+		
+		IPortObject portObj1 = ope.searchPort(dpid, portNumber);
+		assertTrue(portObj1 != null);
+		swSt.deletePort(dpid, portNumber);
+		IPortObject portObj2 = ope.searchPort(dpid, portNumber);
+		assertTrue(portObj2 == null);
+	}
+	
+	/**
+	 * Desc:
+	 *  Test method for delete port method.
+	 * Condition:
+	 *  The port is not existing.
+	 * Expect:
+	 *  Nothing happens.
+	 */
+	//@Ignore 
+	@Test
+	public void testDeleteNonExistingPort() {
+		String dpid = "00:00:00:00:00:00:0a:06";
+		short portNumber = 4;
+		
+		IPortObject portObj1 = ope.searchPort(dpid, portNumber);
+		assertTrue(portObj1 == null);
+		swSt.deletePort(dpid, portNumber);
+		IPortObject portObj2 = ope.searchPort(dpid, portNumber);
+		assertTrue(portObj2 == null);
+	}
+	
+	/**
+	 * Desc:
+	 *  Test method for add port method.
+	 * Condition:
+	 *  The port is not existing.
+	 * Expect:
+	 *  The port should be added.
+	 *  The desc of IPortObject is the same as the name of OFPhysicalPort.
+	 */
+	//@Ignore 
+	@Test
+	public void testAddPort() {
+		String dpid = "00:00:00:00:00:00:0a:06";
+		short portNumber = 4;
+		String name = "port 4 at ATL Switch";
+		int state = OFPortState.OFPPS_STP_FORWARD.getValue();
+		OFPhysicalPort port = new OFPhysicalPort(); 
+		port.setPortNumber(portNumber);
+		port.setName(name);
+		port.setState(state);
+		
+		ISwitchObject sw = ope.searchSwitch(dpid);
+		assertTrue(sw != null);
+		swSt.addPort(dpid, port);
+		IPortObject portObj = ope.searchPort(dpid, portNumber);
+		assertTrue(portObj != null);
+		assertEquals(portObj.getDesc(), name);
+	}
+	
+	/**
+	 * Desc:
+	 *  Test method for add method.
+	 * Condition:
+	 *  The port is existing.
+	 * Expect:
+	 *  Nothing happens.
+	 */
+	//@Ignore 
+	@Test
+	public void testAddExistingPort() {
+		String dpid = "00:00:00:00:00:00:0a:06";
+		short portNumber = 3;
+		String name = "xxx";
+		int state = OFPortState.OFPPS_STP_FORWARD.getValue();
+		OFPhysicalPort port = new OFPhysicalPort(); 
+		port.setPortNumber(portNumber);
+		port.setName(name);
+		port.setState(state);
+		
+		ISwitchObject sw = ope.searchSwitch(dpid);
+		assertTrue(sw != null);
+		swSt.addPort(dpid, port);
+		IPortObject portObj = ope.searchPort(dpid, portNumber);
+		assertTrue(portObj != null);
+	}
+	
+	/**
+	 * Desc:
+	 *  Test method for add method.
+	 * Condition:
+	 *  The port status is down.
+	 * Expect:
+	 *  Delete the port.
+	 */
+	//@Ignore 
+	@Test
+	public void testAddDownPort() {
+		String dpid = "00:00:00:00:00:00:0a:06";
+		short portNumber = 3;
+		String name = "port 3 at ATL Switch";
+		int state = OFPortState.OFPPS_LINK_DOWN.getValue();
+		OFPhysicalPort port = new OFPhysicalPort(); 
+		port.setPortNumber(portNumber);
+		port.setName(name);
+		port.setState(state);
+		
+		ISwitchObject sw = ope.searchSwitch(dpid);
+		assertTrue(sw != null);
+		swSt.addPort(dpid, port);
+		IPortObject portObj = ope.searchPort(dpid, portNumber);
+		assertTrue(portObj == null);
+	}
+}
diff --git a/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceStorageImplTest.java b/src/test/java/net/onrc/onos/ofcontroller/devicemanager/internal/DeviceStorageImplTest.java
similarity index 98%
rename from src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceStorageImplTest.java
rename to src/test/java/net/onrc/onos/ofcontroller/devicemanager/internal/DeviceStorageImplTest.java
index fc37016..5cdcbb5 100644
--- a/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceStorageImplTest.java
+++ b/src/test/java/net/onrc/onos/ofcontroller/devicemanager/internal/DeviceStorageImplTest.java
@@ -1,4 +1,4 @@
-package net.floodlightcontroller.devicemanager.internal;
+package net.onrc.onos.ofcontroller.devicemanager.internal;
 
 import static org.easymock.EasyMock.createMock;
 import static org.easymock.EasyMock.expect;
@@ -20,10 +20,11 @@
 import net.onrc.onos.ofcontroller.core.internal.SwitchStorageImpl;
 import net.onrc.onos.util.GraphDBConnection;
 import net.onrc.onos.util.GraphDBOperation;
-
+import net.floodlightcontroller.devicemanager.internal.Device;
 import org.easymock.EasyMock;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.openflow.util.HexString;
@@ -32,7 +33,6 @@
 import org.powermock.modules.junit4.PowerMockRunner;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
 import com.thinkaurelius.titan.core.TitanFactory;
 
 //Add Powermock preparation
@@ -49,7 +49,9 @@
     
 	@Before
 	public void setUp() throws Exception {
-
+	    deviceImpl = new DeviceStorageImpl();	
+		conf = "/dummy/path/to/db";
+				
 		PowerMock.mockStatic(GraphDBConnection.class);
 		mockConn = createMock(GraphDBConnection.class);
 		PowerMock.suppress(PowerMock.constructor(GraphDBConnection.class));
@@ -58,19 +60,22 @@
 			
 		//PowerMock.mockStatic(GraphDBOperation.class);
 		mockOpe = PowerMock.createMock(GraphDBOperation.class);
-		PowerMock.expectNew(GraphDBOperation.class, mockConn).andReturn(mockOpe);
+		PowerMock.expectNew(GraphDBOperation.class, new Class<?>[]{String.class}, conf).andReturn(mockOpe);
+		mockOpe.close();
 		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;
+		
+		verify(mockOpe);
 	}
 	
 	private String makeIPStringFromArray(Integer[] ipaddresses){
@@ -148,7 +153,6 @@
 			expect(mockOpe.newDevice()).andReturn(mockIDev);
 			expect(mockOpe.searchPort(switchMacAddr, portNum)).andReturn(mockIPort);
 			mockOpe.commit();
-
 			replay(mockOpe);				
 			
 			deviceImpl.init(conf);
@@ -158,7 +162,6 @@
 			assertNotNull(obj);
 			
 			verify(mockIDev);
-			verify(mockOpe);
 			
 		} catch(Exception e) {
 			fail(e.getMessage());
@@ -239,10 +242,7 @@
 			//Add the same device
 	        IDeviceObject obj2 = deviceImpl.addDevice(mockDev);
 			assertNotNull(obj2);
-			
-			verify(mockIDev);
-			verify(mockOpe);
-			
+
 		} catch(Exception e) {
 			fail(e.getMessage());
 		}
@@ -335,7 +335,6 @@
 			assertNotNull(obj2);
 			
 			verify(mockIDev);
-			verify(mockOpe);
 			
 		} catch(Exception e) {
 			fail(e.getMessage());
@@ -429,7 +428,7 @@
 		    assertNull(dev2);
 		    
 			verify(mockIDev);
-			verify(mockOpe);
+
 		} catch(Exception e) {
 			fail(e.getMessage());
 		}
@@ -511,7 +510,7 @@
 		    assertNotNull(dev);
 		    
 			verify(mockIDev);
-			verify(mockOpe);   
+
 		} catch(Exception e) {
 			fail(e.getMessage());
 		}
@@ -600,7 +599,7 @@
 		    assertNotNull(dev);
 		    
 			verify(mockIDev);
-			verify(mockOpe);
+
 			
 		} catch(Exception e) {
 			fail(e.getMessage());
@@ -735,18 +734,17 @@
 		    deviceImpl.changeDeviceAttachments(mockDev3);
 		    
 			verify(mockIDev);
-			verify(mockOpe);
+
 			
 		} catch(Exception e) {
 			fail(e.getMessage());
 		}
 	}
 
-	//@Ignore
+	@Ignore
 	@Test
 	public void testChangeDeviceAttachmentsIDeviceIDeviceObject() {
 		//It is tested by the testChangeDeviceAttachmentsIDevice
-		deviceImpl.init(conf);
 	}
 
 	/**
@@ -828,7 +826,7 @@
 	        deviceImpl.changeDeviceIPv4Address(mockDev2);	
 	        
 			verify(mockIDev);
-			verify(mockOpe);
+
 					
 		} 
 		catch(Exception e) {
diff --git a/src/test/java/net/onrc/onos/ofcontroller/devicemanager/internal/DeviceStorageImplTestBB.java b/src/test/java/net/onrc/onos/ofcontroller/devicemanager/internal/DeviceStorageImplTestBB.java
new file mode 100644
index 0000000..cea70f0
--- /dev/null
+++ b/src/test/java/net/onrc/onos/ofcontroller/devicemanager/internal/DeviceStorageImplTestBB.java
@@ -0,0 +1,626 @@
+package net.onrc.onos.ofcontroller.devicemanager.internal;
+
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+import java.util.List;
+
+import net.floodlightcontroller.core.internal.TestDatabaseManager;
+import net.floodlightcontroller.devicemanager.IDevice;
+import net.floodlightcontroller.devicemanager.SwitchPort;
+import net.floodlightcontroller.devicemanager.internal.Device;
+import net.floodlightcontroller.packet.IPv4;
+import net.onrc.onos.ofcontroller.core.IDeviceStorage;
+import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IDeviceObject;
+import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
+import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
+import net.onrc.onos.ofcontroller.core.internal.DeviceStorageImpl;
+import net.onrc.onos.ofcontroller.core.internal.SwitchStorageImpl;
+import net.onrc.onos.util.GraphDBConnection;
+import net.onrc.onos.util.GraphDBOperation;
+
+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.slf4j.LoggerFactory;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.thinkaurelius.titan.core.TitanFactory;
+import com.thinkaurelius.titan.core.TitanGraph;
+
+//Add Powermock preparation
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({TitanFactory.class, GraphDBConnection.class, GraphDBOperation.class, SwitchStorageImpl.class})
+public class DeviceStorageImplTestBB {
+	protected static org.slf4j.Logger log = LoggerFactory.getLogger(SwitchStorageImpl.class);
+
+	String conf;
+    private GraphDBConnection conn = null;
+    private GraphDBOperation ope = null;
+    private TitanGraph titanGraph = null;
+    IDeviceStorage deviceImpl = null;
+    
+	@Before
+	public void setUp() throws Exception {
+		
+		deviceImpl = new DeviceStorageImpl();
+		conf = "/dummy/path/to/db";
+		
+		// Make mock cassandra DB
+		// Replace TitanFactory.open() to return mock DB
+		titanGraph = TestDatabaseManager.getTestDatabase();
+		TestDatabaseManager.populateTestData(titanGraph);
+		PowerMock.mockStatic(TitanFactory.class);
+		EasyMock.expect(TitanFactory.open((String)EasyMock.anyObject())).andReturn(titanGraph);
+		PowerMock.replay(TitanFactory.class);
+		
+		conn = GraphDBConnection.getInstance(conf);
+		ope = new GraphDBOperation(conn);
+		
+		deviceImpl.init(conf);
+	}
+
+	@After
+	public void tearDown() throws Exception {
+		titanGraph.shutdown();
+		TestDatabaseManager.deleteTestDatabase();
+
+		deviceImpl.close();
+		deviceImpl = null;
+	}
+
+	/**
+	 * Desc:
+	 *  Test method for addDevice method.
+	 * Codition:
+	 *  N/A
+	 * Expect:
+	 * 	Get proper IDeviceObject
+	 *  Check the IDeviceObject properties set
+	 */
+	@Test
+	public void testAddDevice() {
+		try 
+		{	   
+			//Make mockDevice
+			IDevice mockDev = EasyMock.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 ipInt = IPv4.toIPv4Address(ip);
+			Integer[] ipaddrs = {ipInt};
+			// 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};
+
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getIPv4Addresses()).andReturn(ipaddrs);
+			EasyMock.expect(mockDev.getAttachmentPoints()).andReturn(sps);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+
+			EasyMock.replay(mockDev);
+
+			//Add the device
+	        IDeviceObject obj = deviceImpl.addDevice(mockDev);	
+			assertNotNull(obj);
+
+			//Test to take a Device from DB correctly
+			IDeviceObject devObj1 = ope.searchDevice(macAddr);
+			assertEquals(macAddr, devObj1.getMACAddress());
+
+			//Test to take a attached sw  from DB correctly
+			for(ISwitchObject sw1: devObj1.getSwitch())
+			{
+				String swMacFromDB = sw1.getDPID();
+				assertEquals(switchMacAddr, swMacFromDB);
+			}
+
+			//Test to take a IP addr from DB
+			//TodoForGettingIPaddr. There may be bug in the test class.
+			String ipFromDB = devObj1.getIPAddress();
+			String[] ipsFromDB = ipFromDB.replace("[", "").replace("]", "").split(",");
+			List<String> ipsList = Arrays.asList(ipsFromDB);
+			assertTrue(ipsList.contains(ip));
+
+			//Test to take a attached port from DB
+			for(IPortObject port : devObj1.getAttachedPorts())
+			{
+
+				//In this implementing, the object was not set the port. So it must be null.
+				if(port.getNumber() != null)
+				{
+					String portNumFromDB = port.getNumber().toString();
+					assertEquals(String.valueOf(portNum), portNumFromDB);				
+				}
+			}	
+		} 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.
+	 */
+	@Test
+	public void testAddDeviceExisting() {
+		try 
+		{	   
+			IDevice mockDev = EasyMock.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};
+
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getIPv4Addresses()).andReturn(ipaddrs);
+			EasyMock.expect(mockDev.getAttachmentPoints()).andReturn(sps);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getIPv4Addresses()).andReturn(ipaddrs);
+			EasyMock.expect(mockDev.getAttachmentPoints()).andReturn(sps);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.replay(mockDev);
+
+			//Add the device
+	        IDeviceObject obj = deviceImpl.addDevice(mockDev);	
+			assertNotNull(obj);
+
+			//Test to take a Device from DB correctly
+			IDeviceObject devObj1 = ope.searchDevice(macAddr);
+			assertEquals(macAddr, devObj1.getMACAddress());
+
+			//Add the same device
+	        IDeviceObject obj2 = deviceImpl.addDevice(mockDev);	
+			assertNotNull(obj2);
+
+			IDeviceObject devObj2 = ope.searchDevice(macAddr);
+			assertEquals(macAddr, devObj2.getMACAddress());	
+
+			//Test to take a attached port from DB
+			for(IPortObject port : devObj2.getAttachedPorts())
+			{
+				//In this implementing, the object was not set the port. So it must be null.
+				if(port.getNumber() != null)
+				{
+
+					String portNumFromDB = port.getNumber().toString();
+					assertEquals(String.valueOf(portNum), portNumFromDB);						
+
+					ISwitchObject sw = port.getSwitch();
+					String str = sw.getDPID();
+					log.debug("");
+				}
+			}	
+
+			String ipFromDB = devObj2.getIPAddress();
+			String[] ipsFromDB = ipFromDB.replace("[", "").replace("]", "").split(",");
+			List<String> ipsList = Arrays.asList(ipsFromDB);
+			assertTrue(ipsList.contains(ip));
+
+			//Test to take a attached port from DB
+			for(IPortObject port : devObj2.getAttachedPorts())
+			{
+
+				//In this implementing, the object was not set the port. So it must be null.
+				if(port.getNumber() != null)
+				{
+					String portNumFromDB = port.getNumber().toString();
+					assertEquals(String.valueOf(portNum), portNumFromDB);				
+				}
+			}	
+		} 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 properly.
+	 */
+	//@Ignore
+	@Test
+	public void testUpdateDevice() {
+		try
+		{
+			IDevice mockDev = EasyMock.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};
+
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getIPv4Addresses()).andReturn(ipaddrs);
+			EasyMock.expect(mockDev.getAttachmentPoints()).andReturn(sps);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.replay(mockDev);
+
+			//Dev2 (attached port is the same)
+			IDevice mockDev2 = EasyMock.createMock(Device.class);
+			String macAddr2 = "99:aa:aa:aa:aa:aa";
+			Integer ip2 = IPv4.toIPv4Address("192.168.100.2");
+			Integer[] ipaddrs2 = {ip2};
+
+			EasyMock.expect(mockDev2.getMACAddressString()).andReturn(macAddr2);
+			EasyMock.expect(mockDev2.getMACAddressString()).andReturn(macAddr2);
+			EasyMock.expect(mockDev2.getMACAddressString()).andReturn(macAddr2);
+			EasyMock.expect(mockDev2.getMACAddressString()).andReturn(macAddr2);
+			EasyMock.expect(mockDev2.getIPv4Addresses()).andReturn(ipaddrs2);
+			EasyMock.expect(mockDev2.getAttachmentPoints()).andReturn(sps);
+			EasyMock.expect(mockDev2.getMACAddressString()).andReturn(macAddr2);
+			EasyMock.expect(mockDev2.getMACAddressString()).andReturn(macAddr2);
+			EasyMock.replay(mockDev2);
+
+	        IDeviceObject obj = deviceImpl.addDevice(mockDev);	
+			assertNotNull(obj);
+
+			IDeviceObject dev1 = ope.searchDevice(macAddr);
+			assertEquals(macAddr, dev1.getMACAddress());
+
+			//update theDevice
+			deviceImpl.updateDevice(mockDev2);
+			IDeviceObject dev2 = ope.searchDevice(macAddr2);
+			assertEquals(macAddr2, dev2.getMACAddress());
+			IPortObject iport = ope.searchPort(switchMacAddr, portNum);
+
+			//Test to take a attached port from DB
+			for(IDeviceObject dev : iport.getDevices())
+			{
+				String macAddrFromDB = dev.getMACAddress();	
+				if(macAddr2.equals(macAddrFromDB)){
+					//Nothing to do
+				}
+				else{
+					fail("notFoundTheDeviceOnThePort");			
+				}
+			}
+
+		} 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 = EasyMock.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};
+
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getAttachmentPoints()).andReturn(sps);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getIPv4Addresses()).andReturn(ipaddrs);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.replay(mockDev);
+
+	        IDeviceObject obj = deviceImpl.addDevice(mockDev);	
+			assertNotNull(obj);
+
+			IDeviceObject dev1 = ope.searchDevice(macAddr);
+			assertEquals(macAddr, dev1.getMACAddress());
+
+			deviceImpl.removeDevice(mockDev);		
+		    IDeviceObject dev = deviceImpl.getDeviceByMac(macAddr);
+		    assertNull(dev);
+
+		} 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.
+	 */
+	//@Ignore
+	@Test
+	public void testGetDeviceByMac() {
+		try
+		{
+			IDevice mockDev = EasyMock.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};
+
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getIPv4Addresses()).andReturn(ipaddrs);
+			EasyMock.expect(mockDev.getAttachmentPoints()).andReturn(sps);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.replay(mockDev);
+
+	        IDeviceObject obj = deviceImpl.addDevice(mockDev);	
+			assertNotNull(obj);
+
+			IDeviceObject dev1 = ope.searchDevice(macAddr);
+			assertEquals(macAddr, dev1.getMACAddress());
+
+		    IDeviceObject dev = deviceImpl.getDeviceByMac(macAddr);
+		    assertNotNull(dev);
+			assertEquals(macAddr, dev.getMACAddress());
+
+		} 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.
+	 */
+	//@Ignore
+	@Test
+	public void testGetDeviceByIP() {
+		try
+		{
+			IDevice mockDev = EasyMock.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};
+
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getIPv4Addresses()).andReturn(ipaddrs);
+			EasyMock.expect(mockDev.getAttachmentPoints()).andReturn(sps);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.replay(mockDev);
+
+	        IDeviceObject obj = deviceImpl.addDevice(mockDev);	
+			assertNotNull(obj);
+
+			IDeviceObject dev1 = ope.searchDevice(macAddr);
+			assertEquals(macAddr, dev1.getMACAddress());
+
+		    IDeviceObject dev = deviceImpl.getDeviceByIP(ip);
+		    assertNotNull(dev);
+			String ipFromDB = dev.getIPAddress();
+			String[] ipsFromDB = ipFromDB.replace("[", "").replace("]", "").split(",");
+			List<String> ipsList = Arrays.asList(ipsFromDB);
+			assertTrue(ipsList.contains(ip));
+
+		} catch(Exception e) {
+			fail(e.getMessage());
+		}
+	}
+
+	/**
+	 * Desc:
+	 * 	Test method for testChangeDeviceAttachmentsIDevice
+	 * Condition:
+	 * 	1. Unexisting attachment point argument is set
+	 * Expect:
+	 * 	1. Unexisting attachment point is ignored, so nothing happen.
+	 * 	2. Change the attachment point.
+	 */
+	//@Ignore
+	@Test
+	public void testChangeDeviceAttachmentsIDevice() {
+		try
+		{
+			IDevice mockDev = EasyMock.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};
+
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getIPv4Addresses()).andReturn(ipaddrs);
+			EasyMock.expect(mockDev.getAttachmentPoints()).andReturn(sps);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.replay(mockDev);
+
+			//Dev2
+			IDevice mockDev2 = EasyMock.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};
+
+			EasyMock.expect(mockDev2.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev2.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev2.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev2.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev2.getIPv4Addresses()).andReturn(ipaddrs);
+			EasyMock.expect(mockDev2.getAttachmentPoints()).andReturn(sps2);
+			EasyMock.expect(mockDev2.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev2.getMACAddressString()).andReturn(macAddr);
+			EasyMock.replay(mockDev2);
+
+	        IDeviceObject obj = deviceImpl.addDevice(mockDev);	
+			assertNotNull(obj);
+
+		    deviceImpl.changeDeviceAttachments(mockDev2);
+
+		    IDeviceObject dev = deviceImpl.getDeviceByMac(macAddr);
+		    assertNotNull(dev);
+
+			for(ISwitchObject sw1: dev.getSwitch())
+			{
+				String swMacFromDB = sw1.getDPID();
+				assertEquals(switchMacAddr2, swMacFromDB);
+			}
+		} catch(Exception e) {
+			fail(e.getMessage());
+		}
+	}
+
+	//@Ignore
+	@Test
+	public void testChangeDeviceAttachmentsIDeviceIDeviceObject() {
+		//It is tested by the testChangeDeviceAttachmentsIDevice
+	}
+
+	/**
+	 * Desc:
+	 * 	Test method for testChangeDeviceIPv4Address
+	 * Condition:
+	 * 	N/A
+	 * Expect:
+	 *  1. Check correctly changed the ipadress
+	 */
+	//@Ignore
+	@Test
+	public void testChangeDeviceIPv4Address() {
+		try
+		{
+			//Dev1
+			IDevice mockDev = EasyMock.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};
+
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getIPv4Addresses()).andReturn(ipaddrs);
+			EasyMock.expect(mockDev.getAttachmentPoints()).andReturn(sps);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			EasyMock.replay(mockDev);
+
+	        IDeviceObject obj = deviceImpl.addDevice(mockDev);	
+			assertNotNull(obj);
+
+			IDevice mockDev2 = EasyMock.createMock(Device.class);
+			String ip2 = "192.168.100.2";
+			Integer ipInt2 = IPv4.toIPv4Address(ip2);
+			Integer[] ipaddrs2 = {ipInt2};
+			EasyMock.expect(mockDev2.getMACAddressString()).andReturn(macAddr);
+			EasyMock.expect(mockDev2.getIPv4Addresses()).andReturn(ipaddrs2);
+			EasyMock.replay(mockDev2);
+
+			IDeviceObject dev1 = ope.searchDevice(macAddr);
+			assertEquals(macAddr, dev1.getMACAddress());
+			String ipFromDB = dev1.getIPAddress();
+			String[] ipsFromDB = ipFromDB.replace("[", "").replace("]", "").split(",");
+			List<String> ipsList = Arrays.asList(ipsFromDB);
+			assertTrue(ipsList.contains(ip));
+
+	        deviceImpl.changeDeviceIPv4Address(mockDev2);	
+
+			IDeviceObject dev2 = ope.searchDevice(macAddr);
+			assertEquals(macAddr, dev2.getMACAddress());
+			String ipFromDB2 = dev2.getIPAddress();
+			String[] ipsFromDB2 = ipFromDB2.replace("[", "").replace("]", "").split(",");
+			List<String> ipsList2 = Arrays.asList(ipsFromDB2);
+			assertTrue(ipsList2.contains(ip2));
+		} 
+		catch(Exception e) {
+			fail(e.getMessage());
+		}
+	}
+
+}
