Removed Floodlight devicemanager, topology, routing and forwarding modules

Change-Id: Icbdecb2f7c84bcb450ee95177d82ae9c82a3f163
diff --git a/src/test/java/net/floodlightcontroller/core/module/FloodlightTestModuleLoader.java b/src/test/java/net/floodlightcontroller/core/module/FloodlightTestModuleLoader.java
index 89a3591..beb6d4f 100644
--- a/src/test/java/net/floodlightcontroller/core/module/FloodlightTestModuleLoader.java
+++ b/src/test/java/net/floodlightcontroller/core/module/FloodlightTestModuleLoader.java
@@ -6,9 +6,6 @@
 
 import net.floodlightcontroller.core.test.MockFloodlightProvider;
 import net.floodlightcontroller.core.test.MockThreadPoolService;
-import net.floodlightcontroller.devicemanager.internal.DefaultEntityClassifier;
-import net.floodlightcontroller.devicemanager.test.MockDeviceManager;
-import net.floodlightcontroller.topology.TopologyManager;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -19,25 +16,16 @@
 	// List of default modules to use unless specified otherwise
 	public static final Class<? extends IFloodlightModule> DEFAULT_FLOODLIGHT_PRPOVIDER =
 			MockFloodlightProvider.class;
-	public static final Class<? extends IFloodlightModule> DEFAULT_TOPOLOGY_PROVIDER =
-			TopologyManager.class;
-	public static final Class<? extends IFloodlightModule> DEFAULT_DEVICE_SERVICE =
-			MockDeviceManager.class;
 	public static final Class<? extends IFloodlightModule> DEFAULT_THREADPOOL =
 			MockThreadPoolService.class;
-	public static final Class<? extends IFloodlightModule> DEFAULT_ENTITY_CLASSIFIER =
-			DefaultEntityClassifier.class;
 	
 	
 	protected static final Collection<Class<? extends IFloodlightModule>> DEFAULT_MODULE_LIST;
 	
 	static {
 		DEFAULT_MODULE_LIST = new ArrayList<Class<? extends IFloodlightModule>>();
-		DEFAULT_MODULE_LIST.add(DEFAULT_DEVICE_SERVICE);
 		DEFAULT_MODULE_LIST.add(DEFAULT_FLOODLIGHT_PRPOVIDER);
-		DEFAULT_MODULE_LIST.add(DEFAULT_TOPOLOGY_PROVIDER);
 		DEFAULT_MODULE_LIST.add(DEFAULT_THREADPOOL);
-		DEFAULT_MODULE_LIST.add(DEFAULT_ENTITY_CLASSIFIER);
 
 	}
 	
