2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
\r
4 * This program and the accompanying materials are made available under the
\r
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
\r
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
\r
9 package org.opendaylight.controller.hosttracker.internal;
\r
11 import java.net.InetAddress;
\r
12 import java.net.UnknownHostException;
\r
14 import junit.framework.TestCase;
\r
16 import org.junit.Assert;
\r
17 import org.junit.Test;
\r
18 import org.opendaylight.controller.hosttracker.IHostId;
\r
19 import org.opendaylight.controller.hosttracker.IPHostId;
\r
21 public class HostTrackerTest extends TestCase {
\r
24 public void testHostTrackerCallable() throws UnknownHostException {
\r
26 HostTracker hostTracker = null;
\r
27 hostTracker = new HostTracker();
\r
28 Assert.assertFalse(hostTracker == null);
\r
30 InetAddress hostIP = InetAddress.getByName("192.168.0.8");
\r
31 IHostId id = IPHostId.fromIP(hostIP);
\r
33 HostTrackerCallable htCallable = new HostTrackerCallable(hostTracker,
\r
35 Assert.assertTrue(htCallable.trackedHost.equals(id));
\r
36 Assert.assertTrue(htCallable.hostTracker.equals(hostTracker));
\r
38 long count = htCallable.latch.getCount();
\r
39 htCallable.wakeup();
\r
40 Assert.assertTrue(htCallable.latch.getCount() == (count - 1));
\r
44 public void testHostTracker() throws UnknownHostException {
\r
45 HostTracker hostTracker = null;
\r
46 hostTracker = new HostTracker();
\r
47 Assert.assertFalse(hostTracker == null);
\r
49 InetAddress hostIP_1 = InetAddress.getByName("192.168.0.8");
\r
50 IHostId id1 = IPHostId.fromIP(hostIP_1);
\r
51 InetAddress hostIP_2 = InetAddress.getByName("192.168.0.18");
\r
52 IHostId id2 = IPHostId.fromIP(hostIP_2);
\r
53 hostTracker.discoverHost(id1);
\r
54 hostTracker.discoverHost(id2);
\r
55 hostTracker.nonClusterObjectCreate();
\r