X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fhosttracker%2Fimplementation%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fhosttracker%2Finternal%2FHostTrackerTest.java;h=d7c60e67a91dfa85213343e41e3f495bacf83e55;hb=3979e330c9f95a898c54a9234f3a07e3b2ae4349;hp=a99100b2956762fcefd4e92d891d25585b5bf3e0;hpb=541d0a36997f292bb037a2199463431eee538358;p=controller.git diff --git a/opendaylight/hosttracker/implementation/src/test/java/org/opendaylight/controller/hosttracker/internal/HostTrackerTest.java b/opendaylight/hosttracker/implementation/src/test/java/org/opendaylight/controller/hosttracker/internal/HostTrackerTest.java index a99100b295..d7c60e67a9 100644 --- a/opendaylight/hosttracker/implementation/src/test/java/org/opendaylight/controller/hosttracker/internal/HostTrackerTest.java +++ b/opendaylight/hosttracker/implementation/src/test/java/org/opendaylight/controller/hosttracker/internal/HostTrackerTest.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -9,51 +8,51 @@ package org.opendaylight.controller.hosttracker.internal; - import java.net.InetAddress; import java.net.UnknownHostException; -import java.util.concurrent.Future; + +import junit.framework.TestCase; import org.junit.Assert; import org.junit.Test; - -import junit.framework.TestCase; -import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector; +import org.opendaylight.controller.hosttracker.IHostId; +import org.opendaylight.controller.hosttracker.IPHostId; public class HostTrackerTest extends TestCase { - @Test - public void testHostTrackerCallable() throws UnknownHostException { - - HostTracker hostTracker = null; - hostTracker = new HostTracker(); - Assert.assertFalse(hostTracker== null); - - InetAddress hostIP = InetAddress.getByName("192.168.0.8"); - - HostTrackerCallable htCallable = new HostTrackerCallable (hostTracker, hostIP); - Assert.assertTrue(htCallable.trackedHost.equals(hostIP)); - Assert.assertTrue(htCallable.hostTracker.equals(hostTracker)); - - long count = htCallable.latch.getCount(); - htCallable.wakeup(); - Assert.assertTrue(htCallable.latch.getCount() == --count ); - } - - - - @Test - public void testHostTracker() throws UnknownHostException { - HostTracker hostTracker = null; - hostTracker = new HostTracker(); - Assert.assertFalse(hostTracker== null); - - InetAddress hostIP_1 = InetAddress.getByName("192.168.0.8"); - InetAddress hostIP_2 = InetAddress.getByName("192.168.0.18"); - Future dschost = hostTracker.discoverHost(hostIP_1); - dschost = hostTracker.discoverHost(hostIP_2); - hostTracker.nonClusterObjectCreate(); - } - + @Test + public void testHostTrackerCallable() throws UnknownHostException { + + HostTracker hostTracker = null; + hostTracker = new HostTracker(); + Assert.assertFalse(hostTracker == null); + + InetAddress hostIP = InetAddress.getByName("192.168.0.8"); + IHostId id = IPHostId.fromIP(hostIP); + + HostTrackerCallable htCallable = new HostTrackerCallable(hostTracker, + id); + Assert.assertTrue(htCallable.trackedHost.equals(id)); + Assert.assertTrue(htCallable.hostTracker.equals(hostTracker)); + + long count = htCallable.latch.getCount(); + htCallable.wakeup(); + Assert.assertTrue(htCallable.latch.getCount() == (count - 1)); + } + + @Test + public void testHostTracker() throws UnknownHostException { + HostTracker hostTracker = null; + hostTracker = new HostTracker(); + Assert.assertFalse(hostTracker == null); + + InetAddress hostIP_1 = InetAddress.getByName("192.168.0.8"); + IHostId id1 = IPHostId.fromIP(hostIP_1); + InetAddress hostIP_2 = InetAddress.getByName("192.168.0.18"); + IHostId id2 = IPHostId.fromIP(hostIP_2); + hostTracker.discoverHost(id1); + hostTracker.discoverHost(id2); + hostTracker.nonClusterObjectCreate(); + } }