2nd iteration of the unit test.
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjects.java b/src/main/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjects.java
index 1a01155..77c42b1 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjects.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjects.java
@@ -94,6 +94,10 @@
 		@JsonIgnore
 		@Incidence(label="on",direction = Direction.IN)
 		public ISwitchObject getSwitch();
+		
+		@JsonIgnore
+		@Adjacency(label="on",direction = Direction.IN)
+		public ISwitchObject getVertexSwitch();
 				
 		@JsonProperty("devices")
 		@Adjacency(label="host")
@@ -139,11 +143,11 @@
 		@JsonProperty("ipv4")
 		@Property("nw_addr")
 		public String getIPAddress();
-		@Property("dl_addr")
+		@Property("nw_addr")
 		public void setIPAddress(String ipaddr);
 		
 		@JsonIgnore
-		@Incidence(label="host",direction = Direction.IN)
+		@Adjacency(label="host",direction = Direction.IN)
 		public Iterable<IPortObject> getAttachedPorts();
 			
 		@JsonIgnore
diff --git a/src/main/java/net/onrc/onos/ofcontroller/devicemanager/internal/DeviceStorageImpl.java b/src/main/java/net/onrc/onos/ofcontroller/devicemanager/internal/DeviceStorageImpl.java
index cca4794..98b4a88 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/devicemanager/internal/DeviceStorageImpl.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/devicemanager/internal/DeviceStorageImpl.java
@@ -1,5 +1,6 @@
 package net.onrc.onos.ofcontroller.devicemanager.internal;
 
+import java.util.ArrayList;
 import java.util.List;
 import org.openflow.util.HexString;
 import org.slf4j.Logger;
@@ -9,149 +10,259 @@
 import com.thinkaurelius.titan.core.TitanException;
 import net.floodlightcontroller.devicemanager.IDevice;
 import net.floodlightcontroller.devicemanager.SwitchPort;
+import net.floodlightcontroller.packet.IPv4;
 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.IDeviceStorage;
 import net.onrc.onos.util.GraphDBConnection;
+import net.onrc.onos.util.GraphDBConnection.Transaction;
 import net.onrc.onos.util.GraphDBOperation;
 