diff --git a/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java b/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java
deleted file mode 100644
index b37efe3..0000000
--- a/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java
+++ /dev/null
@@ -1,1760 +0,0 @@
-/**
- *    Copyright 2011, Big Switch Networks, Inc.
- *    Originally created by David Erickson, Stanford University
- *
- *    Licensed under the Apache License, Version 2.0 (the "License"); you may
- *    not use this file except in compliance with the License. You may obtain
- *    a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- *    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- *    License for the specific language governing permissions and limitations
- *    under the License.
- **/
-
-package net.floodlightcontroller.devicemanager.internal;
-
-
-import static org.easymock.EasyMock.anyLong;
-import static org.easymock.EasyMock.anyShort;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.createStrictMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.isA;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertArrayEquals;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import net.floodlightcontroller.core.IFloodlightProviderService;
-import net.floodlightcontroller.core.IOFSwitch;
-import net.floodlightcontroller.core.module.FloodlightModuleContext;
-import net.floodlightcontroller.core.test.MockFloodlightProvider;
-import net.floodlightcontroller.core.test.MockThreadPoolService;
-import net.floodlightcontroller.devicemanager.IDevice;
-import net.floodlightcontroller.devicemanager.IDeviceListener;
-import net.floodlightcontroller.devicemanager.IDeviceService;
-import net.floodlightcontroller.devicemanager.IEntityClass;
-import net.floodlightcontroller.devicemanager.IEntityClassifierService;
-import net.floodlightcontroller.devicemanager.SwitchPort;
-import net.floodlightcontroller.devicemanager.SwitchPort.ErrorStatus;
-import net.floodlightcontroller.devicemanager.internal.DeviceManagerImpl.ClassState;
-import net.floodlightcontroller.devicemanager.test.MockEntityClassifier;
-import net.floodlightcontroller.devicemanager.test.MockEntityClassifierMac;
-import net.floodlightcontroller.devicemanager.test.MockFlexEntityClassifier;
-import net.floodlightcontroller.packet.ARP;
-import net.floodlightcontroller.packet.Ethernet;
-import net.floodlightcontroller.packet.IPacket;
-import net.floodlightcontroller.packet.IPv4;
-import net.floodlightcontroller.restserver.IRestApiService;
-import net.floodlightcontroller.restserver.RestApiServer;
-import net.floodlightcontroller.test.FloodlightTestCase;
-import net.floodlightcontroller.threadpool.IThreadPoolService;
-import net.floodlightcontroller.topology.ITopologyService;
-
-import org.easymock.EasyMock;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.openflow.protocol.OFPacketIn;
-import org.openflow.protocol.OFPacketIn.OFPacketInReason;
-import org.openflow.protocol.OFPhysicalPort;
-import org.openflow.protocol.OFType;
-import org.openflow.util.HexString;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Ignore //TODO broken 11/19/13, should fix
-public class DeviceManagerImplTest extends FloodlightTestCase {
-
-    protected final static Logger logger =
-            LoggerFactory.getLogger(DeviceManagerImplTest.class);
-
-    protected OFPacketIn packetIn_1, packetIn_2, packetIn_3;
-    protected IPacket testARPReplyPacket_1, testARPReplyPacket_2,
-    testARPReplyPacket_3;
-    protected IPacket testARPReqPacket_1, testARPReqPacket_2;
-    protected byte[] testARPReplyPacket_1_Srld, testARPReplyPacket_2_Srld;
-    private byte[] testARPReplyPacket_3_Serialized;
-    MockFloodlightProvider mockFloodlightProvider;
-    DeviceManagerImpl deviceManager;
-
-    private IOFSwitch makeSwitchMock(long id) {
-        IOFSwitch mockSwitch = createMock(IOFSwitch.class);
-        expect(mockSwitch.getId()).andReturn(id).anyTimes();
-        expect(mockSwitch.getStringId()).
-        andReturn(HexString.toHexString(id, 6)).anyTimes();
-        expect(mockSwitch.getPort(anyShort())).
-        andReturn(new OFPhysicalPort()).anyTimes();
-        expect(mockSwitch.portEnabled(isA(OFPhysicalPort.class))).
-        andReturn(true).anyTimes();
-        return mockSwitch;
-    }
-
-    @Before
-    public void setUp() throws Exception {
-        super.setUp();
-
-        FloodlightModuleContext fmc = new FloodlightModuleContext();
-        RestApiServer restApi = new RestApiServer();
-        MockThreadPoolService tp = new MockThreadPoolService();
-        ITopologyService topology = createMock(ITopologyService.class);
-        fmc.addService(IThreadPoolService.class, tp);
-        mockFloodlightProvider = getMockFloodlightProvider();
-        deviceManager = new DeviceManagerImpl();
-       
-        DefaultEntityClassifier entityClassifier = new DefaultEntityClassifier();
-        fmc.addService(IDeviceService.class, deviceManager);
-        //storageSource = new MemoryStorageSource();
-        //fmc.addService(IStorageSourceService.class, storageSource);
-        fmc.addService(IFloodlightProviderService.class, mockFloodlightProvider);
-        fmc.addService(IRestApiService.class, restApi);
- 
-        fmc.addService(IEntityClassifierService.class, entityClassifier);
-        fmc.addService(ITopologyService.class, topology);
-        tp.init(fmc);
-        restApi.init(fmc);
-        //storageSource.init(fmc);
-        deviceManager.init(fmc);
-
-        entityClassifier.init(fmc);
-        //storageSource.startUp(fmc);
-        deviceManager.startUp(fmc);
-
-        tp.startUp(fmc);
-        entityClassifier.startUp(fmc);
-
-        reset(topology);
-        topology.addListener(deviceManager);
-        expectLastCall().anyTimes();
-        replay(topology);
-
-        IOFSwitch mockSwitch1 = makeSwitchMock(1L);
-        IOFSwitch mockSwitch10 = makeSwitchMock(10L);
-        IOFSwitch mockSwitch5 = makeSwitchMock(5L);
-        IOFSwitch mockSwitch50 = makeSwitchMock(50L);
-        Map<Long, IOFSwitch> switches = new HashMap<Long,IOFSwitch>();
-        switches.put(1L, mockSwitch1);
-        switches.put(10L, mockSwitch10);
-        switches.put(5L, mockSwitch5);
-        switches.put(50L, mockSwitch50);
-        mockFloodlightProvider.setSwitches(switches);
-
-        replay(mockSwitch1, mockSwitch5, mockSwitch10, mockSwitch50);
-
-        // Build our test packet
-        this.testARPReplyPacket_1 = new Ethernet()
-        .setSourceMACAddress("00:44:33:22:11:01")
-        .setDestinationMACAddress("00:11:22:33:44:55")
-        .setEtherType(Ethernet.TYPE_ARP)
-        .setVlanID((short)5)
-        .setPayload(
-                    new ARP()
-                    .setHardwareType(ARP.HW_TYPE_ETHERNET)
-                    .setProtocolType(ARP.PROTO_TYPE_IP)
-                    .setHardwareAddressLength((byte) 6)
-                    .setProtocolAddressLength((byte) 4)
-                    .setOpCode(ARP.OP_REPLY)
-                    .setSenderHardwareAddress(Ethernet.toMACAddress("00:44:33:22:11:01"))
-                    .setSenderProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.1"))
-                    .setTargetHardwareAddress(Ethernet.toMACAddress("00:11:22:33:44:55"))
-                    .setTargetProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.2")));
-        this.testARPReplyPacket_1_Srld = testARPReplyPacket_1.serialize();
-
-        // Another test packet with a different source IP
-        this.testARPReplyPacket_2 = new Ethernet()
-        .setSourceMACAddress("00:44:33:22:11:01")
-        .setDestinationMACAddress("00:11:22:33:44:55")
-        .setEtherType(Ethernet.TYPE_ARP)
-        .setPayload(
-                    new ARP()
-                    .setHardwareType(ARP.HW_TYPE_ETHERNET)
-                    .setProtocolType(ARP.PROTO_TYPE_IP)
-                    .setHardwareAddressLength((byte) 6)
-                    .setProtocolAddressLength((byte) 4)
-                    .setOpCode(ARP.OP_REPLY)
-                    .setSenderHardwareAddress(Ethernet.toMACAddress("00:44:33:22:11:01"))
-                    .setSenderProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.1"))
-                    .setTargetHardwareAddress(Ethernet.toMACAddress("00:11:22:33:44:55"))
-                    .setTargetProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.2")));
-        this.testARPReplyPacket_2_Srld = testARPReplyPacket_2.serialize();
-
-        this.testARPReplyPacket_3 = new Ethernet()
-        .setSourceMACAddress("00:44:33:22:11:01")
-        .setDestinationMACAddress("00:11:22:33:44:55")
-        .setEtherType(Ethernet.TYPE_ARP)
-        .setPayload(
-                    new ARP()
-                    .setHardwareType(ARP.HW_TYPE_ETHERNET)
-                    .setProtocolType(ARP.PROTO_TYPE_IP)
-                    .setHardwareAddressLength((byte) 6)
-                    .setProtocolAddressLength((byte) 4)
-                    .setOpCode(ARP.OP_REPLY)
-                    .setSenderHardwareAddress(Ethernet.toMACAddress("00:44:33:22:11:01"))
-                    .setSenderProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.3"))
-                    .setTargetHardwareAddress(Ethernet.toMACAddress("00:11:22:33:44:55"))
-                    .setTargetProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.2")));
-        this.testARPReplyPacket_3_Serialized = testARPReplyPacket_3.serialize();
-        
-        // Build the PacketIn
-        this.packetIn_1 = ((OFPacketIn) mockFloodlightProvider.
-                getOFMessageFactory().getMessage(OFType.PACKET_IN))
-                .setBufferId(-1)
-                .setInPort((short) 1)
-                .setPacketData(this.testARPReplyPacket_1_Srld)
-                .setReason(OFPacketInReason.NO_MATCH)
-                .setTotalLength((short) this.testARPReplyPacket_1_Srld.length);
-
-        // Build the PacketIn
-        this.packetIn_2 = ((OFPacketIn) mockFloodlightProvider.
-                getOFMessageFactory().getMessage(OFType.PACKET_IN))
-                .setBufferId(-1)
-                .setInPort((short) 1)
-                .setPacketData(this.testARPReplyPacket_2_Srld)
-                .setReason(OFPacketInReason.NO_MATCH)
-                .setTotalLength((short) this.testARPReplyPacket_2_Srld.length);
-
-        // Build the PacketIn
-        this.packetIn_3 = ((OFPacketIn) mockFloodlightProvider.
-                getOFMessageFactory().getMessage(OFType.PACKET_IN))
-                .setBufferId(-1)
-                .setInPort((short) 1)
-                .setPacketData(this.testARPReplyPacket_3_Serialized)
-                .setReason(OFPacketInReason.NO_MATCH)
-                .setTotalLength((short) this.testARPReplyPacket_3_Serialized.length);
-    }
-
-
-
-
-    
-    @Test
-    public void testLastSeen() throws Exception {
-        Calendar c = Calendar.getInstance();
-        Date d1 = c.getTime();
-        Entity entity1 = new Entity(1L, null, null, null, null, d1);
-        c.add(Calendar.SECOND, 1);
-        Entity entity2 = new Entity(1L, null, 1, null, null, c.getTime());
-
-        IDevice d = deviceManager.learnDeviceByEntity(entity2);
-        assertEquals(c.getTime(), d.getLastSeen());
-        d = deviceManager.learnDeviceByEntity(entity1);
-        assertEquals(c.getTime(), d.getLastSeen());
-
-        deviceManager.startUp(null);
-        d = deviceManager.learnDeviceByEntity(entity1);
-        assertEquals(d1, d.getLastSeen());
-        d = deviceManager.learnDeviceByEntity(entity2);
-        assertEquals(c.getTime(), d.getLastSeen());
-    }
-
-    @Test
-    public void testEntityLearning() throws Exception {
-        IDeviceListener mockListener =
-                createStrictMock(IDeviceListener.class);
-
-        deviceManager.addListener(mockListener);
-        deviceManager.entityClassifier= new MockEntityClassifier();
-        deviceManager.startUp(null);
-
-        ITopologyService mockTopology = createMock(ITopologyService.class);
-        expect(mockTopology.getL2DomainId(anyLong())).
-        andReturn(1L).anyTimes();
-        expect(mockTopology.isBroadcastDomainPort(anyLong(), anyShort())).
-        andReturn(false).anyTimes();
-
-        expect(mockTopology.isAttachmentPointPort(anyLong(),
-                                                  anyShort())).andReturn(true).anyTimes();
-        expect(mockTopology.isConsistent(10L, (short)1, 10L, (short)1)).
-        andReturn(true).anyTimes();
-        expect(mockTopology.isConsistent(1L, (short)1, 1L, (short)1)).
-        andReturn(true).anyTimes();
-        expect(mockTopology.isConsistent(50L, (short)3, 50L, (short)3)).
-        andReturn(true).anyTimes();
-
-        Date topologyUpdateTime = new Date();
-        expect(mockTopology.getLastUpdateTime()).andReturn(topologyUpdateTime).
-        anyTimes();
-
-        deviceManager.topology = mockTopology;
-
-        Entity entity1 = new Entity(1L, null, null, 1L, 1, new Date());
-        Entity entity2 = new Entity(1L, null, null, 10L, 1, new Date());
-        Entity entity3 = new Entity(1L, null, 1, 10L, 1, new Date());
-        Entity entity4 = new Entity(1L, null, 1, 1L, 1, new Date());
-        Entity entity5 = new Entity(2L, (short)4, 1, 5L, 2, new Date());
-        Entity entity6 = new Entity(2L, (short)4, 1, 50L, 3, new Date());
-        Entity entity7 = new Entity(2L, (short)4, 2, 50L, 3, new Date());
-
-        mockListener.deviceAdded(isA(IDevice.class));
-        replay(mockListener, mockTopology);
-
-        Device d1 = deviceManager.learnDeviceByEntity(entity1);
-        assertSame(d1, deviceManager.learnDeviceByEntity(entity1));
-        assertSame(d1, deviceManager.findDeviceByEntity(entity1));
-        assertEquals(DefaultEntityClassifier.entityClass ,
-                          d1.entityClass);
-        assertArrayEquals(new Short[] { -1 }, d1.getVlanId());
-        assertArrayEquals(new Integer[] { }, d1.getIPv4Addresses());
-
-        assertEquals(1, deviceManager.getAllDevices().size());
-        verify(mockListener);
-
-        reset(mockListener);
-        mockListener.deviceAdded(isA(IDevice.class));
-        replay(mockListener);
-
-        Device d2 = deviceManager.learnDeviceByEntity(entity2);
-        assertFalse(d1.equals(d2));
-        assertNotSame(d1, d2);
-        assertNotSame(d1.getDeviceKey(), d2.getDeviceKey());
-        assertEquals(MockEntityClassifier.testEC, d2.entityClass);
-        assertArrayEquals(new Short[] { -1 }, d2.getVlanId());
-        assertArrayEquals(new Integer[] { }, d2.getIPv4Addresses());
-
-        assertEquals(2, deviceManager.getAllDevices().size());
-        verify(mockListener);
-
-        reset(mockListener);
-        mockListener.deviceIPV4AddrChanged(isA(IDevice.class));
-        replay(mockListener);
-
-        Device d3 = deviceManager.learnDeviceByEntity(entity3);
-        assertNotSame(d2, d3);
-        assertEquals(d2.getDeviceKey(), d3.getDeviceKey());
-        assertEquals(MockEntityClassifier.testEC, d3.entityClass);
-        assertArrayEquals(new Integer[] { 1 },
-                          d3.getIPv4Addresses());
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(10L, 1) },
-                          d3.getAttachmentPoints());
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(10L, 1) },
-                          d3.getAttachmentPoints(true));
-        assertArrayEquals(new Short[] { -1 },
-                          d3.getVlanId());
-
-        assertEquals(2, deviceManager.getAllDevices().size());
-        verify(mockListener);
-
-        reset(mockListener);
-        mockListener.deviceIPV4AddrChanged(isA(IDevice.class));
-        replay(mockListener);
-
-        Device d4 = deviceManager.learnDeviceByEntity(entity4);
-        assertNotSame(d1, d4);
-        assertEquals(d1.getDeviceKey(), d4.getDeviceKey());
-        assertEquals(DefaultEntityClassifier.entityClass, d4.entityClass);
-        assertArrayEquals(new Integer[] { 1 },
-                          d4.getIPv4Addresses());
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1) },
-                          d4.getAttachmentPoints());
-        assertArrayEquals(new Short[] { -1 },
-                          d4.getVlanId());
-
-        assertEquals(2, deviceManager.getAllDevices().size());
-        verify(mockListener);
-
-        reset(mockListener);
-        mockListener.deviceAdded((isA(IDevice.class)));
-        replay(mockListener);
-
-        Device d5 = deviceManager.learnDeviceByEntity(entity5);
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(5L, 2) },
-                          d5.getAttachmentPoints());
-        assertArrayEquals(new Short[] { (short) 4 },
-                          d5.getVlanId());
-        assertEquals(2L, d5.getMACAddress());
-        assertEquals("00:00:00:00:00:02", d5.getMACAddressString());
-        verify(mockListener);
-
-        reset(mockListener);
-        mockListener.deviceAdded(isA(IDevice.class));
-        replay(mockListener);
-
-        Device d6 = deviceManager.learnDeviceByEntity(entity6);
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(50L, 3) },
-                          d6.getAttachmentPoints());
-        assertArrayEquals(new Short[] { (short) 4 },
-                          d6.getVlanId());
-
-        assertEquals(4, deviceManager.getAllDevices().size());
-        verify(mockListener);
-
-        reset(mockListener);
-        mockListener.deviceIPV4AddrChanged(isA(IDevice.class));
-        replay(mockListener);
-
-        Device d7 = deviceManager.learnDeviceByEntity(entity7);
-        assertNotSame(d6, d7);
-        assertEquals(d6.getDeviceKey(), d7.getDeviceKey());
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(50L, 3) },
-                          d7.getAttachmentPoints());
-        assertArrayEquals(new Short[] { (short) 4 },
-                          d7.getVlanId());
-
-        assertEquals(4, deviceManager.getAllDevices().size());
-        verify(mockListener);
-        
-        
-        reset(mockListener);
-        replay(mockListener);
-        
-        reset(deviceManager.topology);
-        deviceManager.topology.addListener(deviceManager);
-        expectLastCall().times(1);
-        replay(deviceManager.topology);
-
-        deviceManager.entityClassifier = new MockEntityClassifierMac();
-        deviceManager.startUp(null);
-        Entity entityNoClass = new Entity(5L, (short)1, 5, -1L, 1, new Date());
-        assertEquals(null, deviceManager.learnDeviceByEntity(entityNoClass));
-        
-        verify(mockListener);
-    }
-    
-
-    @Test
-    public void testAttachmentPointLearning() throws Exception {
-        IDeviceListener mockListener =
-                createStrictMock(IDeviceListener.class);
-
-        deviceManager.addListener(mockListener);
-
-        ITopologyService mockTopology = createMock(ITopologyService.class);
-        expect(mockTopology.getL2DomainId(1L)).
-        andReturn(1L).anyTimes();
-        expect(mockTopology.getL2DomainId(5L)).
-        andReturn(1L).anyTimes();
-        expect(mockTopology.getL2DomainId(10L)).
-        andReturn(10L).anyTimes();
-        expect(mockTopology.getL2DomainId(50L)).
-        andReturn(10L).anyTimes();
-        expect(mockTopology.isBroadcastDomainPort(anyLong(), anyShort())).
-        andReturn(false).anyTimes();
-        expect(mockTopology.isInSameBroadcastDomain(anyLong(), anyShort(),
-                                                    anyLong(), anyShort())).andReturn(false).anyTimes();
-
-        expect(mockTopology.isAttachmentPointPort(anyLong(),
-                                                  anyShort())).andReturn(true).anyTimes();
-        expect(mockTopology.isConsistent(1L, (short)1, 5L, (short)1)).
-        andReturn(false).anyTimes();
-        expect(mockTopology.isConsistent(5L, (short)1, 10L, (short)1)).
-        andReturn(false).anyTimes();
-        expect(mockTopology.isConsistent(10L, (short)1, 50L, (short)1)).
-        andReturn(false).anyTimes();
-
-        Date topologyUpdateTime = new Date();
-        expect(mockTopology.getLastUpdateTime()).andReturn(topologyUpdateTime).
-        anyTimes();
-
-        replay(mockTopology);
-
-        deviceManager.topology = mockTopology;
-
-        Calendar c = Calendar.getInstance();
-        Entity entity1 = new Entity(1L, null, 1, 1L, 1, c.getTime());
-        Entity entity0 = new Entity(1L, null, null, null, null, c.getTime());
-        c.add(Calendar.SECOND, 1);
-        Entity entity2 = new Entity(1L, null, null, 5L, 1, c.getTime());
-        c.add(Calendar.SECOND, 1);
-        Entity entity3 = new Entity(1L, null, null, 10L, 1, c.getTime());
-        c.add(Calendar.SECOND, 1);
-        Entity entity4 = new Entity(1L, null, null, 50L, 1, c.getTime());
-
-        IDevice d;
-        SwitchPort[] aps;
-        Integer[] ips;
-
-        mockListener.deviceAdded(isA(IDevice.class));
-        replay(mockListener);
-
-        deviceManager.learnDeviceByEntity(entity1);
-        d = deviceManager.learnDeviceByEntity(entity0);
-        assertEquals(1, deviceManager.getAllDevices().size());
-        aps = d.getAttachmentPoints();
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1) }, aps);
-        ips = d.getIPv4Addresses();
-        assertArrayEquals(new Integer[] { 1 }, ips);
-        verify(mockListener);
-
-        reset(mockListener);
-        mockListener.deviceMoved((isA(IDevice.class)));
-        replay(mockListener);
-
-        d = deviceManager.learnDeviceByEntity(entity2);
-        assertEquals(1, deviceManager.getAllDevices().size());
-        aps = d.getAttachmentPoints();
-
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(5L, 1) }, aps);
-        ips = d.getIPv4Addresses();
-        assertArrayEquals(new Integer[] { 1 }, ips);
-        verify(mockListener);
-
-        reset(mockListener);
-        mockListener.deviceMoved((isA(IDevice.class)));
-        replay(mockListener);
-
-        d = deviceManager.learnDeviceByEntity(entity3);
-        assertEquals(1, deviceManager.getAllDevices().size());
-        aps = d.getAttachmentPoints();
-        assertArrayEquals(new SwitchPort[] {new SwitchPort(5L, 1), new SwitchPort(10L, 1)}, aps);
-        ips = d.getIPv4Addresses();
-        assertArrayEquals(new Integer[] { 1 }, ips);
-        verify(mockListener);
-
-        reset(mockListener);
-        mockListener.deviceMoved((isA(IDevice.class)));
-        replay(mockListener);
-
-        d = deviceManager.learnDeviceByEntity(entity4);
-        assertEquals(1, deviceManager.getAllDevices().size());
-        aps = d.getAttachmentPoints();
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(5L, 1),
-                                             new SwitchPort(50L, 1) }, aps);
-        ips = d.getIPv4Addresses();
-        assertArrayEquals(new Integer[] { 1 }, ips);
-        verify(mockListener);
-    }
-
-    @Test
-    public void testAttachmentPointSuppression() throws Exception {
-        IDeviceListener mockListener =
-                createStrictMock(IDeviceListener.class);
-
-        deviceManager.addListener(mockListener);
-
-        ITopologyService mockTopology = createMock(ITopologyService.class);
-        expect(mockTopology.getL2DomainId(1L)).
-        andReturn(1L).anyTimes();
-        expect(mockTopology.getL2DomainId(5L)).
-        andReturn(1L).anyTimes();
-        expect(mockTopology.getL2DomainId(10L)).
-        andReturn(10L).anyTimes();
-        expect(mockTopology.getL2DomainId(50L)).
-        andReturn(10L).anyTimes();
-        expect(mockTopology.isBroadcastDomainPort(anyLong(), anyShort())).
-        andReturn(false).anyTimes();
-        expect(mockTopology.isInSameBroadcastDomain(anyLong(), anyShort(),
-                                                    anyLong(), anyShort())).andReturn(false).anyTimes();
-
-        expect(mockTopology.isAttachmentPointPort(anyLong(),
-                                                  anyShort())).andReturn(true).anyTimes();
-        expect(mockTopology.isConsistent(5L, (short)1, 50L, (short)1)).
-        andReturn(false).anyTimes();
-
-        Date topologyUpdateTime = new Date();
-        expect(mockTopology.getLastUpdateTime()).andReturn(topologyUpdateTime).
-        anyTimes();
-
-        replay(mockTopology);
-
-        deviceManager.topology = mockTopology;
-        // suppress (1L, 1) and (10L, 1)
-        deviceManager.addSuppressAPs(1L, (short)1);
-        deviceManager.addSuppressAPs(10L, (short)1);
-
-        Calendar c = Calendar.getInstance();
-        Entity entity1 = new Entity(1L, null, 1, 1L, 1, c.getTime());
-        Entity entity0 = new Entity(1L, null, null, null, null, c.getTime());
-        c.add(Calendar.SECOND, 1);
-        Entity entity2 = new Entity(1L, null, null, 5L, 1, c.getTime());
-        c.add(Calendar.SECOND, 1);
-        Entity entity3 = new Entity(1L, null, null, 10L, 1, c.getTime());
-        c.add(Calendar.SECOND, 1);
-        Entity entity4 = new Entity(1L, null, null, 50L, 1, c.getTime());
-
-        IDevice d;
-        SwitchPort[] aps;
-        Integer[] ips;
-
-        mockListener.deviceAdded(isA(IDevice.class));
-        replay(mockListener);
-
-        deviceManager.learnDeviceByEntity(entity1);
-        d = deviceManager.learnDeviceByEntity(entity0);
-        assertEquals(1, deviceManager.getAllDevices().size());
-        aps = d.getAttachmentPoints();
-        assertEquals(aps.length, 0);
-        ips = d.getIPv4Addresses();
-        assertArrayEquals(new Integer[] { 1 }, ips);
-        verify(mockListener);
-
-        reset(mockListener);
-        mockListener.deviceMoved((isA(IDevice.class)));
-        replay(mockListener);
-
-        d = deviceManager.learnDeviceByEntity(entity2);
-        assertEquals(1, deviceManager.getAllDevices().size());
-        aps = d.getAttachmentPoints();
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(5L, 1) }, aps);
-        ips = d.getIPv4Addresses();
-        assertArrayEquals(new Integer[] { 1 }, ips);
-        verify(mockListener);
-
-        reset(mockListener);
-        mockListener.deviceMoved((isA(IDevice.class)));
-        replay(mockListener);
-
-        d = deviceManager.learnDeviceByEntity(entity3);
-        assertEquals(1, deviceManager.getAllDevices().size());
-        aps = d.getAttachmentPoints();
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(5L, 1) }, aps);
-        ips = d.getIPv4Addresses();
-        assertArrayEquals(new Integer[] { 1 }, ips);
-        //verify(mockListener);  // There is no device movement here; no not needed.
-
-        reset(mockListener);
-        mockListener.deviceMoved((isA(IDevice.class)));
-        replay(mockListener);
-
-        d = deviceManager.learnDeviceByEntity(entity4);
-        assertEquals(1, deviceManager.getAllDevices().size());
-        aps = d.getAttachmentPoints();
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(5L, 1),
-                                             new SwitchPort(50L, 1) }, aps);
-        ips = d.getIPv4Addresses();
-        assertArrayEquals(new Integer[] { 1 }, ips);
-        verify(mockListener);
-    }
-
-    @Test
-    public void testBDAttachmentPointLearning() throws Exception {
-        ITopologyService mockTopology = createMock(ITopologyService.class);
-        expect(mockTopology.getL2DomainId(anyLong())).
-        andReturn(1L).anyTimes();
-        expect(mockTopology.isAttachmentPointPort(anyLong(), anyShort())).
-        andReturn(true).anyTimes();
-        expect(mockTopology.isBroadcastDomainPort(1L, (short)1)).
-        andReturn(false).anyTimes();
-        expect(mockTopology.isBroadcastDomainPort(1L, (short)2)).
-        andReturn(true).anyTimes();
-        expect(mockTopology.isInSameBroadcastDomain(1L, (short)1,
-                                                    1L, (short)2)).andReturn(true).anyTimes();
-        expect(mockTopology.isInSameBroadcastDomain(1L, (short)2,
-                                                    1L, (short)1)).andReturn(true).anyTimes();
-        expect(mockTopology.isConsistent(anyLong(), anyShort(), anyLong(), anyShort())).andReturn(false).anyTimes();
-
-        Date topologyUpdateTime = new Date();
-        expect(mockTopology.getLastUpdateTime()).andReturn(topologyUpdateTime).
-        anyTimes();
-
-        replay(mockTopology);
-
-        deviceManager.topology = mockTopology;
-
-        Calendar c = Calendar.getInstance();
-        Entity entity1 = new Entity(1L, null, 1, 1L, 1, c.getTime());
-        c.add(Calendar.MILLISECOND,
-              (int)AttachmentPoint.OPENFLOW_TO_EXTERNAL_TIMEOUT/ 2);
-        Entity entity2 = new Entity(1L, null, null, 1L, 2, c.getTime());
-        c.add(Calendar.MILLISECOND,
-              (int)AttachmentPoint.OPENFLOW_TO_EXTERNAL_TIMEOUT / 2 + 1);
-        Entity entity3 = new Entity(1L, null, null, 1L, 2, c.getTime());
-
-        IDevice d;
-        SwitchPort[] aps;
-
-        d = deviceManager.learnDeviceByEntity(entity1);
-        assertEquals(1, deviceManager.getAllDevices().size());
-        aps = d.getAttachmentPoints();
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1) }, aps);
-
-        // this timestamp is too soon; don't switch
-        d = deviceManager.learnDeviceByEntity(entity2);
-        assertEquals(1, deviceManager.getAllDevices().size());
-        aps = d.getAttachmentPoints();
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1) }, aps);
-
-        // it should switch when we learn with a timestamp after the
-        // timeout
-        d = deviceManager.learnDeviceByEntity(entity3);
-        assertEquals(1, deviceManager.getAllDevices().size());
-        aps = d.getAttachmentPoints();
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 2) }, aps);
-    }
-
-
-    @Test
-    public void testPacketIn() throws Exception {
-        byte[] dataLayerSource =
-                ((Ethernet)this.testARPReplyPacket_1).getSourceMACAddress();
-
-        // Mock up our expected behavior
-        ITopologyService mockTopology = createMock(ITopologyService.class);
-        deviceManager.topology = mockTopology;
-        expect(mockTopology.isAttachmentPointPort(EasyMock.anyLong(),
-                                                  EasyMock.anyShort())).
-                                                  andReturn(true).anyTimes();
-        expect(mockTopology.isConsistent(EasyMock.anyLong(),
-                                         EasyMock.anyShort(),
-                                         EasyMock.anyLong(),
-                                         EasyMock.anyShort())).andReturn(false).
-                                         anyTimes();
-        expect(mockTopology.getL2DomainId(EasyMock.anyLong())).andReturn(1L).anyTimes();
-        replay(mockTopology);
-
-        Date currentDate = new Date();
-
-        // build our expected Device
-        Integer ipaddr = IPv4.toIPv4Address("192.168.1.1");
-        Device device =
-                new Device(deviceManager,
-                           new Long(deviceManager.deviceKeyCounter),
-                           new Entity(Ethernet.toLong(dataLayerSource),
-                                      (short)5,
-                                      ipaddr,
-                                      1L,
-                                      1,
-                                      currentDate),
-                                      DefaultEntityClassifier.entityClass);
-
-
-
-
-        // Get the listener and trigger the packet in
-        IOFSwitch switch1 = mockFloodlightProvider.getSwitches().get(1L);
-        mockFloodlightProvider.dispatchMessage(switch1, this.packetIn_1);
-
-        // Verify the replay matched our expectations
-        // verify(mockTopology);
-
-        // Verify the device
-        Device rdevice = (Device)
-                deviceManager.findDevice(Ethernet.toLong(dataLayerSource),
-                                         (short)5, null, null, null);
-
-        assertEquals(device, rdevice);
-        assertEquals(new Short((short)5), rdevice.getVlanId()[0]);
-
-        Device result = null;
-        Iterator<? extends IDevice> dstiter =
-                deviceManager.queryClassDevices(device, null, null, ipaddr,
-                                                null, null);
-        if (dstiter.hasNext()) {
-            result = (Device)dstiter.next();
-        }
-
-        assertEquals(device, result);
-
-        device =
-                new Device(device,
-                           new Entity(Ethernet.toLong(dataLayerSource),
-                                      (short)5,
-                                      ipaddr,
-                                      5L,
-                                      2,
-                                      currentDate));
-
-        reset(mockTopology);
-        expect(mockTopology.isAttachmentPointPort(anyLong(),
-                                                  anyShort())).
-                                                  andReturn(true).
-                                                  anyTimes();
-        expect(mockTopology.isConsistent(EasyMock.anyLong(),
-                                         EasyMock.anyShort(),
-                                         EasyMock.anyLong(),
-                                         EasyMock.anyShort())).andReturn(false).
-                                         anyTimes();
-        expect(mockTopology.isBroadcastDomainPort(EasyMock.anyLong(),
-                                                  EasyMock.anyShort()))
-                                                  .andReturn(false)
-                                                  .anyTimes();
-        expect(mockTopology.getL2DomainId(1L)).andReturn(1L).anyTimes();
-        expect(mockTopology.getL2DomainId(5L)).andReturn(1L).anyTimes();
-        expect(mockTopology.isInSameBroadcastDomain(1L, (short)1, 5L, (short)2)).
-               andReturn(false).anyTimes();
-
-        // Start recording the replay on the mocks
-        replay(mockTopology);
-        // Get the listener and trigger the packet in
-        IOFSwitch switch5 = mockFloodlightProvider.getSwitches().get(5L);
-        mockFloodlightProvider.
-        dispatchMessage(switch5, this.packetIn_1.setInPort((short)2));
-
-        // Verify the replay matched our expectations
-        verify(mockTopology);
-
-        // Verify the device
-        rdevice = (Device)
-                deviceManager.findDevice(Ethernet.toLong(dataLayerSource),
-                                         (short)5, null, null, null);
-        assertEquals(device, rdevice);
-    }
-
-    
-    /**
-     * Note: Entity expiration does not result in device moved notification.
-     * @throws Exception
-     */
-    public void doTestEntityExpiration() throws Exception {
-        IDeviceListener mockListener =
-                createStrictMock(IDeviceListener.class);
-        mockListener.deviceIPV4AddrChanged(isA(IDevice.class));
-
-        ITopologyService mockTopology = createMock(ITopologyService.class);
-        expect(mockTopology.isAttachmentPointPort(anyLong(),
-                                                  anyShort())).
-                                                  andReturn(true).anyTimes();
-
-        expect(mockTopology.isBroadcastDomainPort(1L, (short)1)).andReturn(false).anyTimes();
-        expect(mockTopology.isBroadcastDomainPort(5L, (short)1)).andReturn(false).anyTimes();
-        expect(mockTopology.getL2DomainId(1L)).andReturn(1L).anyTimes();
-        expect(mockTopology.getL2DomainId(5L)).andReturn(5L).anyTimes();
-        expect(mockTopology.isConsistent(1L, (short)1, 5L, (short)1)).
-        andReturn(false).anyTimes();
-
-        Date topologyUpdateTime = new Date();
-        expect(mockTopology.getLastUpdateTime()).andReturn(topologyUpdateTime).
-        anyTimes();
-
-        replay(mockTopology);
-        deviceManager.topology = mockTopology;
-
-        Calendar c = Calendar.getInstance();
-        Entity entity1 = new Entity(1L, null, 2, 1L, 1, c.getTime());
-        c.add(Calendar.MILLISECOND, -DeviceManagerImpl.ENTITY_TIMEOUT-1);
-        Entity entity2 = new Entity(1L, null, 1, 5L, 1, c.getTime());
-
-        deviceManager.learnDeviceByEntity(entity1);
-        IDevice d = deviceManager.learnDeviceByEntity(entity2);
-        assertArrayEquals(new Integer[] { 1, 2 }, d.getIPv4Addresses());
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1),
-                                             new SwitchPort(5L, 1)},
-                                             d.getAttachmentPoints());
-        Iterator<? extends IDevice> diter =
-                deviceManager.queryClassDevices(d, null, null, 1, null, null);
-        assertTrue(diter.hasNext());
-        assertEquals(d.getDeviceKey(), diter.next().getDeviceKey());
-        diter = deviceManager.queryClassDevices(d, null, null, 2, null, null);
-        assertTrue(diter.hasNext());
-        assertEquals(d.getDeviceKey(), diter.next().getDeviceKey());
-
-
-        deviceManager.addListener(mockListener);
-        replay(mockListener);
-        deviceManager.entityCleanupTask.reschedule(0, null);
-
-        d = deviceManager.getDevice(d.getDeviceKey());
-        assertArrayEquals(new Integer[] { 2 }, d.getIPv4Addresses());
-
-        // Attachment points are not removed, previous ones are still valid.
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1),
-                                             new SwitchPort(5L, 1) },
-                          d.getAttachmentPoints());
-        diter = deviceManager.queryClassDevices(d, null, null, 2, null, null);
-        assertTrue(diter.hasNext());
-        assertEquals(d.getDeviceKey(), diter.next().getDeviceKey());
-        diter = deviceManager.queryClassDevices(d, null, null, 1, null, null);
-        assertFalse(diter.hasNext());
-
-        d = deviceManager.findDevice(1L, null, null, null, null);
-        assertArrayEquals(new Integer[] { 2 }, d.getIPv4Addresses());
-
-        // Attachment points are not removed, previous ones are still valid.
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1),
-                                             new SwitchPort(5L, 1) },
-                          d.getAttachmentPoints());
-
-        verify(mockListener);
-    }
-
-    public void doTestDeviceExpiration() throws Exception {
-        IDeviceListener mockListener =
-                createStrictMock(IDeviceListener.class);
-        mockListener.deviceRemoved(isA(IDevice.class));
-        
-        Calendar c = Calendar.getInstance();
-        c.add(Calendar.MILLISECOND, -DeviceManagerImpl.ENTITY_TIMEOUT-1);
-        Entity entity1 = new Entity(1L, null, 1, 1L, 1, c.getTime());
-        Entity entity2 = new Entity(1L, null, 2, 5L, 1, c.getTime());
-        
-        ITopologyService mockTopology = createMock(ITopologyService.class);
-        deviceManager.topology = mockTopology;
-
-        expect(mockTopology.isAttachmentPointPort(EasyMock.anyLong(),
-                                           EasyMock.anyShort())).
-                                           andReturn(true).
-                                           anyTimes();
-        expect(mockTopology.getL2DomainId(1L)).andReturn(1L).anyTimes();
-        expect(mockTopology.getL2DomainId(5L)).andReturn(1L).anyTimes();
-        expect(mockTopology.isConsistent(EasyMock.anyLong(),
-                                         EasyMock.anyShort(),
-                                         EasyMock.anyLong(),
-                                         EasyMock.anyShort())).andReturn(false).
-                                         anyTimes();
-        expect(mockTopology.isBroadcastDomainPort(EasyMock.anyLong(),
-                                                  EasyMock.anyShort())).
-                                                  andReturn(false).anyTimes();
-        replay(mockTopology);
-
-        IDevice d = deviceManager.learnDeviceByEntity(entity2);
-        d = deviceManager.learnDeviceByEntity(entity1);
-        assertArrayEquals(new Integer[] { 1, 2 }, d.getIPv4Addresses());
-
-        deviceManager.addListener(mockListener);
-        replay(mockListener);
-        deviceManager.entityCleanupTask.reschedule(0, null);
-
-        IDevice r = deviceManager.getDevice(d.getDeviceKey());
-        assertNull(r);
-        Iterator<? extends IDevice> diter =
-                deviceManager.queryClassDevices(d, null, null, 1, null, null);
-        assertFalse(diter.hasNext());
-
-        r = deviceManager.findDevice(1L, null, null, null, null);
-        assertNull(r);
-        
-        verify(mockListener);
-    }
-    
-    /*
-     * A ConcurrentHashMap for devices (deviceMap) that can be used to test 
-     * code that specially handles concurrent modification situations. In
-     * particular, we overwrite values() and will replace / remove all the
-     * elements returned by values. 
-     * 
-     * The remove flag in the constructor specifies if devices returned by 
-     * values() should be removed or replaced.
-     */
-    protected static class ConcurrentlyModifiedDeviceMap
-                            extends ConcurrentHashMap<Long, Device> {
-        private static final long serialVersionUID = 7784938535441180562L;
-        protected boolean remove;
-        public ConcurrentlyModifiedDeviceMap(boolean remove) {
-            super();
-            this.remove = remove;
-        }
-        
-        @Override
-        public Collection<Device> values() {
-            // Get the values from the real map and copy them since
-            // the collection returned by values can reflect changed
-            Collection<Device> devs = new ArrayList<Device>(super.values());
-            for (Device d: devs) {
-                if (remove) {
-                    // We remove the device from the underlying map 
-                    super.remove(d.getDeviceKey());
-                } else {
-                    super.remove(d.getDeviceKey());
-                    // We add a different Device instance with the same
-                    // key to the map. We'll do some hackery so the device
-                    // is different enough to compare differently in equals 
-                    // but otherwise looks the same.
-                    // It's ugly but it works. 
-                    Entity[] curEntities = new Entity[d.getEntities().length];
-                    int i = 0;
-                    // clone entities
-                    for (Entity e: d.getEntities()) {
-                        curEntities[i] = new Entity (e.macAddress,
-                                                     e.vlan,
-                                                     e.ipv4Address,
-                                                     e.switchDPID,
-                                                     e.switchPort,
-                                                     e.lastSeenTimestamp);
-                        if (e.vlan == null) 
-                            curEntities[i].vlan = (short)1;
-                        else 
-                            curEntities[i].vlan = (short)((e.vlan + 1 % 4095)+1);
-                        i++;
-                    }
-                    Device newDevice = new Device(d, curEntities[0]);
-                    newDevice.entities = curEntities;
-                    assertEquals(false, newDevice.equals(d));
-                    super.put(newDevice.getDeviceKey(), newDevice);
-                }
-            }
-            return devs; 
-        }
-    }
-   
-    @Test
-    public void testEntityExpiration() throws Exception {
-        doTestEntityExpiration();
-    }
-    
-    @Test
-    public void testDeviceExpiration() throws Exception {
-        doTestDeviceExpiration();
-    }
-    
-    /* Test correct entity cleanup behavior when a concurrent modification
-     * occurs. 
-     */
-    @Test
-    public void testEntityExpirationConcurrentModification() throws Exception {
-        deviceManager.deviceMap = new ConcurrentlyModifiedDeviceMap(false);
-        doTestEntityExpiration();
-    }
-    
-    /* Test correct entity cleanup behavior when a concurrent remove
-     * occurs. 
-     */
-    @Test
-    public void testDeviceExpirationConcurrentRemove() throws Exception {
-        deviceManager.deviceMap = new ConcurrentlyModifiedDeviceMap(true);
-        doTestDeviceExpiration();
-    }
-    
-    /* Test correct entity cleanup behavior when a concurrent modification
-     * occurs. 
-     */
-    @Test
-    public void testDeviceExpirationConcurrentModification() throws Exception {
-        deviceManager.deviceMap = new ConcurrentlyModifiedDeviceMap(false);
-        doTestDeviceExpiration();
-    }
-    
-
-    @Test
-    public void testAttachmentPointFlapping() throws Exception {
-        Calendar c = Calendar.getInstance();
-
-        ITopologyService mockTopology = createMock(ITopologyService.class);
-        expect(mockTopology.isAttachmentPointPort(anyLong(),
-                                                  anyShort())).andReturn(true).anyTimes();
-        expect(mockTopology.isBroadcastDomainPort(anyLong(),
-                                                  anyShort())).
-                                                  andReturn(false).anyTimes();
-        expect(mockTopology.isInSameBroadcastDomain(anyLong(), anyShort(),
-                                                    anyLong(), anyShort())).andReturn(false).anyTimes();
-        expect(mockTopology.getL2DomainId(anyLong())).
-        andReturn(1L).anyTimes();
-        expect(mockTopology.isConsistent(1L, (short)1, 1L, (short)1)).
-        andReturn(true).anyTimes();
-        expect(mockTopology.isConsistent(1L, (short)1, 5L, (short)1)).
-        andReturn(false).anyTimes();
-        expect(mockTopology.isConsistent(1L, (short)1, 10L, (short)1)).
-        andReturn(false).anyTimes();
-        expect(mockTopology.isConsistent(5L, (short)1, 10L, (short)1)).
-        andReturn(false).anyTimes();
-        expect(mockTopology.isConsistent(10L, (short)1, 1L, (short)1)).
-        andReturn(false).anyTimes();
-        expect(mockTopology.isConsistent(5L, (short)1, 1L, (short)1)).
-        andReturn(false).anyTimes();
-        expect(mockTopology.isConsistent(10L, (short)1, 5L, (short)1)).
-        andReturn(false).anyTimes();
-
-        Date topologyUpdateTime = new Date();
-        expect(mockTopology.getLastUpdateTime()).andReturn(topologyUpdateTime).
-        anyTimes();
-
-
-        replay(mockTopology);
-        deviceManager.topology = mockTopology;
-
-        Entity entity1 = new Entity(1L, null, null, 1L, 1, c.getTime());
-        Entity entity1a = new Entity(1L, null, 1, 1L, 1, c.getTime());
-        Entity entity2 = new Entity(1L, null, null, 5L, 1, c.getTime());
-        Entity entity3 = new Entity(1L, null, null, 10L, 1, c.getTime());
-        entity1.setLastSeenTimestamp(c.getTime());
-        c.add(Calendar.MILLISECOND, Entity.ACTIVITY_TIMEOUT/2);
-        entity1a.setLastSeenTimestamp(c.getTime());
-        c.add(Calendar.MILLISECOND, 1);
-        entity2.setLastSeenTimestamp(c.getTime());
-        c.add(Calendar.MILLISECOND, 1);
-        entity3.setLastSeenTimestamp(c.getTime());
-
-
-
-        IDevice d;
-        d = deviceManager.learnDeviceByEntity(entity1);
-        d = deviceManager.learnDeviceByEntity(entity1a);
-        d = deviceManager.learnDeviceByEntity(entity2);
-        d = deviceManager.learnDeviceByEntity(entity3);
-
-        // all entities are active, so entity3 should win
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(10L, 1) },
-                          d.getAttachmentPoints());
-
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(10L, 1),},
-                              d.getAttachmentPoints(true));
-
-        c.add(Calendar.MILLISECOND, Entity.ACTIVITY_TIMEOUT/4);
-        entity1.setLastSeenTimestamp(c.getTime());
-        d = deviceManager.learnDeviceByEntity(entity1);
-
-        // all are still active; entity3 should still win
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1) },
-                          d.getAttachmentPoints());
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1),
-                                             new SwitchPort(5L, 1,
-                                                            ErrorStatus.DUPLICATE_DEVICE),
-                                                            new SwitchPort(10L, 1,
-                                                                           ErrorStatus.DUPLICATE_DEVICE) },
-                                                                           d.getAttachmentPoints(true));
-
-        c.add(Calendar.MILLISECOND, Entity.ACTIVITY_TIMEOUT+2000);
-        entity1.setLastSeenTimestamp(c.getTime());
-        d = deviceManager.learnDeviceByEntity(entity1);
-
-        assertEquals(entity1.getActiveSince(), entity1.getLastSeenTimestamp());
-        // entity1 should now be the only active entity
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1) },
-                          d.getAttachmentPoints());
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1) },
-                          d.getAttachmentPoints(true));
-    }
-
-
-    @Test
-    public void testAttachmentPointFlappingTwoCluster() throws Exception {
-        Calendar c = Calendar.getInstance();
-
-        ITopologyService mockTopology = createMock(ITopologyService.class);
-        expect(mockTopology.isAttachmentPointPort(anyLong(),
-                                                  anyShort())).andReturn(true).anyTimes();
-        expect(mockTopology.isBroadcastDomainPort(anyLong(),
-                                                  anyShort())).
-                                                  andReturn(false).anyTimes();
-        expect(mockTopology.isInSameBroadcastDomain(anyLong(), anyShort(),
-                                                    anyLong(), anyShort())).andReturn(false).anyTimes();
-        expect(mockTopology.getL2DomainId(1L)).
-        andReturn(1L).anyTimes();
-        expect(mockTopology.getL2DomainId(5L)).
-        andReturn(5L).anyTimes();
-        expect(mockTopology.isConsistent(1L, (short)1, 1L, (short)2)).
-        andReturn(false).anyTimes();
-        expect(mockTopology.isConsistent(1L, (short)2, 5L, (short)1)).
-        andReturn(false).anyTimes();
-        expect(mockTopology.isConsistent(5L, (short)1, 5L, (short)2)).
-        andReturn(false).anyTimes();
-        expect(mockTopology.isConsistent(1L, (short)2, 1L, (short)1)).
-        andReturn(false).anyTimes();
-        expect(mockTopology.isConsistent(1L, (short)1, 5L, (short)1)).
-        andReturn(false).anyTimes();
-        expect(mockTopology.isConsistent(1L, (short)1, 5L, (short)2)).
-        andReturn(false).anyTimes();
-        expect(mockTopology.isConsistent(5L, (short)2, 5L, (short)1)).
-        andReturn(false).anyTimes();
-
-        Date topologyUpdateTime = new Date();
-        expect(mockTopology.getLastUpdateTime()).andReturn(topologyUpdateTime).
-        anyTimes();
-
-        replay(mockTopology);
-        deviceManager.topology = mockTopology;
-
-        Entity entity1 = new Entity(1L, null, null, 1L, 1, c.getTime());
-        Entity entity2 = new Entity(1L, null, null, 1L, 2, c.getTime());
-        Entity entity3 = new Entity(1L, null, null, 5L, 1, c.getTime());
-        Entity entity4 = new Entity(1L, null, null, 5L, 2, c.getTime());
-        entity1.setLastSeenTimestamp(c.getTime());
-        c.add(Calendar.MILLISECOND, Entity.ACTIVITY_TIMEOUT/2);
-        c.add(Calendar.MILLISECOND, 1);
-        entity2.setLastSeenTimestamp(c.getTime());
-        c.add(Calendar.MILLISECOND, 1);
-        entity3.setLastSeenTimestamp(c.getTime());
-        c.add(Calendar.MILLISECOND, 1);
-        entity4.setLastSeenTimestamp(c.getTime());
-
-        deviceManager.learnDeviceByEntity(entity1);
-        deviceManager.learnDeviceByEntity(entity2);
-        deviceManager.learnDeviceByEntity(entity3);
-        IDevice d = deviceManager.learnDeviceByEntity(entity4);
-
-        // all entities are active, so entities 2,4 should win
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 2),
-                                             new SwitchPort(5L, 2) },
-                                             d.getAttachmentPoints());
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 2),
-                                             new SwitchPort(5L, 2)},
-                                             d.getAttachmentPoints(true));
-
-        c.add(Calendar.MILLISECOND, 1);
-        entity1.setLastSeenTimestamp(c.getTime());
-        d = deviceManager.learnDeviceByEntity(entity1);
-
-        // all entities are active, so entities 2,4 should win
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1),
-                                             new SwitchPort(5L, 2) },
-                                             d.getAttachmentPoints());
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1),
-                                             new SwitchPort(5L, 2),
-                                             new SwitchPort(1L, 2, ErrorStatus.DUPLICATE_DEVICE)},
-                                             d.getAttachmentPoints(true));
-
-        c.add(Calendar.MILLISECOND, Entity.ACTIVITY_TIMEOUT+1);
-        entity1.setLastSeenTimestamp(c.getTime());
-        d = deviceManager.learnDeviceByEntity(entity1);
-
-        // entities 3,4 are still in conflict, but 1 should be resolved
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1),
-                                             new SwitchPort(5L, 2) },
-                                             d.getAttachmentPoints());
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1),
-                                             new SwitchPort(5L, 2)},
-                                             d.getAttachmentPoints(true));
-
-        entity3.setLastSeenTimestamp(c.getTime());
-        d = deviceManager.learnDeviceByEntity(entity3);
-
-        // no conflicts, 1 and 3 will win
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1),
-                                             new SwitchPort(5L, 1) },
-                                             d.getAttachmentPoints());
-        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1),
-                                             new SwitchPort(5L, 1) },
-                                             d.getAttachmentPoints(true));
-
-    }
-
-    protected void doTestDeviceQuery() throws Exception {
-        Entity entity1 = new Entity(1L, (short)1, 1, 1L, 1, new Date());
-        Entity entity2 = new Entity(2L, (short)2, 2, 1L, 2, new Date());
-        Entity entity3 = new Entity(3L, (short)3, 3, 5L, 1, new Date());
-        Entity entity4 = new Entity(4L, (short)4, 3, 5L, 2, new Date());
-        Entity entity5 = new Entity(1L, (short)4, 3, 5L, 2, new Date());
-
-        deviceManager.learnDeviceByEntity(entity1);
-        deviceManager.learnDeviceByEntity(entity2);
-        deviceManager.learnDeviceByEntity(entity3);
-        deviceManager.learnDeviceByEntity(entity4);
-
-        Iterator<? extends IDevice> iter =
-                deviceManager.queryDevices(null, (short)1, 1, null, null);
-        int count = 0;
-        while (iter.hasNext()) {
-            count += 1;
-            iter.next();
-        }
-        assertEquals(1, count);
-
-        iter = deviceManager.queryDevices(null, (short)3, 3, null, null);
-        count = 0;
-        while (iter.hasNext()) {
-            count += 1;
-            iter.next();
-        }
-        assertEquals(1, count);
-
-        iter = deviceManager.queryDevices(null, (short)1, 3, null, null);
-        count = 0;
-        while (iter.hasNext()) {
-            count += 1;
-            iter.next();
-        }
-        assertEquals(0, count);
-
-        deviceManager.learnDeviceByEntity(entity5);
-        iter = deviceManager.queryDevices(null, (short)4, 3, null, null);
-        count = 0;
-        while (iter.hasNext()) {
-            count += 1;
-            iter.next();
-        }
-        assertEquals(2, count);
-    }
-
-    @Test
-    public void testDeviceIndex() throws Exception {
-        EnumSet<IDeviceService.DeviceField> indexFields =
-                EnumSet.noneOf(IDeviceService.DeviceField.class);
-        indexFields.add(IDeviceService.DeviceField.IPV4);
-        indexFields.add(IDeviceService.DeviceField.VLAN);
-        deviceManager.addIndex(false, indexFields);
-
-        ITopologyService mockTopology = createMock(ITopologyService.class);
-        deviceManager.topology = mockTopology;
-        expect(mockTopology.isAttachmentPointPort(anyLong(),
-                                                  anyShort())).
-                                                  andReturn(true).anyTimes();
-        expect(mockTopology.getL2DomainId(EasyMock.anyLong())).andReturn(1L).anyTimes();
-        replay(mockTopology);
-        doTestDeviceQuery();
-    }
-
-    @Test
-    public void testDeviceQuery() throws Exception {
-        ITopologyService mockTopology = createMock(ITopologyService.class);
-        deviceManager.topology = mockTopology;
-        expect(mockTopology.isAttachmentPointPort(anyLong(),
-                                                  anyShort())).
-                                                  andReturn(true).anyTimes();
-        expect(mockTopology.getL2DomainId(EasyMock.anyLong())).andReturn(1L).anyTimes();
-        replay(mockTopology);
-        
-        doTestDeviceQuery();
-    }
-
-    protected void doTestDeviceClassQuery() throws Exception {
-        Entity entity1 = new Entity(1L, (short)1, 1, 1L, 1, new Date());
-        Entity entity2 = new Entity(2L, (short)2, 2, 1L, 2, new Date());
-        Entity entity3 = new Entity(3L, (short)3, 3, 5L, 1, new Date());
-        Entity entity4 = new Entity(4L, (short)4, 3, 5L, 2, new Date());
-        Entity entity5 = new Entity(1L, (short)4, 3, 5L, 2, new Date());
-
-        IDevice d = deviceManager.learnDeviceByEntity(entity1);
-        deviceManager.learnDeviceByEntity(entity2);
-        deviceManager.learnDeviceByEntity(entity3);
-        deviceManager.learnDeviceByEntity(entity4);
-
-        Iterator<? extends IDevice> iter =
-                deviceManager.queryClassDevices(d, null,
-                                                (short)1, 1, null, null);
-        int count = 0;
-        while (iter.hasNext()) {
-            count += 1;
-            iter.next();
-        }
-        assertEquals(1, count);
-
-        iter = deviceManager.queryClassDevices(d, null,
-                                               (short)3, 3, null, null);
-        count = 0;
-        while (iter.hasNext()) {
-            count += 1;
-            iter.next();
-        }
-        assertEquals(1, count);
-
-        iter = deviceManager.queryClassDevices(d, null,
-                                               (short)1, 3, null, null);
-        count = 0;
-        while (iter.hasNext()) {
-            count += 1;
-            iter.next();
-        }
-        assertEquals(0, count);
-
-        deviceManager.learnDeviceByEntity(entity5);
-        iter = deviceManager.queryClassDevices(d, null,
-                                               (short)4, 3, null, null);
-        count = 0;
-        while (iter.hasNext()) {
-            count += 1;
-            iter.next();
-        }
-        assertEquals(2, count);
-    }
-
-    @Test
-    public void testDeviceClassIndex() throws Exception {
-        EnumSet<IDeviceService.DeviceField> indexFields =
-                EnumSet.noneOf(IDeviceService.DeviceField.class);
-        indexFields.add(IDeviceService.DeviceField.IPV4);
-        indexFields.add(IDeviceService.DeviceField.VLAN);
-        deviceManager.addIndex(true, indexFields);
-
-        ITopologyService mockTopology = createMock(ITopologyService.class);
-        deviceManager.topology = mockTopology;
-        expect(mockTopology.isAttachmentPointPort(anyLong(),
-                                                  anyShort())).
-                                                  andReturn(true).anyTimes();
-        expect(mockTopology.getL2DomainId(EasyMock.anyLong())).andReturn(1L).anyTimes();
-        replay(mockTopology);
-
-        doTestDeviceClassQuery();
-    }
-
-    @Test
-    public void testDeviceClassQuery() throws Exception {
-        ITopologyService mockTopology = createMock(ITopologyService.class);
-        deviceManager.topology = mockTopology;
-        expect(mockTopology.isAttachmentPointPort(anyLong(),
-                                                  anyShort())).
-                                                  andReturn(true).anyTimes();
-        expect(mockTopology.getL2DomainId(EasyMock.anyLong())).andReturn(1L).anyTimes();
-        replay(mockTopology);
-
-        doTestDeviceClassQuery();
-    }
-
-    @Test
-    public void testFindDevice() {
-        boolean exceptionCaught;
-        deviceManager.entityClassifier= new MockEntityClassifierMac();
-        deviceManager.startUp(null);
-
-        ITopologyService mockTopology = createMock(ITopologyService.class);
-        deviceManager.topology = mockTopology;
-        expect(mockTopology.isAttachmentPointPort(anyLong(),
-                                                  anyShort())).
-                                                  andReturn(true).anyTimes();
-        expect(mockTopology.getL2DomainId(EasyMock.anyLong())).andReturn(1L).anyTimes();
-        replay(mockTopology);
-
-        Entity entity1 = new Entity(1L, (short)1, 1, 1L, 1, new Date());
-        Entity entity2 = new Entity(2L, (short)2, 2, 1L, 2, new Date());
-        Entity entity2b = new Entity(22L, (short)2, 2, 1L, 2, new Date());
-        
-        Entity entity3 = new Entity(3L, (short)1, 3, 2L, 1, new Date());
-        Entity entity4 = new Entity(4L, (short)2, 4, 2L, 2, new Date());
-        
-        Entity entity5 = new Entity(5L, (short)1, 5, 3L, 1, new Date());
-        
-
-        IDevice d1 = deviceManager.learnDeviceByEntity(entity1);
-        IDevice d2 = deviceManager.learnDeviceByEntity(entity2);
-        IDevice d3 = deviceManager.learnDeviceByEntity(entity3);
-        IDevice d4 = deviceManager.learnDeviceByEntity(entity4);
-        IDevice d5 = deviceManager.learnDeviceByEntity(entity5);
-        
-        // Make sure the entity classifier worked as expected
-        assertEquals(MockEntityClassifierMac.testECMac1, d1.getEntityClass());
-        assertEquals(MockEntityClassifierMac.testECMac1, d2.getEntityClass());
-        assertEquals(MockEntityClassifierMac.testECMac2, d3.getEntityClass());
-        assertEquals(MockEntityClassifierMac.testECMac2, d4.getEntityClass());
-        assertEquals(DefaultEntityClassifier.entityClass,
-                     d5.getEntityClass());
-        
-        // Look up the device using findDevice() which uses only the primary
-        // index
-        assertEquals(d1, deviceManager.findDevice(entity1.getMacAddress(), 
-                                                  entity1.getVlan(),
-                                                  entity1.getIpv4Address(),
-                                                  entity1.getSwitchDPID(),
-                                                  entity1.getSwitchPort()));
-        // port changed. Device will be found through class index
-        assertEquals(d1, deviceManager.findDevice(entity1.getMacAddress(), 
-                                                  entity1.getVlan(),
-                                                  entity1.getIpv4Address(),
-                                                  entity1.getSwitchDPID(),
-                                                  entity1.getSwitchPort()+1));
-        // VLAN changed. No device matches
-        assertEquals(null, deviceManager.findDevice(entity1.getMacAddress(), 
-                                                  (short)42,
-                                                  entity1.getIpv4Address(),
-                                                  entity1.getSwitchDPID(),
-                                                  entity1.getSwitchPort()));
-        assertEquals(null, deviceManager.findDevice(entity1.getMacAddress(), 
-                                                  null,
-                                                  entity1.getIpv4Address(),
-                                                  entity1.getSwitchDPID(),
-                                                  entity1.getSwitchPort()));
-        assertEquals(d2, deviceManager.findDeviceByEntity(entity2));
-        assertEquals(null, deviceManager.findDeviceByEntity(entity2b));
-        assertEquals(d3, deviceManager.findDevice(entity3.getMacAddress(), 
-                                                  entity3.getVlan(),
-                                                  entity3.getIpv4Address(),
-                                                  entity3.getSwitchDPID(),
-                                                  entity3.getSwitchPort()));
-        // switch and port not set. throws exception
-        exceptionCaught = false;
-        try {
-            assertEquals(null, deviceManager.findDevice(entity3.getMacAddress(), 
-                                                        entity3.getVlan(),
-                                                        entity3.getIpv4Address(),
-                                                        null,
-                                                        null));
-        } 
-        catch (IllegalArgumentException e) {
-            exceptionCaught = true;
-        }
-        if (!exceptionCaught)
-            fail("findDevice() did not throw IllegalArgumentException");
-        assertEquals(d4, deviceManager.findDeviceByEntity(entity4));
-        assertEquals(d5, deviceManager.findDevice(entity5.getMacAddress(), 
-                                                  entity5.getVlan(),
-                                                  entity5.getIpv4Address(),
-                                                  entity5.getSwitchDPID(),
-                                                  entity5.getSwitchPort()));
-        // switch and port not set. throws exception (swith/port are key 
-        // fields of IEntityClassifier but not d5.entityClass
-        exceptionCaught = false;
-        try {
-            assertEquals(d5, deviceManager.findDevice(entity5.getMacAddress(), 
-                                                      entity5.getVlan(),
-                                                      entity5.getIpv4Address(),
-                                                      null,
-                                                      null));
-        } 
-        catch (IllegalArgumentException e) {
-            exceptionCaught = true;
-        }
-        if (!exceptionCaught)
-            fail("findDevice() did not throw IllegalArgumentException");
-        
-        
-        Entity entityNoClass = new Entity(5L, (short)1, 5, -1L, 1, new Date());
-        assertEquals(null, deviceManager.findDeviceByEntity(entityNoClass));
-        
-        
-        // Now look up destination devices
-        assertEquals(d1, deviceManager.findDestDevice(d2, 
-                                                  entity1.getMacAddress(), 
-                                                  entity1.getVlan(),
-                                                  entity1.getIpv4Address()));
-        assertEquals(d1, deviceManager.findDestDevice(d2, 
-                                                  entity1.getMacAddress(), 
-                                                  entity1.getVlan(),
-                                                  null));
-        assertEquals(null, deviceManager.findDestDevice(d2, 
-                                                  entity1.getMacAddress(), 
-                                                  (short) -1,
-                                                  0));
-    }
-    
-    @Test
-    public void testGetIPv4Addresses() {
-        // Looks like Date is only 1s granularity
-        
-        ITopologyService mockTopology = createMock(ITopologyService.class);
-        deviceManager.topology = mockTopology;
-        expect(mockTopology.isAttachmentPointPort(anyLong(),
-                                                  anyShort())).
-                                                  andReturn(true).anyTimes();
-        expect(mockTopology.getL2DomainId(anyLong())).andReturn(1L).anyTimes();
-        expect(mockTopology.isConsistent(EasyMock.anyLong(),
-                                         EasyMock.anyShort(),
-                                         EasyMock.anyLong(),
-                                         EasyMock.anyShort()))
-                                         .andReturn(false)
-                                         .anyTimes();
-        expect(mockTopology.isBroadcastDomainPort(EasyMock.anyLong(),
-                                                  EasyMock.anyShort()))
-                                                  .andReturn(false)
-                                                  .anyTimes();
-        expect(mockTopology.isInSameBroadcastDomain(EasyMock.anyLong(),
-                                                    EasyMock.anyShort(),
-                                                    EasyMock.anyLong(),
-                                                    EasyMock.anyShort())).
-                                                    andReturn(false).anyTimes();
-        replay(mockTopology);
-
-        Entity e1 = new Entity(1L, (short)1, null, null, null, new Date(2000));
-        Device d1 = deviceManager.learnDeviceByEntity(e1);
-        assertArrayEquals(new Integer[0], d1.getIPv4Addresses());
-        
-        
-        Entity e2 = new Entity(2L, (short)2, 2, null, null, new Date(2000));
-        Device d2 = deviceManager.learnDeviceByEntity(e2);
-        d2 = deviceManager.learnDeviceByEntity(e2);
-        assertArrayEquals(new Integer[] { 2 }, d2.getIPv4Addresses());
-        // More than one entity
-        Entity e2b = new Entity(2L, (short)2, null, 2L, 2, new Date(3000));
-        d2 = deviceManager.learnDeviceByEntity(e2b);
-        assertEquals(2, d2.entities.length);
-        assertArrayEquals(new Integer[] { 2 }, d2.getIPv4Addresses());
-        // and now add an entity with an IP
-        Entity e2c = new Entity(2L, (short)2, 2, 2L, 3, new Date(3000));
-        d2 = deviceManager.learnDeviceByEntity(e2c);
-        assertArrayEquals(new Integer[] { 2 }, d2.getIPv4Addresses());
-        assertEquals(3, d2.entities.length);
-        
-        // Other devices with different IPs shouldn't interfere
-        Entity e3 = new Entity(3L, (short)3, 3, null, null, new Date(4000));
-        Entity e3b = new Entity(3L, (short)3, 3, 3L, 3, new Date(4400));
-        Device d3 = deviceManager.learnDeviceByEntity(e3);
-        d3 = deviceManager.learnDeviceByEntity(e3b);
-        assertArrayEquals(new Integer[] { 2 }, d2.getIPv4Addresses());
-        assertArrayEquals(new Integer[] { 3 }, d3.getIPv4Addresses());
-        
-        // Add another IP to d3
-        Entity e3c = new Entity(3L, (short)3, 33, 3L, 3, new Date(4400));
-        d3 = deviceManager.learnDeviceByEntity(e3c);
-        Integer[] ips = d3.getIPv4Addresses();
-        Arrays.sort(ips);
-        assertArrayEquals(new Integer[] { 3, 33 }, ips);
-        
-        // Add another device that also claims IP2 but is older than e2
-        Entity e4 = new Entity(4L, (short)4, 2, null, null, new Date(1000));
-        Entity e4b = new Entity(4L, (short)4, null, 4L, 4, new Date(1000));
-        Device d4 = deviceManager.learnDeviceByEntity(e4);
-        assertArrayEquals(new Integer[] { 2 }, d2.getIPv4Addresses());
-        assertArrayEquals(new Integer[0],  d4.getIPv4Addresses());
-        // add another entity to d4
-        d4 = deviceManager.learnDeviceByEntity(e4b);
-        assertArrayEquals(new Integer[0], d4.getIPv4Addresses());
-        
-        // Make e4 and e4a newer
-        Entity e4c = new Entity(4L, (short)4, 2, null, null, new Date(5000));
-        Entity e4d = new Entity(4L, (short)4, null, 4L, 5, new Date(5000));
-        d4 = deviceManager.learnDeviceByEntity(e4c);
-        d4 = deviceManager.learnDeviceByEntity(e4d);
-        assertArrayEquals(new Integer[0], d2.getIPv4Addresses());
-        // FIXME: d4 should not return IP4
-        assertArrayEquals(new Integer[] { 2 }, d4.getIPv4Addresses());
-        
-        // Add another newer entity to d2 but with different IP
-        Entity e2d = new Entity(2L, (short)2, 22, 4L, 6, new Date(6000));
-        d2 = deviceManager.learnDeviceByEntity(e2d);
-        assertArrayEquals(new Integer[] { 22 }, d2.getIPv4Addresses());
-        assertArrayEquals(new Integer[] { 2 }, d4.getIPv4Addresses());
-
-        // new IP for d2,d4 but with same timestamp. Both devices get the IP
-        Entity e2e = new Entity(2L, (short)2, 42, 2L, 4, new Date(7000));
-        d2 = deviceManager.learnDeviceByEntity(e2e);
-        ips= d2.getIPv4Addresses();
-        Arrays.sort(ips);
-        assertArrayEquals(new Integer[] { 22, 42 }, ips);
-        Entity e4e = new Entity(4L, (short)4, 42, 4L, 7, new Date(7000));
-        d4 = deviceManager.learnDeviceByEntity(e4e);
-        ips= d4.getIPv4Addresses();
-        Arrays.sort(ips);
-        assertArrayEquals(new Integer[] { 2, 42 }, ips);
-        
-        // add a couple more IPs
-        Entity e2f = new Entity(2L, (short)2, 4242, 2L, 5, new Date(8000));
-        d2 = deviceManager.learnDeviceByEntity(e2f);
-        ips= d2.getIPv4Addresses();
-        Arrays.sort(ips);
-        assertArrayEquals(new Integer[] { 22, 42, 4242 }, ips);
-        Entity e4f = new Entity(4L, (short)4, 4242, 4L, 8, new Date(9000));
-        d4 = deviceManager.learnDeviceByEntity(e4f);
-        ips= d4.getIPv4Addresses();
-        Arrays.sort(ips);
-        assertArrayEquals(new Integer[] { 2, 42, 4242 }, ips);
-    }
-    
-    // TODO: this test should really go into a separate class that collects
-    // unit tests for Device
-    @Test
-    public void testGetSwitchPortVlanId() {
-            Entity entity1 = new Entity(1L, (short)1, null, 10L, 1, new Date());
-            Entity entity2 = new Entity(1L, null, null, 10L, 1, new Date());
-            Entity entity3 = new Entity(1L, (short)3, null,  1L, 1, new Date());
-            Entity entity4 = new Entity(1L, (short)42, null,  1L, 1, new Date());
-            Entity[] entities = new Entity[] { entity1, entity2, 
-                                               entity3, entity4
-                                             };
-            Device d = new Device(null,1L, null, null, Arrays.asList(entities), null);
-            SwitchPort swp1x1 = new SwitchPort(1L, 1);
-            SwitchPort swp1x2 = new SwitchPort(1L, 2);
-            SwitchPort swp2x1 = new SwitchPort(2L, 1);
-            SwitchPort swp10x1 = new SwitchPort(10L, 1);
-            assertArrayEquals(new Short[] { -1, 1}, 
-                              d.getSwitchPortVlanIds(swp10x1));
-            assertArrayEquals(new Short[] { 3, 42}, 
-                              d.getSwitchPortVlanIds(swp1x1));
-            assertArrayEquals(new Short[0],
-                              d.getSwitchPortVlanIds(swp1x2));
-            assertArrayEquals(new Short[0],
-                              d.getSwitchPortVlanIds(swp2x1));
-    }
-    
-    @Test
-    public void testReclassifyDevice() {
-    	MockFlexEntityClassifier flexClassifier = 
-    			new MockFlexEntityClassifier();
-        deviceManager.entityClassifier= flexClassifier;
-        deviceManager.startUp(null);
-
-        ITopologyService mockTopology = createMock(ITopologyService.class);
-        deviceManager.topology = mockTopology;
-        expect(mockTopology.isAttachmentPointPort(anyLong(),
-                                                  anyShort())).
-                                                  andReturn(true).anyTimes();
-        expect(mockTopology.getL2DomainId(anyLong())).andReturn(1L).anyTimes();
-        expect(mockTopology.isConsistent(EasyMock.anyLong(),
-                                         EasyMock.anyShort(),
-                                         EasyMock.anyLong(),
-                                         EasyMock.anyShort()))
-                                         .andReturn(false)
-                                         .anyTimes();
-        expect(mockTopology.isBroadcastDomainPort(EasyMock.anyLong(),
-                                                  EasyMock.anyShort()))
-                                                  .andReturn(false)
-                                                  .anyTimes();
-        replay(mockTopology);
-        
-        //flexClassifier.createTestEntityClass("Class1");
-        
-        Entity entity1 = new Entity(1L, (short)1, 1, 1L, 1, new Date());
-        Entity entity1b = new Entity(1L, (short)2, 1, 1L, 1, new Date());
-        Entity entity2 = new Entity(2L, (short)1, 2, 2L, 2, new Date());
-        Entity entity2b = new Entity(2L, (short)2, 2, 2L, 2, new Date());
-        
-        
-        Device d1 = deviceManager.learnDeviceByEntity(entity1);
-        Device d2 = deviceManager.learnDeviceByEntity(entity2);
-        Device d1b = deviceManager.learnDeviceByEntity(entity1b);
-        Device d2b = deviceManager.learnDeviceByEntity(entity2b);
-        
-        d1 = deviceManager.getDeviceIteratorForQuery(entity1.getMacAddress(), 
-        				entity1.getVlan(), entity1.getIpv4Address(), 
-        				entity1.getSwitchDPID(), entity1.getSwitchPort())
-        				.next();
-        d1b = deviceManager.getDeviceIteratorForQuery(entity1b.getMacAddress(), 
-				entity1b.getVlan(), entity1b.getIpv4Address(), 
-				entity1b.getSwitchDPID(), entity1b.getSwitchPort()).next();
-        
-        assertEquals(d1, d1b);
-        
-        d2 = deviceManager.getDeviceIteratorForQuery(entity2.getMacAddress(), 
-				entity2.getVlan(), entity2.getIpv4Address(), 
-				entity2.getSwitchDPID(), entity2.getSwitchPort()).next();
-        d2b = deviceManager.getDeviceIteratorForQuery(entity2b.getMacAddress(), 
-				entity2b.getVlan(), entity2b.getIpv4Address(), 
-				entity2b.getSwitchDPID(), entity2b.getSwitchPort()).next();
-        assertEquals(d2, d2b);
-        
-        IEntityClass eC1 = flexClassifier.createTestEntityClass("C1");
-        IEntityClass eC2 = flexClassifier.createTestEntityClass("C2");
-        
-        flexClassifier.addVlanEntities((short)1, eC1);
-        flexClassifier.addVlanEntities((short)2, eC1);
-        
-        deviceManager.reclassifyDevice(d1);
-        deviceManager.reclassifyDevice(d2);
-        
-        d1 = deviceManager.deviceMap.get(
-        		deviceManager.primaryIndex.findByEntity(entity1));
-        d1b = deviceManager.deviceMap.get(
-        		deviceManager.primaryIndex.findByEntity(entity1b));
-        
-        assertEquals(d1, d1b);
-        
-        d2 = deviceManager.deviceMap.get(
-        		deviceManager.primaryIndex.findByEntity(entity2));
-        d2b = deviceManager.deviceMap.get(
-        		deviceManager.primaryIndex.findByEntity(entity2b));
-        
-        assertEquals(d2, d2b);
-        				
-        flexClassifier.addVlanEntities((short)1, eC2);
-        
-        deviceManager.reclassifyDevice(d1);
-        deviceManager.reclassifyDevice(d2);
-        d1 = deviceManager.deviceMap.get(
-        		deviceManager.primaryIndex.findByEntity(entity1));
-        d1b = deviceManager.deviceMap.get(
-        		deviceManager.primaryIndex.findByEntity(entity1b));
-        d2 = deviceManager.deviceMap.get(
-        		deviceManager.primaryIndex.findByEntity(entity2));
-        d2b = deviceManager.deviceMap.get(
-        		deviceManager.primaryIndex.findByEntity(entity2b));
-        
-        assertNotSame(d1, d1b);
-       
-        assertNotSame(d2, d2b);
-        
-        flexClassifier.addVlanEntities((short)1, eC1);
-        deviceManager.reclassifyDevice(d1);
-        deviceManager.reclassifyDevice(d2);
-        ClassState classState = deviceManager.classStateMap.get(eC1.getName());
-
-        Long deviceKey1 = null;
-        Long deviceKey1b = null;
-        Long deviceKey2 = null;
-        Long deviceKey2b = null;
-
-        deviceKey1 =
-        		classState.classIndex.findByEntity(entity1);
-        deviceKey1b =
-        		classState.classIndex.findByEntity(entity1b);
-        deviceKey2 =
-        		classState.classIndex.findByEntity(entity2);
-        deviceKey2b =
-        		classState.classIndex.findByEntity(entity2b);
-
-        assertEquals(deviceKey1, deviceKey1b);
-        
-        assertEquals(deviceKey2, deviceKey2b);
-
-
-    }
-}
diff --git a/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceUniqueIndexTest.java b/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceUniqueIndexTest.java
deleted file mode 100644
index 2a6ee9d..0000000
--- a/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceUniqueIndexTest.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/**
-*    Copyright 2012 Big Switch Networks, Inc. 
-* 
-*    Licensed under the Apache License, Version 2.0 (the "License"); you may
-*    not use this file except in compliance with the License. You may obtain
-*    a copy of the License at
-*
-*         http://www.apache.org/licenses/LICENSE-2.0
-*
-*    Unless required by applicable law or agreed to in writing, software
-*    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-*    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-*    License for the specific language governing permissions and limitations
-*    under the License.
-**/
-
-package net.floodlightcontroller.devicemanager.internal;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.Iterator;
-
-import org.junit.Test;
-import net.floodlightcontroller.devicemanager.IDeviceService.DeviceField;
-import junit.framework.TestCase;
-
-/**
- * 
- * @author gregor
- *
- */
-public class DeviceUniqueIndexTest extends TestCase {
-    protected Entity e1a;
-    protected Entity e1b;
-    protected Device d1;
-    protected Entity e2;
-    protected Entity e2alt;
-    protected Entity e3;
-    protected Entity e4;
-    
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        e1a = new Entity(1L, (short)1, 1, 1L, 1, new Date());
-        e1b = new Entity(1L, (short)2, 1, 1L, 1, new Date());
-        List<Entity> d1Entities = new ArrayList<Entity>(2);
-        d1Entities.add(e1a);
-        d1Entities.add(e1b);
-        d1 = new Device(null, Long.valueOf(1), null, null, d1Entities, null);
-        
-        // e2 and e2 alt match in MAC and VLAN
-        e2 = new Entity(2L, (short)2, 2, 2L, 2, new Date());
-        e2alt = new Entity(2, (short)2, null, null, null, null);
-        
-        // IP is null
-        e3 = new Entity(3L, (short)3, null, 3L, 3, new Date());
-        
-        // IP and switch and port are null
-        e4 = new Entity(4L, (short)4, null, null, null, new Date());
-    }
-    
-    /*
-     * Checks that the iterator it returns the elements in the Set expected
-     * Doesn't check how often an element is returned as long it's at least
-     * once
-     */
-    protected void verifyIterator(Set<Long> expected, Iterator<Long> it) {
-        HashSet<Long> actual = new HashSet<Long>();
-        while (it.hasNext()) {
-            actual.add(it.next());
-        }
-        assertEquals(expected, actual);
-    }
-    
-    @Test
-    public void testDeviceUniqueIndex() {
-        DeviceUniqueIndex idx1 = new DeviceUniqueIndex(
-                                             EnumSet.of(DeviceField.MAC, 
-                                                        DeviceField.VLAN));
-        
-        idx1.updateIndex(d1, d1.getDeviceKey());
-        idx1.updateIndex(e2, 2L);
-        
-        //-------------
-        // Test findByEntity lookups
-        assertEquals(Long.valueOf(1L), idx1.findByEntity(e1a));
-        assertEquals(Long.valueOf(1L), idx1.findByEntity(e1b));
-        assertEquals(Long.valueOf(2L), idx1.findByEntity(e2));
-        // we didn't add e2alt but since they key fields are the same we 
-        // should find it 
-        assertEquals(Long.valueOf(2L), idx1.findByEntity(e2alt));
-        assertEquals(null, idx1.findByEntity(e3));
-        assertEquals(null, idx1.findByEntity(e4));
-        
-        //-------------
-        // Test getAll()
-        HashSet<Long> expectedKeys = new HashSet<Long>();
-        expectedKeys.add(1L);
-        expectedKeys.add(2L);
-        verifyIterator(expectedKeys, idx1.getAll());
-        
-                
-        //-------------
-        // Test queryByEntity()
-        verifyIterator(Collections.<Long>singleton(1L), 
-                       idx1.queryByEntity(e1a));
-        verifyIterator(Collections.<Long>singleton(1L), 
-                       idx1.queryByEntity(e1b));
-        verifyIterator(Collections.<Long>singleton(2L), 
-                       idx1.queryByEntity(e2));
-        verifyIterator(Collections.<Long>singleton(2L),
-                       idx1.queryByEntity(e2alt));
-        assertEquals(false, idx1.queryByEntity(e3).hasNext());
-        assertEquals(false, idx1.queryByEntity(e3).hasNext());
-        
-        
-        //-------------
-        // Test removal
-        idx1.removeEntity(e1a, 42L); // No-op. e1a isn't mapped to this key
-        assertEquals(Long.valueOf(1L), idx1.findByEntity(e1a));
-        idx1.removeEntity(e1a, 1L); 
-        assertEquals(null, idx1.findByEntity(e1a));
-        assertEquals(Long.valueOf(1L), idx1.findByEntity(e1b));
-        assertEquals(Long.valueOf(2L), idx1.findByEntity(e2));
-        idx1.removeEntity(e2);  
-        assertEquals(null, idx1.findByEntity(e2));
-        assertEquals(Long.valueOf(1L), idx1.findByEntity(e1b));
-        
-        
-        //-------------
-        // Test null keys
-        DeviceUniqueIndex idx2 = new DeviceUniqueIndex(
-                                             EnumSet.of(DeviceField.IPV4,
-                                                        DeviceField.SWITCH));
-        // only one key field is null
-        idx2.updateIndex(e3, 3L);
-        assertEquals(Long.valueOf(3L), idx2.findByEntity(e3));
-        e3.ipv4Address = 3;
-        assertEquals(null, idx2.findByEntity(e3));
-        // all key fields are null
-        idx2.updateIndex(e4, 4L);
-        assertEquals(null, idx2.findByEntity(e4));
-        Device d4 = new Device(null, 4L, null, null, Collections.<Entity>singleton(e4), null);
-        idx2.updateIndex(d4, 4L);
-        assertEquals(null, idx2.findByEntity(e4));
-        
-        
-
-        //-------------
-        // entity already exists with different deviceKey
-        DeviceUniqueIndex idx3 = new DeviceUniqueIndex(
-                                             EnumSet.of(DeviceField.MAC, 
-                                                        DeviceField.VLAN));
-        idx3.updateIndex(e1a, 42L);
-        assertEquals(false, idx3.updateIndex(d1, 1L));
-        // TODO: shouldn't this fail as well so that the behavior
-        // is consistent?
-        idx3.updateIndex(e1a, 1L);
-        // anyways. We can now add d1 ;-)
-        assertEquals(true, idx3.updateIndex(d1, 1L));
-    }
-}
diff --git a/src/test/java/net/floodlightcontroller/devicemanager/test/MockDevice.java b/src/test/java/net/floodlightcontroller/devicemanager/test/MockDevice.java
deleted file mode 100644
index 5460ea3..0000000
--- a/src/test/java/net/floodlightcontroller/devicemanager/test/MockDevice.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
-*    Copyright 2011,2012 Big Switch Networks, Inc. 
-*    Originally created by David Erickson, Stanford University
-* 
-*    Licensed under the Apache License, Version 2.0 (the "License"); you may
-*    not use this file except in compliance with the License. You may obtain
-*    a copy of the License at
-*
-*         http://www.apache.org/licenses/LICENSE-2.0
-*
-*    Unless required by applicable law or agreed to in writing, software
-*    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-*    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-*    License for the specific language governing permissions and limitations
-*    under the License.
-**/
-
-package net.floodlightcontroller.devicemanager.test;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.TreeSet;
-
-import net.floodlightcontroller.devicemanager.IEntityClass;
-import net.floodlightcontroller.devicemanager.SwitchPort;
-import net.floodlightcontroller.devicemanager.internal.AttachmentPoint;
-import net.floodlightcontroller.devicemanager.internal.Device;
-import net.floodlightcontroller.devicemanager.internal.DeviceManagerImpl;
-import net.floodlightcontroller.devicemanager.internal.Entity;
-
-/**
- * This mock device removes the dependency on topology and a parent device
- * manager and simply assumes all its entities are current and correct
- */
-public class MockDevice extends Device {
-
-    public MockDevice(DeviceManagerImpl deviceManager,
-                      Long deviceKey,
-                      Entity entity, 
-                      IEntityClass entityClass)  {
-        super(deviceManager, deviceKey, entity, entityClass);
-    }
-
-    public MockDevice(Device device, Entity newEntity) {
-        super(device, newEntity);
-    }
-    
-    public MockDevice(DeviceManagerImpl deviceManager, Long deviceKey,
-                      List<AttachmentPoint> aps,
-                      List<AttachmentPoint> trueAPs,
-                      Collection<Entity> entities,
-                      IEntityClass entityClass) {
-        super(deviceManager, deviceKey, aps, trueAPs, entities, entityClass);
-    }
-
-    @Override
-    public Integer[] getIPv4Addresses() {
-        TreeSet<Integer> vals = new TreeSet<Integer>();
-        for (Entity e : entities) {
-            if (e.getIpv4Address() == null) continue;
-            vals.add(e.getIpv4Address());
-        }
-        
-        return vals.toArray(new Integer[vals.size()]);
-    }
-
-    @Override
-    public SwitchPort[] getAttachmentPoints() {
-        ArrayList<SwitchPort> vals = 
-                new ArrayList<SwitchPort>(entities.length);
-        for (Entity e : entities) {
-            if (e.getSwitchDPID() != null &&
-                e.getSwitchPort() != null &&
-                deviceManager.isValidAttachmentPoint(e.getSwitchDPID(), e.getSwitchPort())) {
-                SwitchPort sp = new SwitchPort(e.getSwitchDPID(), 
-                                               e.getSwitchPort());
-                vals.add(sp);
-            }
-        }
-        return vals.toArray(new SwitchPort[vals.size()]);
-    }
-    
-    @Override
-    public String toString() {
-        String rv = "MockDevice[entities=+";
-        rv += entities.toString();
-        rv += "]";
-        return rv;
-    }
-}
diff --git a/src/test/java/net/floodlightcontroller/devicemanager/test/MockDeviceManager.java b/src/test/java/net/floodlightcontroller/devicemanager/test/MockDeviceManager.java
deleted file mode 100644
index 8b539f6..0000000
--- a/src/test/java/net/floodlightcontroller/devicemanager/test/MockDeviceManager.java
+++ /dev/null
@@ -1,103 +0,0 @@
-package net.floodlightcontroller.devicemanager.test;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.Set;
-
-import net.floodlightcontroller.devicemanager.IDevice;
-import net.floodlightcontroller.devicemanager.IDeviceListener;
-import net.floodlightcontroller.devicemanager.IEntityClass;
-import net.floodlightcontroller.devicemanager.IEntityClassifierService;
-import net.floodlightcontroller.devicemanager.internal.AttachmentPoint;
-import net.floodlightcontroller.devicemanager.internal.Device;
-import net.floodlightcontroller.devicemanager.internal.DeviceManagerImpl;
-import net.floodlightcontroller.devicemanager.internal.Entity;
-
-/**
- * Mock device manager useful for unit tests
- * @author readams
- */
-public class MockDeviceManager extends DeviceManagerImpl {
-    /**
-     * Set a new IEntityClassifier
-     * Use this as a quick way to use a particular entity classifier in a 
-     * single test without having to setup the full FloodlightModuleContext
-     * again.
-     * @param ecs 
-     */
-    public void setEntityClassifier(IEntityClassifierService ecs) {
-        this.entityClassifier = ecs;
-        this.startUp(null);
-    }
-    
-    /**
-     * Learn a device using the given characteristics. 
-     * @param macAddress the MAC
-     * @param vlan the VLAN (can be null)
-     * @param ipv4Address the IP (can be null)
-     * @param switchDPID the attachment point switch DPID (can be null)
-     * @param switchPort the attachment point switch port (can be null)
-     * @param processUpdates if false, will not send updates.  Note that this 
-     * method is not thread safe if this is false
-     * @return the device, either new or not
-     */
-    public IDevice learnEntity(long macAddress, Short vlan, 
-                               Integer ipv4Address, Long switchDPID, 
-                               Integer switchPort,
-                               boolean processUpdates) {
-        Set<IDeviceListener> listeners = deviceListeners;
-        if (!processUpdates) {
-            deviceListeners = Collections.<IDeviceListener>emptySet();
-        }
-        
-        if (vlan != null && vlan.shortValue() <= 0)
-            vlan = null;
-        if (ipv4Address != null && ipv4Address == 0)
-            ipv4Address = null;
-        IDevice res =  learnDeviceByEntity(new Entity(macAddress, vlan, 
-                                                      ipv4Address, switchDPID, 
-                                                      switchPort, new Date()));
-        deviceListeners = listeners;
-        return res;
-    }
-    
-    /**
-     * Learn a device using the given characteristics. 
-     * @param macAddress the MAC
-     * @param vlan the VLAN (can be null)
-     * @param ipv4Address the IP (can be null)
-     * @param switchDPID the attachment point switch DPID (can be null)
-     * @param switchPort the attachment point switch port (can be null)
-     * @return the device, either new or not
-     */
-    public IDevice learnEntity(long macAddress, Short vlan, 
-                               Integer ipv4Address, Long switchDPID, 
-                               Integer switchPort) {
-        return learnEntity(macAddress, vlan, ipv4Address, 
-                           switchDPID, switchPort, true);
-    }
-
-    @Override
-    protected Device allocateDevice(Long deviceKey,
-                                    Entity entity, 
-                                    IEntityClass entityClass) {
-        return new MockDevice(this, deviceKey, entity, entityClass);
-    }
-    
-    @Override
-    protected Device allocateDevice(Long deviceKey,
-                                    List<AttachmentPoint> aps,
-                                    List<AttachmentPoint> trueAPs,
-                                    Collection<Entity> entities,
-                                    IEntityClass entityClass) {
-        return new MockDevice(this, deviceKey, aps, trueAPs, entities, entityClass);
-    }
-    
-    @Override
-    protected Device allocateDevice(Device device,
-                                    Entity entity) {
-        return new MockDevice(device, entity);
-    }
-}
diff --git a/src/test/java/net/floodlightcontroller/devicemanager/test/MockEntityClassifier.java b/src/test/java/net/floodlightcontroller/devicemanager/test/MockEntityClassifier.java
deleted file mode 100644
index 679dc9a..0000000
--- a/src/test/java/net/floodlightcontroller/devicemanager/test/MockEntityClassifier.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package net.floodlightcontroller.devicemanager.test;
-
-import static net.floodlightcontroller.devicemanager.IDeviceService.DeviceField.MAC;
-import static net.floodlightcontroller.devicemanager.IDeviceService.DeviceField.PORT;
-import static net.floodlightcontroller.devicemanager.IDeviceService.DeviceField.SWITCH;
-import static net.floodlightcontroller.devicemanager.IDeviceService.DeviceField.VLAN;
-
-import java.util.EnumSet;
-
-import net.floodlightcontroller.devicemanager.IDeviceService;
-import net.floodlightcontroller.devicemanager.IEntityClass;
-import net.floodlightcontroller.devicemanager.IDeviceService.DeviceField;
-import net.floodlightcontroller.devicemanager.internal.DefaultEntityClassifier;
-import net.floodlightcontroller.devicemanager.internal.Entity;
-
-/** A simple IEntityClassifier. Useful for tests that need IEntityClassifiers 
- * and IEntityClass'es with switch and/or port key fields 
- */
-public class MockEntityClassifier extends DefaultEntityClassifier {
-    public static class TestEntityClass implements IEntityClass {
-        @Override
-        public EnumSet<DeviceField> getKeyFields() {
-            return EnumSet.of(MAC, VLAN, SWITCH, PORT);
-        }
-
-        @Override
-        public String getName() {
-            return "TestEntityClass";
-        }
-    }
-    public static IEntityClass testEC = 
-            new MockEntityClassifier.TestEntityClass();
-    
-    @Override
-    public IEntityClass classifyEntity(Entity entity) {
-        if (entity.getSwitchDPID() >= 10L) {
-            return testEC;
-        }
-        return DefaultEntityClassifier.entityClass;
-    }
-
-    @Override
-    public EnumSet<IDeviceService.DeviceField> getKeyFields() {
-        return EnumSet.of(MAC, VLAN, SWITCH, PORT);
-    }
-
-}
\ No newline at end of file
diff --git a/src/test/java/net/floodlightcontroller/devicemanager/test/MockEntityClassifierMac.java b/src/test/java/net/floodlightcontroller/devicemanager/test/MockEntityClassifierMac.java
deleted file mode 100644
index 398b6c0..0000000
--- a/src/test/java/net/floodlightcontroller/devicemanager/test/MockEntityClassifierMac.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package net.floodlightcontroller.devicemanager.test;
-
-import static net.floodlightcontroller.devicemanager.IDeviceService.DeviceField.MAC;
-import static net.floodlightcontroller.devicemanager.IDeviceService.DeviceField.PORT;
-import static net.floodlightcontroller.devicemanager.IDeviceService.DeviceField.SWITCH;
-import static net.floodlightcontroller.devicemanager.IDeviceService.DeviceField.VLAN;
-
-import java.util.EnumSet;
-
-import net.floodlightcontroller.devicemanager.IDeviceService;
-import net.floodlightcontroller.devicemanager.IEntityClass;
-import net.floodlightcontroller.devicemanager.IDeviceService.DeviceField;
-import net.floodlightcontroller.devicemanager.internal.DefaultEntityClassifier;
-import net.floodlightcontroller.devicemanager.internal.Entity;
-
-/** A simple IEntityClassifier. Useful for tests that need an IEntityClassifier
- * with switch/port as key fields. 
- */
-public class MockEntityClassifierMac extends DefaultEntityClassifier {
-    public static class TestEntityClassMac implements IEntityClass {
-        protected String name;
-        public TestEntityClassMac(String name) {
-            this.name = name;
-        }
-        
-        @Override
-        public EnumSet<DeviceField> getKeyFields() {
-            return EnumSet.of(MAC, VLAN);
-        }
-
-        @Override
-        public String getName() {
-            return name;
-        }
-    }
-    public static IEntityClass testECMac1 = 
-            new MockEntityClassifierMac.TestEntityClassMac("testECMac1");
-    public static IEntityClass testECMac2 = 
-            new MockEntityClassifierMac.TestEntityClassMac("testECMac2");
-    
-    @Override
-    public IEntityClass classifyEntity(Entity entity) {
-        if (entity.getSwitchDPID() == 1L) {
-            return testECMac1;
-        } else if (entity.getSwitchDPID() == 2L) {
-            return testECMac2;
-        } else if (entity.getSwitchDPID() == -1L) {
-            return null;
-        }
-        return DefaultEntityClassifier.entityClass;
-    }
-
-    @Override
-    public EnumSet<IDeviceService.DeviceField> getKeyFields() {
-        return EnumSet.of(MAC, VLAN, SWITCH, PORT);
-    }
-}
\ No newline at end of file
diff --git a/src/test/java/net/floodlightcontroller/devicemanager/test/MockFlexEntityClassifier.java b/src/test/java/net/floodlightcontroller/devicemanager/test/MockFlexEntityClassifier.java
deleted file mode 100644
index 2224551..0000000
--- a/src/test/java/net/floodlightcontroller/devicemanager/test/MockFlexEntityClassifier.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- * 
- */
-package net.floodlightcontroller.devicemanager.test;
-
-import static net.floodlightcontroller.devicemanager.IDeviceService.DeviceField.MAC;
-import static net.floodlightcontroller.devicemanager.IDeviceService.DeviceField.PORT;
-import static net.floodlightcontroller.devicemanager.IDeviceService.DeviceField.SWITCH;
-import static net.floodlightcontroller.devicemanager.IDeviceService.DeviceField.VLAN;
-
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Map;
-
-import net.floodlightcontroller.devicemanager.IDeviceService;
-import net.floodlightcontroller.devicemanager.IEntityClass;
-import net.floodlightcontroller.devicemanager.IDeviceService.DeviceField;
-import net.floodlightcontroller.devicemanager.internal.DefaultEntityClassifier;
-import net.floodlightcontroller.devicemanager.internal.Entity;
-
-/**
- * Extension to simple entity classifier to help in unit tests to provide table
- * based multiple entity classification mock for reclassification tests
- *
- */
-public class MockFlexEntityClassifier extends DefaultEntityClassifier {
-	Map <Long, IEntityClass> switchEntities;
-	Map <Short, IEntityClass> vlanEntities;
-	
-    public static class TestEntityClass implements IEntityClass {
-    	String name;
-    	public TestEntityClass(String name) {
-    		this.name = name;
-    	}
-        @Override
-        public EnumSet<DeviceField> getKeyFields() {
-            return EnumSet.of(MAC);
-        }
-
-        @Override
-        public String getName() {
-            return name;
-        }
-    }
-    public static IEntityClass defaultClass = new TestEntityClass("default");
-    public MockFlexEntityClassifier() {
-    	switchEntities = new HashMap<Long, IEntityClass> ();
-    	vlanEntities = new HashMap<Short, IEntityClass> ();
-    }
-    public IEntityClass createTestEntityClass(String name) {
-    	return new TestEntityClass(name);
-    }
-    
-    public void addSwitchEntity(Long dpid, IEntityClass entityClass) {
-    	switchEntities.put(dpid, entityClass);
-    }
-    public void removeSwitchEntity(Long dpid) {
-    	switchEntities.remove(dpid);
-    }
-    public void addVlanEntities(Short vlan, IEntityClass entityClass) {
-    	vlanEntities.put(vlan, entityClass);
-    }
-    public void removeVlanEntities(Short vlan) {
-    	vlanEntities.remove(vlan);
-    }
-    @Override
-    public IEntityClass classifyEntity(Entity entity) {
-        if (switchEntities.containsKey(entity.getSwitchDPID()))
-        	return switchEntities.get(entity.getSwitchDPID());
-        if (vlanEntities.containsKey(entity.getVlan()))
-        	return vlanEntities.get(entity.getVlan());
-        return defaultClass;
-    }
-    @Override
-    public EnumSet<IDeviceService.DeviceField> getKeyFields() {
-        return EnumSet.of(MAC, VLAN, SWITCH, PORT);
-    }
-}
diff --git a/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java b/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java
deleted file mode 100644
index f29c319..0000000
--- a/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java
+++ /dev/null
@@ -1,518 +0,0 @@
-/**
-*    Copyright 2011, Big Switch Networks, Inc. 
-*    Originally created by David Erickson, Stanford University
-* 
-*    Licensed under the Apache License, Version 2.0 (the "License"); you may
-*    not use this file except in compliance with the License. You may obtain
-*    a copy of the License at
-*
-*         http://www.apache.org/licenses/LICENSE-2.0
-*
-*    Unless required by applicable law or agreed to in writing, software
-*    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-*    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-*    License for the specific language governing permissions and limitations
-*    under the License.
-**/
-
-package net.floodlightcontroller.forwarding;
-
-import static org.easymock.EasyMock.anyLong;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.anyShort;
-import static org.easymock.EasyMock.capture;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.easymock.EasyMock.verify;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import net.floodlightcontroller.core.FloodlightContext;
-import net.floodlightcontroller.core.IFloodlightProviderService;
-import net.floodlightcontroller.core.IOFSwitch;
-import net.floodlightcontroller.core.module.FloodlightModuleContext;
-import net.floodlightcontroller.core.test.MockFloodlightProvider;
-import net.floodlightcontroller.core.test.MockThreadPoolService;
-import net.floodlightcontroller.devicemanager.IDevice;
-import net.floodlightcontroller.devicemanager.IDeviceService;
-import net.floodlightcontroller.devicemanager.IEntityClassifierService;
-import net.floodlightcontroller.devicemanager.internal.DefaultEntityClassifier;
-import net.floodlightcontroller.devicemanager.test.MockDeviceManager;
-import net.floodlightcontroller.packet.Data;
-import net.floodlightcontroller.packet.Ethernet;
-import net.floodlightcontroller.packet.IPacket;
-import net.floodlightcontroller.packet.IPv4;
-import net.floodlightcontroller.packet.UDP;
-import net.floodlightcontroller.routing.IRoutingService;
-import net.floodlightcontroller.routing.Route;
-import net.floodlightcontroller.test.FloodlightTestCase;
-import net.floodlightcontroller.threadpool.IThreadPoolService;
-import net.floodlightcontroller.topology.ITopologyListener;
-import net.floodlightcontroller.topology.ITopologyService;
-import net.floodlightcontroller.topology.NodePortTuple;
-
-import org.easymock.Capture;
-import org.easymock.CaptureType;
-import org.easymock.EasyMock;
-import org.junit.Test;
-import org.openflow.protocol.OFFeaturesReply;
-import org.openflow.protocol.OFFlowMod;
-import org.openflow.protocol.OFMatch;
-import org.openflow.protocol.OFMessage;
-import org.openflow.protocol.OFPacketIn;
-import org.openflow.protocol.OFPacketIn.OFPacketInReason;
-import org.openflow.protocol.OFPacketOut;
-import org.openflow.protocol.OFPort;
-import org.openflow.protocol.OFType;
-import org.openflow.protocol.action.OFAction;
-import org.openflow.protocol.action.OFActionOutput;
-import org.openflow.util.HexString;
-
-public class ForwardingTest extends FloodlightTestCase {
-    protected MockFloodlightProvider mockFloodlightProvider;
-    protected FloodlightContext cntx;
-    protected MockDeviceManager deviceManager;
-    protected IRoutingService routingEngine;
-    protected Forwarding forwarding;
-    protected ITopologyService topology;
-    protected MockThreadPoolService threadPool;
-    protected IOFSwitch sw1, sw2;
-    protected OFFeaturesReply swFeatures;
-    protected IDevice srcDevice, dstDevice1, dstDevice2;
-    protected OFPacketIn packetIn;
-    protected OFPacketOut packetOut;
-    protected OFPacketOut packetOutFlooded;
-    protected IPacket testPacket;
-    protected byte[] testPacketSerialized;
-    protected int expected_wildcards;
-    protected Date currentDate;
-    
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
-
-        cntx = new FloodlightContext();
-        
-        // Module loader setup
-        /*
-        Collection<Class<? extends IFloodlightModule>> mods = new ArrayList<Class<? extends IFloodlightModule>>();
-        Collection<IFloodlightService> mockedServices = new ArrayList<IFloodlightService>();
-        mods.add(Forwarding.class);
-        routingEngine = createMock(IRoutingService.class);
-        topology = createMock(ITopologyService.class);
-        mockedServices.add(routingEngine);
-        mockedServices.add(topology);
-        FloodlightTestModuleLoader fml = new FloodlightTestModuleLoader();
-        fml.setupModules(mods, mockedServices);
-        mockFloodlightProvider =
-        		(MockFloodlightProvider) fml.getModuleByName(MockFloodlightProvider.class);
-        deviceManager =
-        		(MockDeviceManager) fml.getModuleByName(MockDeviceManager.class);
-        threadPool =
-        		(MockThreadPoolService) fml.getModuleByName(MockThreadPoolService.class);
-        forwarding =
-        		(Forwarding) fml.getModuleByName(Forwarding.class);
-        */
-        mockFloodlightProvider = getMockFloodlightProvider();
-        forwarding = new Forwarding();
-        threadPool = new MockThreadPoolService();
-        deviceManager = new MockDeviceManager();
-        routingEngine = createMock(IRoutingService.class);
-        topology = createMock(ITopologyService.class);
-        DefaultEntityClassifier entityClassifier = new DefaultEntityClassifier();
-
-
-        FloodlightModuleContext fmc = new FloodlightModuleContext();
-        fmc.addService(IFloodlightProviderService.class, 
-                       mockFloodlightProvider);
-        fmc.addService(IThreadPoolService.class, threadPool);
-        fmc.addService(ITopologyService.class, topology);
-        fmc.addService(IRoutingService.class, routingEngine);
-        fmc.addService(IDeviceService.class, deviceManager);
-        fmc.addService(IEntityClassifierService.class, entityClassifier);
-
-        topology.addListener(anyObject(ITopologyListener.class));
-        expectLastCall().anyTimes();
-        replay(topology);
-        threadPool.init(fmc);
-        forwarding.init(fmc);
-        deviceManager.init(fmc);
-        entityClassifier.init(fmc);
-        threadPool.startUp(fmc);
-        deviceManager.startUp(fmc);
-        forwarding.startUp(fmc);
-        entityClassifier.startUp(fmc);
-        verify(topology);
-        
-        swFeatures = new OFFeaturesReply();
-        swFeatures.setBuffers(1000);
-        // Mock switches
-        sw1 = EasyMock.createMock(IOFSwitch.class);
-        expect(sw1.getId()).andReturn(1L).anyTimes();
-        expect(sw1.getBuffers()).andReturn(swFeatures.getBuffers()).anyTimes();
-        expect(sw1.getStringId())
-                .andReturn(HexString.toHexString(1L)).anyTimes();
-
-        sw2 = EasyMock.createMock(IOFSwitch.class);  
-        expect(sw2.getId()).andReturn(2L).anyTimes();
-        expect(sw2.getBuffers()).andReturn(swFeatures.getBuffers()).anyTimes();
-        expect(sw2.getStringId())
-                .andReturn(HexString.toHexString(2L)).anyTimes();
-
-        //fastWilcards mocked as this constant
-        int fastWildcards = 
-                OFMatch.OFPFW_IN_PORT | 
-                OFMatch.OFPFW_NW_PROTO | 
-                OFMatch.OFPFW_TP_SRC | 
-                OFMatch.OFPFW_TP_DST | 
-                OFMatch.OFPFW_NW_SRC_ALL | 
-                OFMatch.OFPFW_NW_DST_ALL |
-                OFMatch.OFPFW_NW_TOS;
-
-        expect(sw1.getAttribute(IOFSwitch.PROP_FASTWILDCARDS)).andReturn((Integer)fastWildcards).anyTimes();
-        expect(sw1.hasAttribute(IOFSwitch.PROP_SUPPORTS_OFPP_TABLE)).andReturn(true).anyTimes();
-
-        expect(sw2.getAttribute(IOFSwitch.PROP_FASTWILDCARDS)).andReturn((Integer)fastWildcards).anyTimes();
-        expect(sw2.hasAttribute(IOFSwitch.PROP_SUPPORTS_OFPP_TABLE)).andReturn(true).anyTimes();
-
-        // Load the switch map
-        Map<Long, IOFSwitch> switches = new HashMap<Long, IOFSwitch>();
-        switches.put(1L, sw1);
-        switches.put(2L, sw2);
-        mockFloodlightProvider.setSwitches(switches);
-
-        // Build test packet
-        testPacket = new Ethernet()
-            .setDestinationMACAddress("00:11:22:33:44:55")
-            .setSourceMACAddress("00:44:33:22:11:00")
-            .setEtherType(Ethernet.TYPE_IPv4)
-            .setPayload(
-                new IPv4()
-                .setTtl((byte) 128)
-                .setSourceAddress("192.168.1.1")
-                .setDestinationAddress("192.168.1.2")
-                .setPayload(new UDP()
-                            .setSourcePort((short) 5000)
-                            .setDestinationPort((short) 5001)
-                            .setPayload(new Data(new byte[] {0x01}))));
-
-
-
-        currentDate = new Date();
-        
-        // Mock Packet-in
-        testPacketSerialized = testPacket.serialize();
-        packetIn = 
-                ((OFPacketIn) mockFloodlightProvider.getOFMessageFactory().
-                        getMessage(OFType.PACKET_IN))
-                        .setBufferId(-1)
-                        .setInPort((short) 1)
-                        .setPacketData(testPacketSerialized)
-                        .setReason(OFPacketInReason.NO_MATCH)
-                        .setTotalLength((short) testPacketSerialized.length);
-
-        // Mock Packet-out
-        packetOut = 
-                (OFPacketOut) mockFloodlightProvider.getOFMessageFactory().
-                    getMessage(OFType.PACKET_OUT);
-        packetOut.setBufferId(this.packetIn.getBufferId())
-            .setInPort(this.packetIn.getInPort());
-        List<OFAction> poactions = new ArrayList<OFAction>();
-        poactions.add(new OFActionOutput((short) 3, (short) 0xffff));
-        packetOut.setActions(poactions)
-            .setActionsLength((short) OFActionOutput.MINIMUM_LENGTH)
-            .setPacketData(testPacketSerialized)
-            .setLengthU(OFPacketOut.MINIMUM_LENGTH+
-                        packetOut.getActionsLength()+
-                        testPacketSerialized.length);
-        
-        // Mock Packet-out with OFPP_FLOOD action
-        packetOutFlooded = 
-                (OFPacketOut) mockFloodlightProvider.getOFMessageFactory().
-                    getMessage(OFType.PACKET_OUT);
-        packetOutFlooded.setBufferId(this.packetIn.getBufferId())
-            .setInPort(this.packetIn.getInPort());
-        poactions = new ArrayList<OFAction>();
-        poactions.add(new OFActionOutput(OFPort.OFPP_FLOOD.getValue(), 
-                                         (short) 0xffff));
-        packetOutFlooded.setActions(poactions)
-            .setActionsLength((short) OFActionOutput.MINIMUM_LENGTH)
-            .setPacketData(testPacketSerialized)
-            .setLengthU(OFPacketOut.MINIMUM_LENGTH+
-                        packetOutFlooded.getActionsLength()+
-                        testPacketSerialized.length);
-
-        expected_wildcards = fastWildcards;
-        expected_wildcards &= ~OFMatch.OFPFW_IN_PORT & 
-                              ~OFMatch.OFPFW_DL_VLAN &
-                              ~OFMatch.OFPFW_DL_SRC & 
-                              ~OFMatch.OFPFW_DL_DST;
-        expected_wildcards &= ~OFMatch.OFPFW_NW_SRC_MASK & 
-                              ~OFMatch.OFPFW_NW_DST_MASK;
-
-        IFloodlightProviderService.bcStore.
-            put(cntx, 
-                IFloodlightProviderService.CONTEXT_PI_PAYLOAD, 
-                (Ethernet)testPacket);
-    }
-    
-    enum DestDeviceToLearn { NONE, DEVICE1 ,DEVICE2 };
-    public void learnDevices(DestDeviceToLearn destDeviceToLearn) {
-        // Build src and dest devices
-        byte[] dataLayerSource = ((Ethernet)testPacket).getSourceMACAddress();
-        byte[] dataLayerDest = 
-                ((Ethernet)testPacket).getDestinationMACAddress();
-        int networkSource =
-                ((IPv4)((Ethernet)testPacket).getPayload()).
-                    getSourceAddress();
-        int networkDest = 
-                ((IPv4)((Ethernet)testPacket).getPayload()).
-                    getDestinationAddress();
-        
-        reset(topology);
-        expect(topology.isAttachmentPointPort(1L, (short)1))
-                                              .andReturn(true)
-                                              .anyTimes();
-        expect(topology.isAttachmentPointPort(2L, (short)3))
-                                              .andReturn(true)
-                                              .anyTimes();
-        expect(topology.isAttachmentPointPort(1L, (short)3))
-                                              .andReturn(true)
-                                              .anyTimes();
-        replay(topology);
-
-        srcDevice = 
-                deviceManager.learnEntity(Ethernet.toLong(dataLayerSource), 
-                                          null, networkSource,
-                                          1L, 1);
-        IDeviceService.fcStore. put(cntx, 
-                                    IDeviceService.CONTEXT_SRC_DEVICE,
-                                    srcDevice);
-        if (destDeviceToLearn == DestDeviceToLearn.DEVICE1) {
-            dstDevice1 = 
-                    deviceManager.learnEntity(Ethernet.toLong(dataLayerDest), 
-                                              null, networkDest,
-                                              2L, 3);
-            IDeviceService.fcStore.put(cntx, 
-                                       IDeviceService.CONTEXT_DST_DEVICE, 
-                                       dstDevice1);
-        }
-        if (destDeviceToLearn == DestDeviceToLearn.DEVICE2) {
-            dstDevice2 = 
-                    deviceManager.learnEntity(Ethernet.toLong(dataLayerDest), 
-                                              null, networkDest,
-                                              1L, 3);
-            IDeviceService.fcStore.put(cntx, 
-                                       IDeviceService.CONTEXT_DST_DEVICE, 
-                                       dstDevice2);
-        }
-        verify(topology);
-    }
-
-    @Test
-    public void testForwardMultiSwitchPath() throws Exception {
-        learnDevices(DestDeviceToLearn.DEVICE1);
-        
-        Capture<OFMessage> wc1 = new Capture<OFMessage>(CaptureType.ALL);
-        Capture<OFMessage> wc2 = new Capture<OFMessage>(CaptureType.ALL);
-        Capture<FloodlightContext> bc1 = 
-                new Capture<FloodlightContext>(CaptureType.ALL);
-        Capture<FloodlightContext> bc2 = 
-                new Capture<FloodlightContext>(CaptureType.ALL);
-
-
-        Route route = new Route(1L, 2L);
-        List<NodePortTuple> nptList = new ArrayList<NodePortTuple>();
-        nptList.add(new NodePortTuple(1L, (short)1));
-        nptList.add(new NodePortTuple(1L, (short)3));
-        nptList.add(new NodePortTuple(2L, (short)1));
-        nptList.add(new NodePortTuple(2L, (short)3));
-        route.setPath(nptList);
-        expect(routingEngine.getRoute(1L, (short)1, 2L, (short)3)).andReturn(route).atLeastOnce();
-
-        // Expected Flow-mods
-        OFMatch match = new OFMatch();
-        match.loadFromPacket(testPacketSerialized, (short) 1);
-        OFActionOutput action = new OFActionOutput((short)3, (short)0xffff);
-        List<OFAction> actions = new ArrayList<OFAction>();
-        actions.add(action);
-
-        OFFlowMod fm1 = 
-                (OFFlowMod) mockFloodlightProvider.getOFMessageFactory().
-                    getMessage(OFType.FLOW_MOD);
-        fm1.setIdleTimeout((short)5)
-            .setMatch(match.clone()
-                    .setWildcards(expected_wildcards))
-            .setActions(actions)
-            .setBufferId(OFPacketOut.BUFFER_ID_NONE)
-            .setCookie(2L << 52)
-            .setLengthU(OFFlowMod.MINIMUM_LENGTH+OFActionOutput.MINIMUM_LENGTH);
-        OFFlowMod fm2 = fm1.clone();
-        ((OFActionOutput)fm2.getActions().get(0)).setPort((short) 3);
-
-        sw1.write(capture(wc1), capture(bc1));
-        expectLastCall().anyTimes(); 
-        sw2.write(capture(wc2), capture(bc2));
-        expectLastCall().anyTimes(); 
-
-        reset(topology);
-        expect(topology.getL2DomainId(1L)).andReturn(1L).anyTimes();
-        expect(topology.getL2DomainId(2L)).andReturn(1L).anyTimes();
-        expect(topology.isAttachmentPointPort(1L,  (short)1)).andReturn(true).anyTimes();
-        expect(topology.isAttachmentPointPort(2L,  (short)3)).andReturn(true).anyTimes();
-        expect(topology.isIncomingBroadcastAllowed(anyLong(), anyShort())).andReturn(true).anyTimes();
-
-        // Reset mocks, trigger the packet in, and validate results
-        replay(sw1, sw2, routingEngine, topology);
-        forwarding.receive(sw1, this.packetIn, cntx);
-        verify(sw1, sw2, routingEngine);
-        
-        assertTrue(wc1.hasCaptured());  // wc1 should get packetout + flowmod.
-        assertTrue(wc2.hasCaptured());  // wc2 should be a flowmod.
-        
-        List<OFMessage> msglist = wc1.getValues();
-        
-        for (OFMessage m: msglist) {
-            if (m instanceof OFFlowMod) 
-                assertEquals(fm1, m);
-            else if (m instanceof OFPacketOut)
-                assertEquals(packetOut, m);
-        }
-        
-        OFMessage m = wc2.getValue();
-        assert (m instanceof OFFlowMod);
-        assertTrue(m.equals(fm2));
-    }
-
-    @Test
-    public void testForwardSingleSwitchPath() throws Exception {        
-        learnDevices(DestDeviceToLearn.DEVICE2);
-        
-        Route route = new  Route(1L, 1L);
-        route.getPath().add(new NodePortTuple(1L, (short)1));
-        route.getPath().add(new NodePortTuple(1L, (short)3));
-        expect(routingEngine.getRoute(1L, (short)1, 1L, (short)3)).andReturn(route).atLeastOnce();
-
-        // Expected Flow-mods
-        OFMatch match = new OFMatch();
-        match.loadFromPacket(testPacketSerialized, (short) 1);
-        OFActionOutput action = new OFActionOutput((short)3, (short)0xffff);
-        List<OFAction> actions = new ArrayList<OFAction>();
-        actions.add(action);
-
-        OFFlowMod fm1 = 
-                (OFFlowMod) mockFloodlightProvider.getOFMessageFactory().
-                    getMessage(OFType.FLOW_MOD);
-        fm1.setIdleTimeout((short)5)
-            .setMatch(match.clone()
-                    .setWildcards(expected_wildcards))
-            .setActions(actions)
-            .setBufferId(OFPacketOut.BUFFER_ID_NONE)
-            .setCookie(2L << 52)
-            .setLengthU(OFFlowMod.MINIMUM_LENGTH +
-                        OFActionOutput.MINIMUM_LENGTH);
-
-        // Record expected packet-outs/flow-mods
-        sw1.write(fm1, cntx);
-        sw1.write(packetOut, cntx);
-        
-        reset(topology);
-        expect(topology.isIncomingBroadcastAllowed(anyLong(), anyShort())).andReturn(true).anyTimes();
-        expect(topology.getL2DomainId(1L)).andReturn(1L).anyTimes();
-        expect(topology.isAttachmentPointPort(1L,  (short)1)).andReturn(true).anyTimes();
-        expect(topology.isAttachmentPointPort(1L,  (short)3)).andReturn(true).anyTimes();
-
-        // Reset mocks, trigger the packet in, and validate results
-        replay(sw1, sw2, routingEngine, topology);
-        forwarding.receive(sw1, this.packetIn, cntx);
-        verify(sw1, sw2, routingEngine);
-    }
-
-    @Test
-    public void testFlowModDampening() throws Exception {        
-        learnDevices(DestDeviceToLearn.DEVICE2);
-    
-        reset(topology);
-        expect(topology.isAttachmentPointPort(EasyMock.anyLong(), EasyMock.anyShort()))
-        .andReturn(true).anyTimes();
-        expect(topology.getL2DomainId(1L)).andReturn(1L).anyTimes();
-        replay(topology);
-    
-    
-        Route route = new  Route(1L, 1L);
-        route.getPath().add(new NodePortTuple(1L, (short)1));
-        route.getPath().add(new NodePortTuple(1L, (short)3));
-        expect(routingEngine.getRoute(1L, (short)1, 1L, (short)3)).andReturn(route).atLeastOnce();
-    
-        // Expected Flow-mods
-        OFMatch match = new OFMatch();
-        match.loadFromPacket(testPacketSerialized, (short) 1);
-        OFActionOutput action = new OFActionOutput((short)3, (short)0xffff);
-        List<OFAction> actions = new ArrayList<OFAction>();
-        actions.add(action);
-    
-        OFFlowMod fm1 = 
-                (OFFlowMod) mockFloodlightProvider.getOFMessageFactory().
-                    getMessage(OFType.FLOW_MOD);
-        fm1.setIdleTimeout((short)5)
-            .setMatch(match.clone()
-                    .setWildcards(expected_wildcards))
-            .setActions(actions)
-            .setBufferId(OFPacketOut.BUFFER_ID_NONE)
-            .setCookie(2L << 52)
-            .setLengthU(OFFlowMod.MINIMUM_LENGTH +
-                        OFActionOutput.MINIMUM_LENGTH);
-    
-        // Record expected packet-outs/flow-mods
-        // We will inject the packet_in 3 times and expect 1 flow mod and
-        // 3 packet outs due to flow mod dampening
-        sw1.write(fm1, cntx);
-        expectLastCall().once();
-        sw1.write(packetOut, cntx);
-        expectLastCall().times(3);
-        
-        reset(topology);
-        expect(topology.isIncomingBroadcastAllowed(anyLong(), anyShort())).andReturn(true).anyTimes();
-        expect(topology.getL2DomainId(1L)).andReturn(1L).anyTimes();
-        expect(topology.isAttachmentPointPort(1L,  (short)1)).andReturn(true).anyTimes();
-        expect(topology.isAttachmentPointPort(1L,  (short)3)).andReturn(true).anyTimes();
-    
-        // Reset mocks, trigger the packet in, and validate results
-        replay(sw1, routingEngine, topology);
-        forwarding.receive(sw1, this.packetIn, cntx);
-        forwarding.receive(sw1, this.packetIn, cntx);
-        forwarding.receive(sw1, this.packetIn, cntx);
-        verify(sw1, routingEngine);
-    }
-
-    @Test
-    public void testForwardNoPath() throws Exception {
-        learnDevices(DestDeviceToLearn.NONE);
-
-        // Set no destination attachment point or route
-        // expect no Flow-mod but expect the packet to be flooded 
-                
-        // Reset mocks, trigger the packet in, and validate results
-        reset(topology);
-        expect(topology.isIncomingBroadcastAllowed(1L, (short)1)).andReturn(true).anyTimes();
-        expect(topology.isAttachmentPointPort(EasyMock.anyLong(),
-                                              EasyMock.anyShort()))
-                                              .andReturn(true)
-                                              .anyTimes();
-        expect(sw1.hasAttribute(IOFSwitch.PROP_SUPPORTS_OFPP_FLOOD))
-                .andReturn(true).anyTimes();
-        sw1.write(packetOutFlooded, cntx);
-        expectLastCall().once();
-        replay(sw1, sw2, routingEngine, topology);
-        forwarding.receive(sw1, this.packetIn, cntx);
-        verify(sw1, sw2, routingEngine);
-    }
-
-}
diff --git a/src/test/java/net/floodlightcontroller/routing/RouteTest.java b/src/test/java/net/floodlightcontroller/routing/RouteTest.java
deleted file mode 100644
index 3bd0398..0000000
--- a/src/test/java/net/floodlightcontroller/routing/RouteTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
-*    Copyright 2011, Big Switch Networks, Inc. 
-*    Originally created by David Erickson, Stanford University
-* 
-*    Licensed under the Apache License, Version 2.0 (the "License"); you may
-*    not use this file except in compliance with the License. You may obtain
-*    a copy of the License at
-*
-*         http://www.apache.org/licenses/LICENSE-2.0
-*
-*    Unless required by applicable law or agreed to in writing, software
-*    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-*    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-*    License for the specific language governing permissions and limitations
-*    under the License.
-**/
-
-package net.floodlightcontroller.routing;
-
-import org.junit.Test;
-
-import net.floodlightcontroller.routing.Route;
-import net.floodlightcontroller.test.FloodlightTestCase;
-import net.floodlightcontroller.topology.NodePortTuple;
-
-/**
- *
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class RouteTest extends FloodlightTestCase {
-    @Test
-    public void testCloneable() throws Exception {
-        Route r1 = new Route(1L, 2L);
-        Route r2 = new Route(1L, 3L);
-
-        assertNotSame(r1, r2);
-        assertNotSame(r1.getId(), r2.getId());
-
-        r1 = new Route(1L, 3L);
-        r1.getPath().add(new NodePortTuple(1L, (short)1));
-        r1.getPath().add(new NodePortTuple(2L, (short)1));
-        r1.getPath().add(new NodePortTuple(2L, (short)2));
-        r1.getPath().add(new NodePortTuple(3L, (short)1));
-
-        r2.getPath().add(new NodePortTuple(1L, (short)1));
-        r2.getPath().add(new NodePortTuple(2L, (short)1));
-        r2.getPath().add(new NodePortTuple(2L, (short)2));
-        r2.getPath().add(new NodePortTuple(3L, (short)1));
-
-        assertEquals(r1, r2);
-
-        NodePortTuple temp = r2.getPath().remove(0);
-        assertNotSame(r1, r2);
-
-        r2.getPath().add(0, temp);
-        assertEquals(r1, r2);
-
-        r2.getPath().remove(1);
-        temp = new NodePortTuple(2L, (short)5);
-        r2.getPath().add(1, temp);
-        assertNotSame(r1, r2);
-    }
-}
diff --git a/src/test/java/net/floodlightcontroller/test/FloodlightTestCase.java b/src/test/java/net/floodlightcontroller/test/FloodlightTestCase.java
index b0e83cc..f96d374 100644
--- a/src/test/java/net/floodlightcontroller/test/FloodlightTestCase.java
+++ b/src/test/java/net/floodlightcontroller/test/FloodlightTestCase.java
@@ -18,17 +18,9 @@
 package net.floodlightcontroller.test;
 
 import junit.framework.TestCase;
-import net.floodlightcontroller.core.FloodlightContext;
-import net.floodlightcontroller.core.IFloodlightProviderService;
 import net.floodlightcontroller.core.test.MockFloodlightProvider;
-import net.floodlightcontroller.devicemanager.IDevice;
-import net.floodlightcontroller.devicemanager.IDeviceService;
-import net.floodlightcontroller.packet.Ethernet;
 
 import org.junit.Test;
-import org.openflow.protocol.OFMessage;
-import org.openflow.protocol.OFPacketIn;
-import org.openflow.protocol.OFType;
 
 /**
  * This class gets a handle on the application context which is used to
@@ -46,42 +38,6 @@
     public void setMockFloodlightProvider(MockFloodlightProvider mockFloodlightProvider) {
         this.mockFloodlightProvider = mockFloodlightProvider;
     }
-
-    public FloodlightContext parseAndAnnotate(OFMessage m,
-                                              IDevice srcDevice,
-                                              IDevice dstDevice) {
-        FloodlightContext bc = new FloodlightContext();
-        return parseAndAnnotate(bc, m, srcDevice, dstDevice);
-    }
-
-    public FloodlightContext parseAndAnnotate(OFMessage m) {
-        return parseAndAnnotate(m, null, null);
-    }
-
-    public FloodlightContext parseAndAnnotate(FloodlightContext bc,
-                                              OFMessage m,
-                                              IDevice srcDevice,
-                                              IDevice dstDevice) {
-        if (OFType.PACKET_IN.equals(m.getType())) {
-            OFPacketIn pi = (OFPacketIn)m;
-            Ethernet eth = new Ethernet();
-            eth.deserialize(pi.getPacketData(), 0, pi.getPacketData().length);
-            IFloodlightProviderService.bcStore.put(bc, 
-                    IFloodlightProviderService.CONTEXT_PI_PAYLOAD, 
-                    eth);
-        }
-        if (srcDevice != null) {
-            IDeviceService.fcStore.put(bc, 
-                    IDeviceService.CONTEXT_SRC_DEVICE, 
-                    srcDevice);
-        }
-        if (dstDevice != null) {
-            IDeviceService.fcStore.put(bc, 
-                    IDeviceService.CONTEXT_DST_DEVICE, 
-                    dstDevice);
-        }
-        return bc;
-    }
     
     @Override
     public void setUp() throws Exception {
diff --git a/src/test/java/net/floodlightcontroller/topology/TopologyInstanceTest.java b/src/test/java/net/floodlightcontroller/topology/TopologyInstanceTest.java
deleted file mode 100644
index 8653625..0000000
--- a/src/test/java/net/floodlightcontroller/topology/TopologyInstanceTest.java
+++ /dev/null
@@ -1,518 +0,0 @@
-package net.floodlightcontroller.topology;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import static org.junit.Assert.*;
-
-import net.floodlightcontroller.core.IFloodlightProviderService;
-import net.floodlightcontroller.core.module.FloodlightModuleContext;
-import net.floodlightcontroller.core.test.MockFloodlightProvider;
-import net.floodlightcontroller.core.test.MockThreadPoolService;
-import net.floodlightcontroller.threadpool.IThreadPoolService;
-import net.floodlightcontroller.topology.NodePortTuple;
-import net.floodlightcontroller.topology.TopologyInstance;
-import net.floodlightcontroller.topology.TopologyManager;
-import net.onrc.onos.ofcontroller.linkdiscovery.ILinkDiscovery;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class TopologyInstanceTest {
-    protected final static Logger log = LoggerFactory.getLogger(TopologyInstanceTest.class);
-    protected TopologyManager topologyManager;
-    protected FloodlightModuleContext fmc;
-    protected MockFloodlightProvider mockFloodlightProvider;
-
-    protected int DIRECT_LINK = 1;
-    protected int MULTIHOP_LINK = 2;
-    protected int TUNNEL_LINK = 3;
-
-    @Before 
-    public void SetUp() throws Exception {
-        fmc = new FloodlightModuleContext();
-        mockFloodlightProvider = new MockFloodlightProvider();
-        fmc.addService(IFloodlightProviderService.class, mockFloodlightProvider);
-        MockThreadPoolService tp = new MockThreadPoolService();
-        topologyManager  = new TopologyManager();
-        fmc.addService(IThreadPoolService.class, tp);
-        topologyManager.init(fmc);
-        tp.init(fmc);
-        tp.startUp(fmc);
-    }
-
-    protected void verifyClusters(int[][] clusters) {
-        verifyClusters(clusters, true);
-    }
-
-    protected void verifyClusters(int[][] clusters, boolean tunnelsEnabled) {
-        List<Long> verifiedSwitches = new ArrayList<Long>();
-
-        // Make sure the expected cluster arrays are sorted so we can
-        // use binarySearch to test for membership
-        for (int i = 0; i < clusters.length; i++)
-            Arrays.sort(clusters[i]);
-
-        TopologyInstance ti = 
-                topologyManager.getCurrentInstance(tunnelsEnabled);
-        Set<Long> switches = ti.getSwitches();
-
-        for (long sw: switches) {
-            if (!verifiedSwitches.contains(sw)) {
-
-                int[] expectedCluster = null;
-
-                for (int j = 0; j < clusters.length; j++) {
-                    if (Arrays.binarySearch(clusters[j], (int) sw) >= 0) {
-                        expectedCluster = clusters[j];
-                        break;
-                    }
-                }
-                if (expectedCluster != null) {
-                    Set<Long> cluster = ti.getSwitchesInOpenflowDomain(sw);
-                    assertEquals(expectedCluster.length, cluster.size());
-                    for (long sw2: cluster) {
-                        assertTrue(Arrays.binarySearch(expectedCluster, (int)sw2) >= 0);
-                        verifiedSwitches.add(sw2);
-                    }
-                }
-            }
-        }
-    }
-
-    protected void 
-    verifyExpectedBroadcastPortsInClusters(int [][][] ebp) {
-        verifyExpectedBroadcastPortsInClusters(ebp, true);
-    }
-
-    protected void 
-    verifyExpectedBroadcastPortsInClusters(int [][][] ebp, 
-                                           boolean tunnelsEnabled) {
-        NodePortTuple npt = null;
-        Set<NodePortTuple> expected = new HashSet<NodePortTuple>();
-        for(int i=0; i<ebp.length; ++i) {
-            int [][] nptList = ebp[i];
-            expected.clear();
-            for(int j=0; j<nptList.length; ++j) {
-                npt = new NodePortTuple((long)nptList[j][0], (short)nptList[j][1]);
-                expected.add(npt);
-            }
-            TopologyInstance ti = topologyManager.getCurrentInstance(tunnelsEnabled);
-            Set<NodePortTuple> computed = ti.getBroadcastNodePortsInCluster(npt.nodeId);
-            if (computed != null)
-                assertTrue(computed.equals(expected));
-            else if (computed == null)
-                assertTrue(expected.isEmpty());
-        }
-    }
-
-    public void createTopologyFromLinks(int [][] linkArray) throws Exception {
-        ILinkDiscovery.LinkType type = ILinkDiscovery.LinkType.DIRECT_LINK;
-
-        // Use topologymanager to write this test, it will make it a lot easier.
-        for (int i = 0; i < linkArray.length; i++) {
-            int [] r = linkArray[i];
-            if (r[4] == DIRECT_LINK)
-                type= ILinkDiscovery.LinkType.DIRECT_LINK;
-            else if (r[4] == MULTIHOP_LINK)
-                type= ILinkDiscovery.LinkType.MULTIHOP_LINK;
-            else if (r[4] == TUNNEL_LINK)
-                type = ILinkDiscovery.LinkType.TUNNEL;
-
-            topologyManager.addOrUpdateLink((long)r[0], (short)r[1], (long)r[2], (short)r[3], type);
-        }
-        topologyManager.createNewInstance();
-    }
-
-    public TopologyManager getTopologyManager() {
-        return topologyManager;
-    }
-
-    @Test
-    public void testClusters() throws Exception {
-        TopologyManager tm = getTopologyManager();
-        {
-            int [][] linkArray = { 
-                                  {1, 1, 2, 1, DIRECT_LINK}, 
-                                  {2, 2, 3, 2, DIRECT_LINK},
-                                  {3, 1, 1, 2, DIRECT_LINK},
-                                  {2, 3, 4, 2, DIRECT_LINK},
-                                  {3, 3, 4, 1, DIRECT_LINK}
-            };
-            int [][] expectedClusters = {
-                                         {1,2,3}, 
-                                         {4}
-            };
-            //tm.recompute();
-            createTopologyFromLinks(linkArray);
-            verifyClusters(expectedClusters);
-        }
-
-        {
-            int [][] linkArray = { 
-                                  {5, 3, 6, 1, DIRECT_LINK} 
-            };
-            int [][] expectedClusters = {
-                                         {1,2,3}, 
-                                         {4},
-                                         {5},
-                                         {6}
-            };
-            createTopologyFromLinks(linkArray);
-
-            verifyClusters(expectedClusters);
-        }
-
-        {
-            int [][] linkArray = { 
-                                  {6, 1, 5, 3, DIRECT_LINK} 
-            };
-            int [][] expectedClusters = {
-                                         {1,2,3}, 
-                                         {4},
-                                         {5,6}
-            };
-            createTopologyFromLinks(linkArray);
-
-            verifyClusters(expectedClusters);
-        }
-
-        {
-            int [][] linkArray = { 
-                                  {4, 2, 2, 3, DIRECT_LINK} 
-            };
-            int [][] expectedClusters = {
-                                         {1,2,3,4},
-                                         {5,6}
-            };
-            createTopologyFromLinks(linkArray);
-
-            verifyClusters(expectedClusters);
-        }
-        {
-            int [][] linkArray = { 
-                                  {4, 3, 5, 1, DIRECT_LINK} 
-            };
-            int [][] expectedClusters = {
-                                         {1,2,3,4},
-                                         {5,6}
-            };
-            createTopologyFromLinks(linkArray);
-
-            verifyClusters(expectedClusters);
-        }
-        {
-            int [][] linkArray = { 
-                                  {5, 2, 2, 4, DIRECT_LINK} 
-            };
-            int [][] expectedClusters = {
-                                         {1,2,3,4,5,6}
-            };
-            createTopologyFromLinks(linkArray);
-
-            verifyClusters(expectedClusters);
-        }
-
-        //Test 2.
-        {
-            int [][] linkArray = { 
-                                  {3, 2, 2, 2, DIRECT_LINK}, 
-                                  {2, 1, 1, 1, DIRECT_LINK},
-                                  {1, 2, 3, 1, DIRECT_LINK},
-                                  {4, 1, 3, 3, DIRECT_LINK},
-                                  {5, 1, 4, 3, DIRECT_LINK},
-                                  {2, 4, 5, 2, DIRECT_LINK}
-            };
-            int [][] expectedClusters = {
-                                         {1,2,3,4,5,6}
-            };
-            createTopologyFromLinks(linkArray);
-            verifyClusters(expectedClusters);
-        }
-
-        // Test 3. Remove links
-        {
-            tm.removeLink((long)5,(short)3,(long)6,(short)1);
-            tm.removeLink((long)6,(short)1,(long)5,(short)3);
-
-            int [][] expectedClusters = {
-                                         {1,2,3,4,5},
-            };
-            topologyManager.createNewInstance();
-            verifyClusters(expectedClusters);
-        }
-
-        // Remove Switch
-        {
-            tm.removeSwitch(4);
-            int [][] expectedClusters = {
-                                         {1,2,3,5},
-            };
-            topologyManager.createNewInstance();
-            verifyClusters(expectedClusters);
-        }
-    }
-
-    @Test
-    public void testLoopDetectionInSingleIsland() throws Exception {
-
-        int [][] linkArray = {
-                              {1, 1, 2, 1, DIRECT_LINK},
-                              {2, 1, 1, 1, DIRECT_LINK},
-                              {1, 2, 3, 1, DIRECT_LINK},
-                              {3, 1, 1, 2, DIRECT_LINK},
-                              {2, 2, 3, 2, DIRECT_LINK},
-                              {3, 2, 2, 2, DIRECT_LINK},
-                              {3, 3, 4, 1, DIRECT_LINK},
-                              {4, 1, 3, 3, DIRECT_LINK},
-                              {4, 2, 6, 2, DIRECT_LINK},
-                              {6, 2, 4, 2, DIRECT_LINK},
-                              {4, 3, 5, 1, DIRECT_LINK},
-                              {5, 1, 4, 3, DIRECT_LINK},
-                              {5, 2, 6, 1, DIRECT_LINK},
-                              {6, 1, 5, 2, DIRECT_LINK},
-
-        };
-        int [][] expectedClusters = {
-                                     {1, 2, 3, 4, 5, 6}
-        };
-        int [][][] expectedBroadcastPorts = {
-                                             {{1,1}, {2,1}, {1,2}, {3,1}, {3,3}, {4,1}, {4,3}, {5,1}, {4,2}, {6,2}},
-        };
-
-        createTopologyFromLinks(linkArray);
-        topologyManager.createNewInstance();
-        verifyClusters(expectedClusters);
-        verifyExpectedBroadcastPortsInClusters(expectedBroadcastPorts);
-    }
-
-    @Test
-    public void testTunnelLinkDeletion() throws Exception {
-
-        //      +-------+             +-------+
-        //      |       |             |       |
-        //      |   1  1|-------------|1  2   |
-        //      |   2   |             |   2   |
-        //      +-------+             +-------+
-        //          |                     |
-        //          |                     |
-        //      +-------+                 |
-        //      |   1   |                 |
-        //      |   3  2|-----------------+
-        //      |   3   |
-        //      +-------+
-        //
-        //
-        //      +-------+
-        //      |   1   |
-        //      |   4  2|----------------+
-        //      |   3   |                |
-        //      +-------+                |
-        //          |                    |
-        //          |                    |
-        //      +-------+             +-------+
-        //      |   1   |             |   2   |
-        //      |   5  2|-------------|1  6   |
-        //      |       |             |       |
-        //      +-------+             +-------+
-        {
-            int [][] linkArray = {
-                                  {1, 1, 2, 1, DIRECT_LINK},
-                                  {2, 1, 1, 1, DIRECT_LINK},
-                                  {1, 2, 3, 1, TUNNEL_LINK},
-                                  {3, 1, 1, 2, TUNNEL_LINK},
-                                  {2, 2, 3, 2, TUNNEL_LINK},
-                                  {3, 2, 2, 2, TUNNEL_LINK},
-
-                                  {4, 2, 6, 2, DIRECT_LINK},
-                                  {6, 2, 4, 2, DIRECT_LINK},
-                                  {4, 3, 5, 1, TUNNEL_LINK},
-                                  {5, 1, 4, 3, TUNNEL_LINK},
-                                  {5, 2, 6, 1, TUNNEL_LINK},
-                                  {6, 1, 5, 2, TUNNEL_LINK},
-
-            };
-
-            int [][] expectedClusters = {
-                                         {1, 2},
-                                         {4, 6},
-            };
-            int [][][] expectedBroadcastPorts = {
-                                                 {{1,1}, {2,1}},
-                                                 {{4,2}, {6,2}}
-            };
-
-            createTopologyFromLinks(linkArray);
-            topologyManager.createNewInstance();
-            verifyClusters(expectedClusters, false);
-            verifyExpectedBroadcastPortsInClusters(expectedBroadcastPorts, false);
-        }
-
-        //      +-------+             +-------+
-        //      |       |    TUNNEL   |       |
-        //      |   1  1|-------------|1  2   |
-        //      |   2   |             |   2   |
-        //      +-------+             +-------+
-        //          |                     |
-        //          |                     |
-        //      +-------+                 |
-        //      |   1   |                 |
-        //      |   3  2|-----------------+
-        //      |   3   |
-        //      +-------+
-        //          | 
-        //          |   TUNNEL
-        //          |
-        //      +-------+
-        //      |   1   |    TUNNEL
-        //      |   4  2|----------------+
-        //      |   3   |                |
-        //      +-------+                |
-        //          |                    |
-        //          |                    |
-        //      +-------+             +-------+
-        //      |   1   |             |   2   |
-        //      |   5  2|-------------|1  6   |
-        //      |       |             |       |
-        //      +-------+             +-------+
-
-        {
-            int [][] linkArray = {
-                                  {3, 3, 4, 1, TUNNEL_LINK},
-                                  {4, 1, 3, 3, TUNNEL_LINK},
-
-            };
-            int [][] expectedClusters = {
-                                         {1, 2},
-                                         {4, 6},
-                                         {3},
-                                         {5},
-            };
-            int [][][] expectedBroadcastPorts = {
-                                                 {{1,1}, {2,1}},
-                                                 {{4,2}, {6,2}}
-            };
-
-            createTopologyFromLinks(linkArray);
-            topologyManager.createNewInstance();
-            verifyClusters(expectedClusters, false);
-            verifyExpectedBroadcastPortsInClusters(expectedBroadcastPorts, false);
-        }
-    }
-
-    @Test
-    public void testLoopDetectionWithIslands() throws Exception {
-
-        //      +-------+             +-------+
-        //      |       |   TUNNEL    |       |
-        //      |   1  1|-------------|1  2   |
-        //      |   2   |             |   2   |
-        //      +-------+             +-------+
-        //          |                     |
-        //          |                     |
-        //      +-------+                 |
-        //      |   1   |                 |
-        //      |   3  2|-----------------+
-        //      |   3   |
-        //      +-------+
-        //
-        //
-        //      +-------+
-        //      |   1   |   TUNNEL
-        //      |   4  2|----------------+
-        //      |   3   |                |
-        //      +-------+                |
-        //          |                    |
-        //          |                    |
-        //      +-------+             +-------+
-        //      |   1   |             |   2   |
-        //      |   5  2|-------------|1  6   |
-        //      |       |             |       |
-        //      +-------+             +-------+
-        {
-            int [][] linkArray = {
-                                  {1, 1, 2, 1, TUNNEL_LINK},
-                                  {2, 1, 1, 1, TUNNEL_LINK},
-                                  {1, 2, 3, 1, DIRECT_LINK},
-                                  {3, 1, 1, 2, DIRECT_LINK},
-                                  {2, 2, 3, 2, DIRECT_LINK},
-                                  {3, 2, 2, 2, DIRECT_LINK},
-
-                                  {4, 2, 6, 2, TUNNEL_LINK},
-                                  {6, 2, 4, 2, TUNNEL_LINK},
-                                  {4, 3, 5, 1, DIRECT_LINK},
-                                  {5, 1, 4, 3, DIRECT_LINK},
-                                  {5, 2, 6, 1, DIRECT_LINK},
-                                  {6, 1, 5, 2, DIRECT_LINK},
-
-            };
-
-            int [][] expectedClusters = {
-                                         {1, 2, 3}, 
-                                         {4, 5, 6}
-            };
-            int [][][] expectedBroadcastPorts = {
-                                                 {{1,2}, {3,1}, {2,2}, {3,2}},
-                                                 {{4,3}, {5,1}, {5,2}, {6,1}},
-            };
-
-            createTopologyFromLinks(linkArray);
-            topologyManager.createNewInstance();
-            verifyClusters(expectedClusters);
-            verifyExpectedBroadcastPortsInClusters(expectedBroadcastPorts);
-        }
-
-        //      +-------+             +-------+
-        //      |       |    TUNNEL   |       |
-        //      |   1  1|-------------|1  2   |
-        //      |   2   |             |   2   |
-        //      +-------+             +-------+
-        //          |                     |
-        //          |                     |
-        //      +-------+                 |
-        //      |   1   |                 |
-        //      |   3  2|-----------------+
-        //      |   3   |
-        //      +-------+
-        //          | 
-        //          |   TUNNEL
-        //          |
-        //      +-------+
-        //      |   1   |    TUNNEL
-        //      |   4  2|----------------+
-        //      |   3   |                |
-        //      +-------+                |
-        //          |                    |
-        //          |                    |
-        //      +-------+             +-------+
-        //      |   1   |             |   2   |
-        //      |   5  2|-------------|1  6   |
-        //      |       |             |       |
-        //      +-------+             +-------+
-
-        {
-            int [][] linkArray = {
-                                  {3, 3, 4, 1, TUNNEL_LINK},
-                                  {4, 1, 3, 3, TUNNEL_LINK},
-
-            };
-            int [][] expectedClusters = {
-                                         {1, 2, 3}, 
-                                         {4, 5, 6}
-            };
-            int [][][] expectedBroadcastPorts = {
-                                                 {{1,2}, {3,1}, {2,2}, {3,2}},
-                                                 {{4,3}, {5,1}, {5,2}, {6,1}},
-            };
-
-            createTopologyFromLinks(linkArray);
-            topologyManager.createNewInstance();
-            verifyClusters(expectedClusters, false);
-            verifyExpectedBroadcastPortsInClusters(expectedBroadcastPorts);
-        }
-    }
-}
diff --git a/src/test/java/net/floodlightcontroller/topology/TopologyManagerTest.java b/src/test/java/net/floodlightcontroller/topology/TopologyManagerTest.java
deleted file mode 100644
index 280c336..0000000
--- a/src/test/java/net/floodlightcontroller/topology/TopologyManagerTest.java
+++ /dev/null
@@ -1,130 +0,0 @@
-package net.floodlightcontroller.topology;
-
-import net.floodlightcontroller.core.IFloodlightProviderService;
-import net.floodlightcontroller.core.module.FloodlightModuleContext;
-import net.floodlightcontroller.core.test.MockThreadPoolService;
-import net.floodlightcontroller.test.FloodlightTestCase;
-import net.floodlightcontroller.threadpool.IThreadPoolService;
-import net.onrc.onos.ofcontroller.linkdiscovery.ILinkDiscovery;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class TopologyManagerTest extends FloodlightTestCase {
-    protected final static Logger log = LoggerFactory.getLogger(TopologyManagerTest.class);
-    TopologyManager tm;
-    FloodlightModuleContext fmc;
-    
-    @Before
-    public void setUp() throws Exception {
-        super.setUp();
-        fmc = new FloodlightModuleContext();
-        fmc.addService(IFloodlightProviderService.class, getMockFloodlightProvider());
-        MockThreadPoolService tp = new MockThreadPoolService();
-        fmc.addService(IThreadPoolService.class, tp);
-        tm  = new TopologyManager();
-        tp.init(fmc);
-        tm.init(fmc);
-        tp.startUp(fmc);
-    }
-
-    @Test
-    public void testBasic1() throws Exception {
-        tm.addOrUpdateLink((long)1, (short)1, (long)2, (short)1, ILinkDiscovery.LinkType.DIRECT_LINK);
-        assertTrue(tm.getSwitchPorts().size() == 2);  // for two nodes.
-        assertTrue(tm.getSwitchPorts().get((long)1).size()==1);
-        assertTrue(tm.getSwitchPorts().get((long)2).size()==1);
-        assertTrue(tm.getSwitchPortLinks().size()==2);
-        assertTrue(tm.getPortBroadcastDomainLinks().size()==0);
-        assertTrue(tm.getTunnelPorts().size()==0);
-
-        tm.addOrUpdateLink((long)1, (short)2, (long)2, (short)2, ILinkDiscovery.LinkType.MULTIHOP_LINK);
-        assertTrue(tm.getSwitchPorts().size() == 2);  // for two nodes.
-        assertTrue(tm.getSwitchPorts().get((long)1).size()==2);
-        assertTrue(tm.getSwitchPorts().get((long)2).size()==2);
-        assertTrue(tm.getSwitchPortLinks().size()==4);
-        assertTrue(tm.getPortBroadcastDomainLinks().size()==2);
-        assertTrue(tm.getTunnelPorts().size()==0);
-
-        tm.addOrUpdateLink((long)1, (short)3, (long)2, (short)3, ILinkDiscovery.LinkType.TUNNEL);
-        assertTrue(tm.getSwitchPorts().size() == 2);  // for two nodes.
-        assertTrue(tm.getSwitchPorts().get((long)1).size()==3);
-        assertTrue(tm.getSwitchPorts().get((long)2).size()==3);
-        assertTrue(tm.getSwitchPortLinks().size()==6);
-        assertTrue(tm.getPortBroadcastDomainLinks().size()==2);
-        assertTrue(tm.getTunnelPorts().size()==2);
-
-        tm.removeLink((long)1, (short)2, (long)2, (short)2);
-        log.info("# of switchports. {}", tm.getSwitchPorts().get((long)1).size());
-        assertTrue(tm.getSwitchPorts().get((long)1).size()==2);
-        assertTrue(tm.getSwitchPorts().get((long)2).size()==2);
-        assertTrue(tm.getSwitchPorts().size() == 2);  // for two nodes.
-        assertTrue(tm.getSwitchPortLinks().size()==4);
-        assertTrue(tm.getPortBroadcastDomainLinks().size()==0);
-        assertTrue(tm.getTunnelPorts().size()==2);
-
-        tm.removeLink((long)1, (short)1, (long)2, (short)1);
-        assertTrue(tm.getSwitchPorts().size() == 2);  // for two nodes.
-        assertTrue(tm.getSwitchPorts().get((long)1).size()==1);
-        assertTrue(tm.getSwitchPorts().get((long)2).size()==1);
-        assertTrue(tm.getSwitchPortLinks().size()==2);
-        assertTrue(tm.getPortBroadcastDomainLinks().size()==0);
-        assertTrue(tm.getTunnelPorts().size()==2);
-
-        tm.removeLink((long)1, (short)3, (long)2, (short)3);
-        assertTrue(tm.getSwitchPorts().size() == 0); 
-        assertTrue(tm.getSwitchPortLinks().size()==0);
-        assertTrue(tm.getPortBroadcastDomainLinks().size()==0);
-        assertTrue(tm.getTunnelPorts().size()==0);
-    }
-
-    @Test
-    public void testBasic2() throws Exception {
-        tm.addOrUpdateLink((long)1, (short)1, (long)2, (short)1, ILinkDiscovery.LinkType.DIRECT_LINK);
-        tm.addOrUpdateLink((long)2, (short)2, (long)3, (short)1, ILinkDiscovery.LinkType.MULTIHOP_LINK);
-        tm.addOrUpdateLink((long)3, (short)2, (long)1, (short)2, ILinkDiscovery.LinkType.TUNNEL);
-        assertTrue(tm.getSwitchPorts().size() == 3);  // for two nodes.
-        assertTrue(tm.getSwitchPorts().get((long)1).size()==2);
-        assertTrue(tm.getSwitchPorts().get((long)2).size()==2);
-        assertTrue(tm.getSwitchPorts().get((long)3).size()==2);
-        assertTrue(tm.getSwitchPortLinks().size()==6);
-        assertTrue(tm.getPortBroadcastDomainLinks().size()==2);
-        assertTrue(tm.getTunnelPorts().size()==2);
-
-        tm.removeLink((long)1, (short)1, (long)2, (short)1);
-        assertTrue(tm.getSwitchPorts().size() == 3);  // for two nodes.
-        assertTrue(tm.getSwitchPorts().get((long)1).size()==1);
-        assertTrue(tm.getSwitchPorts().get((long)2).size()==1);
-        assertTrue(tm.getSwitchPorts().get((long)3).size()==2);
-        assertTrue(tm.getSwitchPortLinks().size()==4);
-        assertTrue(tm.getPortBroadcastDomainLinks().size()==2);
-        assertTrue(tm.getTunnelPorts().size()==2);
-
-        // nonexistent link // no null pointer exceptions.
-        tm.removeLink((long)3, (short)1, (long)2, (short)2);
-        assertTrue(tm.getSwitchPorts().size() == 3);  // for two nodes.
-        assertTrue(tm.getSwitchPorts().get((long)1).size()==1);
-        assertTrue(tm.getSwitchPorts().get((long)2).size()==1);
-        assertTrue(tm.getSwitchPorts().get((long)3).size()==2);
-        assertTrue(tm.getSwitchPortLinks().size()==4);
-        assertTrue(tm.getPortBroadcastDomainLinks().size()==2);
-        assertTrue(tm.getTunnelPorts().size()==2);
-
-        tm.removeLink((long)3, (short)2, (long)1, (short)2);
-        assertTrue(tm.getSwitchPorts().size() == 2);  // for two nodes.
-        assertTrue(tm.getSwitchPorts().get((long)1)==null);
-        assertTrue(tm.getSwitchPorts().get((long)2).size()==1);
-        assertTrue(tm.getSwitchPorts().get((long)3).size()==1);
-        assertTrue(tm.getSwitchPortLinks().size()==2);
-        assertTrue(tm.getPortBroadcastDomainLinks().size()==2);
-        assertTrue(tm.getTunnelPorts().size()==0);
-
-        tm.removeLink((long)2, (short)2, (long)3, (short)1);
-        assertTrue(tm.getSwitchPorts().size() == 0);  // for two nodes.
-        assertTrue(tm.getSwitchPortLinks().size()==0);
-        assertTrue(tm.getPortBroadcastDomainLinks().size()==0);
-        assertTrue(tm.getTunnelPorts().size()==0);
-    }
-}
diff --git a/src/test/java/net/onrc/onos/ofcontroller/linkdiscovery/internal/LinkDiscoveryManagerTest.java b/src/test/java/net/onrc/onos/ofcontroller/linkdiscovery/internal/LinkDiscoveryManagerTest.java
index ecb87cf..c6d1143 100644
--- a/src/test/java/net/onrc/onos/ofcontroller/linkdiscovery/internal/LinkDiscoveryManagerTest.java
+++ b/src/test/java/net/onrc/onos/ofcontroller/linkdiscovery/internal/LinkDiscoveryManagerTest.java
@@ -33,16 +33,13 @@
 import net.floodlightcontroller.core.test.MockThreadPoolService;
 import net.floodlightcontroller.restserver.IRestApiService;
 import net.floodlightcontroller.restserver.RestApiServer;
-import net.floodlightcontroller.routing.IRoutingService;
-import net.floodlightcontroller.routing.Link;
 import net.floodlightcontroller.test.FloodlightTestCase;
 import net.floodlightcontroller.threadpool.IThreadPoolService;
-import net.floodlightcontroller.topology.ITopologyService;
-import net.floodlightcontroller.topology.NodePortTuple;
-import net.floodlightcontroller.topology.TopologyManager;
 import net.onrc.onos.ofcontroller.linkdiscovery.ILinkDiscoveryListener;
 import net.onrc.onos.ofcontroller.linkdiscovery.ILinkDiscoveryService;
+import net.onrc.onos.ofcontroller.linkdiscovery.Link;
 import net.onrc.onos.ofcontroller.linkdiscovery.LinkInfo;
+import net.onrc.onos.ofcontroller.linkdiscovery.NodePortTuple;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -89,23 +86,18 @@
         super.setUp();
         FloodlightModuleContext cntx = new FloodlightModuleContext();
         ldm = new TestLinkDiscoveryManager();
-        TopologyManager routingEngine = new TopologyManager();
         ldm.linkDiscoveryAware = new ArrayList<ILinkDiscoveryListener>();
         MockThreadPoolService tp = new MockThreadPoolService();
         RestApiServer restApi = new RestApiServer();
         cntx.addService(IRestApiService.class, restApi);
         cntx.addService(IThreadPoolService.class, tp);
-        cntx.addService(IRoutingService.class, routingEngine);
         cntx.addService(ILinkDiscoveryService.class, ldm);
-        cntx.addService(ITopologyService.class, ldm);
         cntx.addService(IFloodlightProviderService.class, getMockFloodlightProvider());
         restApi.init(cntx);
         tp.init(cntx);
-        routingEngine.init(cntx);
         ldm.init(cntx);
         restApi.startUp(cntx);
         tp.startUp(cntx);
-        routingEngine.startUp(cntx);
         ldm.startUp(cntx);
 
         IOFSwitch sw1 = createMockSwitch(1L);