Checkstyle enforcer
[controller.git] / opendaylight / hosttracker / implementation / src / test / java / org / opendaylight / controller / hosttracker / internal / HostTrackerTest.java
1 \r
2 /*\r
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
4  *\r
5  * This program and the accompanying materials are made available under the\r
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
7  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
8  */\r
9 \r
10 package org.opendaylight.controller.hosttracker.internal;\r
11 \r
12 \r
13 import java.net.InetAddress;\r
14 import java.net.UnknownHostException;\r
15 import java.util.concurrent.Future;\r
16 \r
17 import org.junit.Assert;\r
18 import org.junit.Test;\r
19 \r
20 import junit.framework.TestCase;\r
21 import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector;\r
22 \r
23 public class HostTrackerTest extends TestCase {\r
24 \r
25         @Test\r
26         public void testHostTrackerCallable() throws UnknownHostException {\r
27 \r
28                 HostTracker hostTracker = null;\r
29                 hostTracker = new HostTracker();\r
30                 Assert.assertFalse(hostTracker== null);\r
31 \r
32                 InetAddress hostIP = InetAddress.getByName("192.168.0.8");\r
33 \r
34                 HostTrackerCallable htCallable = new HostTrackerCallable (hostTracker, hostIP);\r
35                 Assert.assertTrue(htCallable.trackedHost.equals(hostIP));\r
36                 Assert.assertTrue(htCallable.hostTracker.equals(hostTracker));\r
37 \r
38                 long count = htCallable.latch.getCount();\r
39                 htCallable.wakeup();\r
40                 Assert.assertTrue(htCallable.latch.getCount() == --count );\r
41         }\r
42 \r
43 \r
44 \r
45         @Test\r
46         public void testHostTracker() throws UnknownHostException {\r
47                 HostTracker hostTracker = null;\r
48                 hostTracker = new HostTracker();\r
49                 Assert.assertFalse(hostTracker== null);\r
50 \r
51                 InetAddress hostIP_1 = InetAddress.getByName("192.168.0.8");\r
52                 InetAddress hostIP_2 = InetAddress.getByName("192.168.0.18");\r
53                 Future<HostNodeConnector> dschost = hostTracker.discoverHost(hostIP_1);\r
54                 dschost = hostTracker.discoverHost(hostIP_2);\r
55                 hostTracker.nonClusterObjectCreate();\r
56         }\r
57 \r
58 \r
59 }\r