+/**
+ * This is the class for storing the information of devices into CassandraDB
+ * @author Pankaj
+ */
 public class DeviceStorageImpl implements IDeviceStorage {
 	
-	public GraphDBOperation op;
+	private GraphDBConnection conn;
+	private GraphDBOperation ope;
 	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 init(String conf) {
-		op = new GraphDBOperation(GraphDBConnection.getInstance(conf));
+		try{
+			if((conn = GraphDBConnection.getInstance(conf)) != null)
+			{
+				ope = new GraphDBOperation(conn);
+			}
+		} catch(Exception e) {
+			log.error(e.getMessage());
+		}
 	}	
-
-	public void finalize() {		
-		close();
-	}
 	
+	/***
+	 * Finalize/close function. After you use this class, please call this method.
+	 * It will close the DB connection.
+	 */
 	@Override
 	public void close() {
-		op.close();
+		conn.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 finalize() {
+		close();
 	}
 
+	/***
+	 * This function is for adding the device into the DB.
+	 * @param device The device you want to add into the DB.
+	 * @return IDeviceObject which was added in the DB. 
+	 */
 	@Override
 	public IDeviceObject addDevice(IDevice device) {
-		// TODO Auto-generated method stub
 		IDeviceObject obj = null;
  		try {
-            if ((obj = op.searchDevice(device.getMACAddressString())) != null) {
-                log.debug("Adding device {}: found existing device",device.getMACAddressString());
+ 			if ((obj = ope.searchDevice(device.getMACAddressString())) != null) {
+ 				log.debug("Adding device {}: found existing device",device.getMACAddressString());
             } else {
-            	obj = op.newDevice();
+            	obj = ope.newDevice();
                 log.debug("Adding device {}: creating new device",device.getMACAddressString());
             }
-            changeDeviceAttachments(device, obj);
-            
- 			obj.setIPAddress(device.getIPv4Addresses().toString());
- 			obj.setMACAddress(device.getMACAddressString());
- 			obj.setState("ACTIVE");
- 			op.commit();
+	            changeDeviceAttachments(device, obj);
+	
+				String multiIntString = "";
+				for(Integer intValue : device.getIPv4Addresses()) {
+				   if (multiIntString == null || multiIntString.isEmpty()){
+				     multiIntString = IPv4.fromIPv4Address(intValue);
+				     multiIntString = "[" + IPv4.fromIPv4Address(intValue);
+				   }else{
+				        multiIntString += "," + IPv4.fromIPv4Address(intValue);
+				   }
+				}
+	 	            
+	            if(multiIntString.toString() != null && !multiIntString.toString().isEmpty()){
+	            	obj.setIPAddress(multiIntString + "]");
+	            }
+	            
+	 			obj.setMACAddress(device.getMACAddressString());
+	 			obj.setType("device");
+	 			obj.setState("ACTIVE");
+	 			ope.commit();
  			
- 			log.debug("Adding device {}",device.getMACAddressString());
+	 			log.debug("Adding device {}",device.getMACAddressString());
 		} catch (Exception e) {
-            // TODO: handle exceptions
-          	op.rollback();
+			ope.rollback();
 			log.error(":addDevice mac:{} failed", device.getMACAddressString());
+			obj = null;
 		}	
-		
-		return obj;
+ 			return obj;		
 	}
 
+	/***
+	 * This function is for updating the Device properties.
+	 * @param device The device you want to add into the DB.
+	 * @return IDeviceObject which was added in the DB. 
+	 */
 	@Override
 	public IDeviceObject updateDevice(IDevice device) {
 		return addDevice(device);
 	}
 
+	/***
+	 * This function is for removing the Device from the DB.
+	 * @param device The device you want to delete from the DB.
+	 */
 	@Override
 	public void removeDevice(IDevice device) {
-		// TODO Auto-generated method stub
 		IDeviceObject dev;
 		try {
-			if ((dev = op.searchDevice(device.getMACAddressString())) != null) {
-             	op.removeDevice(dev);
-              	op.commit();
+			if ((dev = ope.searchDevice(device.getMACAddressString())) != null) {
+             	ope.removeDevice(dev);
+             	ope.commit();
             	log.error("DeviceStorage:removeDevice mac:{} done", device.getMACAddressString());
             }
 		} catch (Exception e) {
-             // TODO: handle exceptions
-          	op.rollback();
+			ope.rollback();
 			log.error("DeviceStorage:removeDevice mac:{} failed", device.getMACAddressString());
 		}
 	}
 
+	/***
+	 * This function is for getting the Device from the DB by Mac address of the device.
+	 * @param mac The device mac address you want to get from the DB.
+	 * @return IDeviceObject you want to get.
+	 */
 	@Override
 	public IDeviceObject getDeviceByMac(String mac) {
-		return op.searchDevice(mac);
+		return ope.searchDevice(mac);
 	}
 
+	/***
+	 * This function is for getting the Device from the DB by IP address of the device.
+	 * @param ip The device ip address you want to get from the DB.
+	 * @return IDeviceObject you want to get.
+	 */
 	@Override
 	public IDeviceObject getDeviceByIP(String ip) {
-		// TODO Auto-generated method stub
-		return null;
+		try
+		{
+			for(IDeviceObject dev : ope.getDevices()){
+				String ips;
+				if((ips = dev.getIPAddress()) != null){
+					String nw_addr_wob = ips.replace("[", "").replace("]", "");
+					ArrayList<String> iplists = Lists.newArrayList(nw_addr_wob.split(","));	
+					if(iplists.contains(ip)){
+						return dev;
+					}
+				}
+			}
+			return null;
+		}
+		catch (Exception e)
+		{
+			log.error("DeviceStorage:getDeviceByIP:{} failed");
+			return null;
+		}
 	}
 
+	/***
+	 * This function is for changing the Device attachment point.
+	 * @param device The device you want change the attachment point
+	 */
 	@Override
 	public void changeDeviceAttachments(IDevice device) {
-		// TODO Auto-generated method stub
 		IDeviceObject obj = null;
  		try {
-            if ((obj = op.searchDevice(device.getMACAddressString())) != null) {
+            if ((obj = ope.searchDevice(device.getMACAddressString())) != null) {
                 log.debug("Changing device ports {}: found existing device",device.getMACAddressString());
                 changeDeviceAttachments(device, obj);
-     			op.commit();
-           } else {
+                ope.commit();
+            } else {
    				log.debug("failed to search device...now adding {}",device.getMACAddressString());
    				addDevice(device);
-           }            			
+            }            			
 		} catch (Exception e) {
-            // TODO: handle exceptions
-          	op.rollback();
+			ope.rollback();
 			log.error(":addDevice mac:{} failed", device.getMACAddressString());
 		}	
 	}
 	
+	/***
+	 * This function is for changing the Device attachment point.
+	 * @param device The new device you want change the attachment point
+	 * @param obj The old device IDeviceObject that is going to change the attachment point.
+	 */
 	public void changeDeviceAttachments(IDevice device, IDeviceObject obj) {
 		SwitchPort[] attachmentPoints = device.getAttachmentPoints();
 		List<IPortObject> attachedPorts = Lists.newArrayList(obj.getAttachedPorts());
-
+		
         for (SwitchPort ap : attachmentPoints) {
-       	 IPortObject port = op.searchPort(
-       			 HexString.toHexString(ap.getSwitchDPID()),
-       			 (short) ap.getPort());
-       	if (attachedPorts.contains(port)) {
-       		attachedPorts.remove(port);
-       	} else {
-               log.debug("Adding device {}: attaching to port",device.getMACAddressString());
-               port.setDevice(obj);
-       		//obj.setHostPort(port);
-       	}            		
-       }
-       for (IPortObject port: attachedPorts) {
+        	//Check weather there is the port
+          	 IPortObject port = ope.searchPort( HexString.toHexString(ap.getSwitchDPID()),
+												(short) ap.getPort());
+          	 log.debug("New Switch Port is {},{}", HexString.toHexString(ap.getSwitchDPID()),(short) ap.getPort());
+	       	 
+	       	 if(port != null){
+	   			if(attachedPorts.contains(port))
+	       		{
+		       		log.debug("This is the port you already attached {}: do nothing",device.getMACAddressString());
+		       		//This port will be remained, so remove from the removed port lists.
+		       		attachedPorts.remove(port);
+		       	} else {
+	     		   log.debug("Adding device {}: attaching to port",device.getMACAddressString());
+		       		port.setDevice(obj);  
+		        }
+	    	
+		       	log.debug("port number is {}", port.getNumber().toString());
+		        log.debug("port desc is {}", port.getDesc());  
+	       	 }
+        }      		 
+	            
+	    for (IPortObject port: attachedPorts) {
+            log.debug("Detouching the device {}: detouching from port",device.getMACAddressString());
        		port.removeDevice(obj);
-       	//	obj.removeHostPort(port);
-       }	
+        }
 	}
 
+	/***
+	 * This function is for changing the Device IPv4 address.
+	 * @param device The new device you want change the ipaddress
+	 */
 	@Override
 	public void changeDeviceIPv4Address(IDevice device) {
-		// TODO Auto-generated method stub
 		IDeviceObject obj;
   		try {
-  			if ((obj = op.searchDevice(device.getMACAddressString())) != null) {
-            	obj.setIPAddress(device.getIPv4Addresses().toString());
-              	op.commit(); 
+  			if ((obj = ope.searchDevice(device.getMACAddressString())) != null) {
+
+  				String multiIntString = "";
+  				for(Integer intValue : device.getIPv4Addresses()){
+  				   if (multiIntString == null || multiIntString.isEmpty()){
+  				     multiIntString = "[" + IPv4.fromIPv4Address(intValue);
+  				   } else {
+  				        multiIntString += "," + IPv4.fromIPv4Address(intValue);
+  				   }
+  				}
+  				
+  	            if(multiIntString != null && !multiIntString.isEmpty()){
+  	            	obj.setIPAddress(multiIntString + "]");
+  	            }
+  	            
+              	ope.commit();
   			} else {
             	log.error(":changeDeviceIPv4Address mac:{} failed", device.getMACAddressString());
-             }		
+            }		
   		} catch (TitanException e) {
-            // TODO: handle exceptions
-          	op.rollback();
+  			ope.rollback();
 			log.error(":changeDeviceIPv4Address mac:{} failed due to exception {}", device.getMACAddressString(),e);
 		}
 	}
diff --git a/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceStorageImplTest.java b/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceStorageImplTest.java
new file mode 100644
index 0000000..bedee03
--- /dev/null
+++ b/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceStorageImplTest.java
@@ -0,0 +1,881 @@
+package net.floodlightcontroller.devicemanager.internal;
+
+import static org.junit.Assert.*;
+import static org.easymock.EasyMock.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javassist.bytecode.Descriptor.Iterator;
+
+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.SwitchStorageImpl;
+import net.onrc.onos.ofcontroller.devicemanager.internal.DeviceStorageImpl;
+import net.onrc.onos.util.GraphDBConnection;
+import net.onrc.onos.util.GraphDBConnection.Transaction;
+import net.onrc.onos.util.GraphDBOperation;
+import net.floodlightcontroller.core.internal.TestDatabaseManager;
+import net.floodlightcontroller.devicemanager.IDevice;
+import net.floodlightcontroller.devicemanager.SwitchPort;
+import net.floodlightcontroller.flowcache.FlowReconcileManager;
+import net.floodlightcontroller.packet.IPacket;
+import net.floodlightcontroller.packet.IPv4;
+import net.floodlightcontroller.storage.memory.MemoryStorageSource;
+
+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.OFPacketIn;
+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;
+import com.thinkaurelius.titan.core.TitanGraph;
+import com.tinkerpop.blueprints.Vertex;
+import com.tinkerpop.gremlin.java.GremlinPipeline;
+
+//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);
+	
+	DeviceStorageImpl deviceImpl;
+	DeviceManagerImpl deviceManager;
+	protected IPacket testARPReplyPacket_1;
+    FlowReconcileManager flowReconcileMgr;
+    MemoryStorageSource storageSource;
+    protected byte[] testARPReplyPacket_1_Srld;
+    protected OFPacketIn packetIn_1;
+    private static TitanGraph titanGraph;
+    String conf;
+    private GraphDBConnection mockConn;
+    private GraphDBOperation mockOpe;
+    
+	@Before
+	public void setUp() throws Exception {
+
+// 		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);
+		
+		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);
+			
+		} 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.
+	 */
+	//@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);
+			
+		} 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 = 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);
+			
+		} 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);
+			expect(mockDev.getAttachmentPoints()).andReturn(sps);
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev.getIPv4Addresses()).andReturn(ipaddrs);
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			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);
+			expect(mockDev2.getMACAddressString()).andReturn(macAddr2);
+			expect(mockDev2.getMACAddressString()).andReturn(macAddr2);
+			expect(mockDev2.getMACAddressString()).andReturn(macAddr2);
+			expect(mockDev2.getIPv4Addresses()).andReturn(ipaddrs);
+			expect(mockDev2.getAttachmentPoints()).andReturn(sps);
+			expect(mockDev2.getMACAddressString()).andReturn(macAddr2);
+			expect(mockDev2.getMACAddressString()).andReturn(macAddr2);
+			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);
+		 
+		} 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 = 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);
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev.getIPv4Addresses()).andReturn(ipaddrs);
+			expect(mockDev.getAttachmentPoints()).andReturn(sps);
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			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);
+		    
+		} 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 = 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 dummyIP = "222.222.222.222";
+			
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev.getIPv4Addresses()).andReturn(ipaddrs);
+			expect(mockDev.getAttachmentPoints()).andReturn(sps);
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			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(ip).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);
+			
+		} 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. Change the attachment point.
+	 */
+	//@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);
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev.getIPv4Addresses()).andReturn(ipaddrs);
+			expect(mockDev.getAttachmentPoints()).andReturn(sps);
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			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);
+			expect(mockDev2.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev2.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev2.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev2.getIPv4Addresses()).andReturn(ipaddrs);
+			expect(mockDev2.getAttachmentPoints()).andReturn(sps2);
+			expect(mockDev2.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev2.getMACAddressString()).andReturn(macAddr);
+			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);
+			expect(mockDev3.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev3.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev3.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev3.getIPv4Addresses()).andReturn(ipaddrs);
+			expect(mockDev3.getAttachmentPoints()).andReturn(sps3);
+			expect(mockDev3.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev3.getMACAddressString()).andReturn(macAddr);
+			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);
+			
+		} 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. Check correctly changed the ipadress
+	 */
+	//@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);
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev.getIPv4Addresses()).andReturn(ipaddrs);
+			expect(mockDev.getAttachmentPoints()).andReturn(sps);
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			expect(mockDev.getMACAddressString()).andReturn(macAddr);
+			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);	
+					
+		} 
+		catch(Exception e) {
+			fail(e.getMessage());
+		}
+	}
+
+}