Fixed flaky HostMonitor unit tests.
Change-Id: Ie9e9e922733e6210b61a0360feae38d683685fe7
diff --git a/core/net/src/main/java/org/onlab/onos/net/host/impl/HostMonitor.java b/core/net/src/main/java/org/onlab/onos/net/host/impl/HostMonitor.java
index e6e348f..0b3b2cb 100644
--- a/core/net/src/main/java/org/onlab/onos/net/host/impl/HostMonitor.java
+++ b/core/net/src/main/java/org/onlab/onos/net/host/impl/HostMonitor.java
@@ -73,8 +73,6 @@
monitoredAddresses = Collections.newSetFromMap(
new ConcurrentHashMap<IpAddress, Boolean>());
hostProviders = new ConcurrentHashMap<>();
-
- timeout = Timer.getTimer().newTimeout(this, 0, TimeUnit.MILLISECONDS);
}
/**
diff --git a/core/net/src/test/java/org/onlab/onos/net/host/impl/HostMonitorTest.java b/core/net/src/test/java/org/onlab/onos/net/host/impl/HostMonitorTest.java
index d8ddfbe..7fc6b8c 100644
--- a/core/net/src/test/java/org/onlab/onos/net/host/impl/HostMonitorTest.java
+++ b/core/net/src/test/java/org/onlab/onos/net/host/impl/HostMonitorTest.java
@@ -5,6 +5,7 @@
import static org.easymock.EasyMock.expectLastCall;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
@@ -13,7 +14,7 @@
import java.util.List;
import java.util.Set;
-import org.junit.Ignore;
+import org.junit.After;
import org.junit.Test;
import org.onlab.onos.net.ConnectPoint;
import org.onlab.onos.net.Device;
@@ -52,8 +53,12 @@
private HostMonitor hostMonitor;
+ @After
+ public void shutdown() {
+ hostMonitor.shutdown();
+ }
+
@Test
- @Ignore
public void testMonitorHostExists() throws Exception {
ProviderId id = new ProviderId("fake://", "id");
@@ -83,8 +88,8 @@
}
@Test
- @Ignore
public void testMonitorHostDoesNotExist() throws Exception {
+
HostManager hostManager = createMock(HostManager.class);
DeviceId devId = DeviceId.deviceId("fake");
@@ -124,11 +129,11 @@
// Check that a packet was sent to our PacketService and that it has
// the properties we expect
- assertTrue(packetService.packets.size() == 1);
+ assertEquals(1, packetService.packets.size());
OutboundPacket packet = packetService.packets.get(0);
// Check the output port is correct
- assertTrue(packet.treatment().instructions().size() == 1);
+ assertEquals(1, packet.treatment().instructions().size());
Instruction instruction = packet.treatment().instructions().get(0);
assertTrue(instruction instanceof OutputInstruction);
OutputInstruction oi = (OutputInstruction) instruction;