HostTracker Bundle Separation
[controller.git] / opendaylight / hosttracker / implementation / src / test / java / org / opendaylight / controller / hosttracker / internal / HostTrackerTest.java
1 /*\r
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
3  *\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
7  */\r
8 \r
9 package org.opendaylight.controller.hosttracker.internal;\r
10 \r
11 import java.net.InetAddress;\r
12 import java.net.UnknownHostException;\r
13 import java.util.concurrent.Future;\r
14 \r
15 import junit.framework.TestCase;\r
16 \r
17 import org.junit.Assert;\r
18 import org.junit.Test;\r
19 import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector;\r
20 \r
21 public class HostTrackerTest extends TestCase {\r
22 \r
23     @Test\r
24     public void testHostTrackerCallable() throws UnknownHostException {\r
25 \r
26         HostTracker hostTracker = null;\r
27         hostTracker = new HostTracker();\r
28         Assert.assertFalse(hostTracker == null);\r
29 \r
30         InetAddress hostIP = InetAddress.getByName("192.168.0.8");\r
31 \r
32         HostTrackerCallable htCallable = new HostTrackerCallable(hostTracker,\r
33                 hostIP);\r
34         Assert.assertTrue(htCallable.trackedHost.equals(hostIP));\r
35         Assert.assertTrue(htCallable.hostTracker.equals(hostTracker));\r
36 \r
37         long count = htCallable.latch.getCount();\r
38         htCallable.wakeup();\r
39         Assert.assertTrue(htCallable.latch.getCount() == --count);\r
40     }\r
41 \r
42     @Test\r
43     public void testHostTracker() throws UnknownHostException {\r
44         HostTracker hostTracker = null;\r
45         hostTracker = new HostTracker();\r
46         Assert.assertFalse(hostTracker == null);\r
47 \r
48         InetAddress hostIP_1 = InetAddress.getByName("192.168.0.8");\r
49         InetAddress hostIP_2 = InetAddress.getByName("192.168.0.18");\r
50         Future<HostNodeConnector> dschost = hostTracker.discoverHost(hostIP_1);\r
51         dschost = hostTracker.discoverHost(hostIP_2);\r
52         hostTracker.nonClusterObjectCreate();\r
53     }\r
54 \r
55 }\r