--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.controller.hosttracker.hostAware;\r
+\r
+import java.net.InetAddress;\r
+import java.net.UnknownHostException;\r
+\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+\r
+import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector;\r
+import org.opendaylight.controller.sal.core.ConstructionException;\r
+import org.opendaylight.controller.sal.core.Node;\r
+\r
+import junit.framework.TestCase;\r
+\r
+import org.opendaylight.controller.sal.packet.address.EthernetAddress;\r
+\r
+import org.opendaylight.controller.sal.utils.NodeConnectorCreator;\r
+import org.opendaylight.controller.sal.core.NodeConnector;\r
+import org.opendaylight.controller.sal.utils.NodeCreator;\r
+\r
+public class HostNodeConnectorTest extends TestCase {\r
+\r
+ @Test\r
+ public void testHostNodeConnector() throws UnknownHostException {\r
+ HostNodeConnector hostnodeconnector_1, hostnodeconnector_2, hostnodeconnector_3;\r
+ InetAddress hostIP_1 = InetAddress.getByName("192.168.0.8");\r
+ InetAddress hostIP_2 = InetAddress\r
+ .getByName("2001:420:281:1004:e123:e688:d655:a1b0");\r
+ InetAddress hostIP_3 = InetAddress.getByName("192.168.0.28");\r
+ byte[] hostMAC_2 = new byte[] { (byte) 0x11, (byte) 0x22, (byte) 0x33,\r
+ (byte) 0x22, (byte) 0x22, (byte) 0x22 };\r
+ byte[] hostMAC_3 = new byte[] { (byte) 0x11, (byte) 0x22, (byte) 0x33,\r
+ (byte) 0x33, (byte) 0x33, (byte) 0x33 };\r
+\r
+ Node node = NodeCreator.createOFNode(1L);\r
+ NodeConnector nc1 = NodeConnectorCreator.createOFNodeConnector(\r
+ (short) 2, node);\r
+ NodeConnector nc2 = NodeConnectorCreator.createOFNodeConnector(\r
+ (short) 1, node);\r
+\r
+ try {\r
+ hostnodeconnector_1 = new HostNodeConnector(hostIP_1);\r
+ Assert.assertTrue(hostnodeconnector_1.equalsByIP(hostIP_1));\r
+ Assert.assertTrue(hostnodeconnector_1.isV4Host());\r
+ Assert.assertTrue(hostnodeconnector_1.equalsByIP(hostIP_1));\r
+ } catch (ConstructionException e) {\r
+ Assert.assertTrue(false);\r
+ }\r
+\r
+ try {\r
+ hostnodeconnector_2 = new HostNodeConnector(hostMAC_2, hostIP_2,\r
+ nc1, (short) 2);\r
+ Assert.assertTrue(hostnodeconnector_2.isV6Host());\r
+ Assert.assertTrue(hostnodeconnector_2.getnodeConnector()\r
+ .equals(nc1));\r
+ Assert.assertTrue(hostnodeconnector_2.getnodeconnectorNode()\r
+ .equals(node));\r
+ Assert.assertTrue(node.getID().equals(\r
+ hostnodeconnector_2.getnodeconnectornodeId()));\r
+ Assert.assertTrue(hostnodeconnector_2.getnodeconnectorportId()\r
+ .equals((short) 2));\r
+ } catch (ConstructionException e) {\r
+ Assert.assertTrue(false);\r
+ }\r
+\r
+ try {\r
+ hostnodeconnector_3 = new HostNodeConnector(new EthernetAddress(\r
+ hostMAC_3), hostIP_3, nc2, (short) 3);\r
+ byte[] hostMAC_3_rb = hostnodeconnector_3\r
+ .getDataLayerAddressBytes();\r
+ HostNodeConnector hostnodeconnector_3rb = new HostNodeConnector(\r
+ new EthernetAddress(hostMAC_3_rb), hostIP_3, nc2, (short) 3);\r
+ Assert.assertTrue(hostnodeconnector_3.equals(hostnodeconnector_3rb));\r
+\r
+ Assert.assertTrue(hostnodeconnector_3.getVlan() == (short) 3);\r
+\r
+ hostnodeconnector_3.setStaticHost(true);\r
+ Assert.assertTrue(hostnodeconnector_3.isStaticHost());\r
+\r
+ Assert.assertTrue(hostnodeconnector_3.isRewriteEnabled());\r
+\r
+ hostnodeconnector_3.initArpSendCountDown().setArpSendCountDown(\r
+ (short) 10);\r
+ Assert.assertTrue(hostnodeconnector_3.getArpSendCountDown() == (short) 10);\r
+\r
+ } catch (ConstructionException e) {\r
+ Assert.assertTrue(false);\r
+ }\r
+\r
+ }\r
+\r
+}\r