Move adsal into its own subdirectory.
[controller.git] / opendaylight / adsal / 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 \r
14 import org.junit.Assert;\r
15 import org.junit.Test;\r
16 import org.opendaylight.controller.hosttracker.IHostId;\r
17 import org.opendaylight.controller.hosttracker.IPHostId;\r
18 \r
19 public class HostTrackerTest {\r
20 \r
21     @Test\r
22     public void testHostTrackerCallable() throws UnknownHostException {\r
23 \r
24         HostTracker hostTracker = null;\r
25         hostTracker = new HostTracker();\r
26 \r
27         InetAddress hostIP = InetAddress.getByName("192.168.0.8");\r
28         IHostId id  = IPHostId.fromIP(hostIP);\r
29 \r
30         HostTrackerCallable htCallable = new HostTrackerCallable(hostTracker,\r
31                 id);\r
32         Assert.assertTrue(htCallable.trackedHost.equals(id));\r
33         Assert.assertTrue(htCallable.hostTracker.equals(hostTracker));\r
34 \r
35         long count = htCallable.latch.getCount();\r
36         htCallable.wakeup();\r
37         Assert.assertTrue(htCallable.latch.getCount() == (count - 1));\r
38     }\r
39 \r
40     @Test\r
41     public void testHostTracker() throws UnknownHostException {\r
42         HostTracker hostTracker = null;\r
43         hostTracker = new HostTracker();\r
44 \r
45         InetAddress hostIP_1 = InetAddress.getByName("192.168.0.8");\r
46         IHostId id1 = IPHostId.fromIP(hostIP_1);\r
47         InetAddress hostIP_2 = InetAddress.getByName("192.168.0.18");\r
48         IHostId id2 = IPHostId.fromIP(hostIP_2);\r
49         hostTracker.discoverHost(id1);\r
50         hostTracker.discoverHost(id2);\r
51         hostTracker.nonClusterObjectCreate();\r
52     }\r
53 \r
54 }\r