Revert "Checkstyle enforcer"
[controller.git] / opendaylight / hosttracker / api / src / test / java / org / opendaylight / controller / hosttracker / hostAware / HostNodeConnectorTest.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.hostAware;\r
11 \r
12 import java.net.InetAddress;\r
13 import java.net.UnknownHostException;\r
14 \r
15 import org.junit.Assert;\r
16 import org.junit.Test;\r
17 \r
18 import org.opendaylight.controller.sal.core.ConstructionException;\r
19 import org.opendaylight.controller.sal.core.Node;\r
20 \r
21 import junit.framework.TestCase;\r
22 \r
23 import org.opendaylight.controller.sal.packet.address.EthernetAddress;\r
24 \r
25 import org.opendaylight.controller.sal.utils.NodeConnectorCreator;\r
26 import org.opendaylight.controller.sal.core.NodeConnector;\r
27 import org.opendaylight.controller.sal.utils.NodeCreator;\r
28 \r
29 \r
30 public class HostNodeConnectorTest extends TestCase {\r
31 \r
32         @Test\r
33         public void testHostNodeConnector() throws UnknownHostException {\r
34                 HostNodeConnector hostnodeconnector_1, hostnodeconnector_2, hostnodeconnector_3;\r
35                 InetAddress hostIP_1 = InetAddress.getByName("192.168.0.8");\r
36                 InetAddress hostIP_2 = InetAddress.getByName("2001:420:281:1004:e123:e688:d655:a1b0");\r
37                 InetAddress hostIP_3 = InetAddress.getByName("192.168.0.28");\r
38                 byte[] hostMAC_2 = new byte[]{(byte)0x11,(byte)0x22,(byte)0x33,(byte)0x22,(byte)0x22,(byte)0x22};\r
39                 byte[] hostMAC_3 = new byte[]{(byte)0x11,(byte)0x22,(byte)0x33,(byte)0x33,(byte)0x33,(byte)0x33};\r
40                 \r
41                 Node node  = NodeCreator.createOFNode(1L);\r
42                 NodeConnector nc1 = NodeConnectorCreator.createOFNodeConnector((short) 2, node);\r
43                 NodeConnector nc2 = NodeConnectorCreator.createOFNodeConnector((short) 1, node);\r
44                 \r
45                 try {\r
46                         hostnodeconnector_1 = new HostNodeConnector(hostIP_1);\r
47                         Assert.assertTrue(hostnodeconnector_1.equalsByIP(hostIP_1));\r
48                         Assert.assertTrue(hostnodeconnector_1.isV4Host());\r
49                         Assert.assertTrue(hostnodeconnector_1.equalsByIP(hostIP_1));\r
50                 } catch (ConstructionException e) {\r
51                         Assert.assertTrue(false);\r
52                 }\r
53                 \r
54                 try {\r
55                         hostnodeconnector_2 = new HostNodeConnector(\r
56                                 hostMAC_2, hostIP_2, nc1, (short)2);\r
57                         Assert.assertTrue(hostnodeconnector_2.isV6Host());\r
58                         Assert.assertTrue(hostnodeconnector_2.getnodeConnector().equals(nc1));\r
59                         Assert.assertTrue(hostnodeconnector_2.getnodeconnectorNode().equals(node));\r
60                         Assert.assertTrue(node.equals(hostnodeconnector_2.getnodeconnectorNode()));\r
61                 } catch (ConstructionException e) {\r
62                         Assert.assertTrue(false);\r
63                 }\r
64                 \r
65                 try {\r
66                         hostnodeconnector_3 = new HostNodeConnector(\r
67                                         new EthernetAddress(hostMAC_3), hostIP_3, nc2, (short)3);\r
68                         byte[] hostMAC_3_rb = hostnodeconnector_3.getDataLayerAddressBytes();\r
69                         HostNodeConnector  hostnodeconnector_3rb = new HostNodeConnector(\r
70                                         new EthernetAddress(hostMAC_3_rb), hostIP_3, nc2, (short)3);\r
71                         Assert.assertTrue(hostnodeconnector_3.equals(hostnodeconnector_3rb));\r
72                         \r
73                         Assert.assertTrue(hostnodeconnector_3.getVlan() == (short)3);\r
74                         \r
75                         hostnodeconnector_3.setStaticHost(true);\r
76                         Assert.assertTrue(hostnodeconnector_3.isStaticHost());\r
77                         \r
78                         Assert.assertTrue(hostnodeconnector_3.isRewriteEnabled());\r
79                         \r
80                         hostnodeconnector_3.initArpSendCountDown().setArpSendCountDown((short) 10);\r
81                         Assert.assertTrue(hostnodeconnector_3.getArpSendCountDown() == (short)10);\r
82                         \r
83                 } catch (ConstructionException e) {\r
84                         Assert.assertTrue(false);\r
85                 }\r
86                 \r
87         }\r
88 \r
89 }\r

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.