2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
\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
9 package org.opendaylight.controller.hosttracker.hostAware;
\r
11 import java.net.InetAddress;
\r
12 import java.net.UnknownHostException;
\r
14 import org.junit.Assert;
\r
15 import org.junit.Test;
\r
17 import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector;
\r
18 import org.opendaylight.controller.sal.core.ConstructionException;
\r
19 import org.opendaylight.controller.sal.core.Node;
\r
21 import junit.framework.TestCase;
\r
23 import org.opendaylight.controller.sal.packet.address.EthernetAddress;
\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
29 public class HostNodeConnectorTest extends TestCase {
\r
32 public void testHostNodeConnector() throws UnknownHostException {
\r
33 HostNodeConnector hostnodeconnector_1, hostnodeconnector_2, hostnodeconnector_3;
\r
34 InetAddress hostIP_1 = InetAddress.getByName("192.168.0.8");
\r
35 InetAddress hostIP_2 = InetAddress
\r
36 .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,
\r
39 (byte) 0x22, (byte) 0x22, (byte) 0x22 };
\r
40 byte[] hostMAC_3 = new byte[] { (byte) 0x11, (byte) 0x22, (byte) 0x33,
\r
41 (byte) 0x33, (byte) 0x33, (byte) 0x33 };
\r
43 Node node = NodeCreator.createOFNode(1L);
\r
44 NodeConnector nc1 = NodeConnectorCreator.createOFNodeConnector(
\r
46 NodeConnector nc2 = NodeConnectorCreator.createOFNodeConnector(
\r
50 hostnodeconnector_1 = new HostNodeConnector(hostIP_1);
\r
51 Assert.assertTrue(hostnodeconnector_1.equalsByIP(hostIP_1));
\r
52 Assert.assertTrue(hostnodeconnector_1.isV4Host());
\r
53 Assert.assertTrue(hostnodeconnector_1.equalsByIP(hostIP_1));
\r
54 } catch (ConstructionException e) {
\r
55 Assert.assertTrue(false);
\r
59 hostnodeconnector_2 = new HostNodeConnector(hostMAC_2, hostIP_2,
\r
61 Assert.assertTrue(hostnodeconnector_2.isV6Host());
\r
62 Assert.assertTrue(hostnodeconnector_2.getnodeConnector()
\r
64 Assert.assertTrue(hostnodeconnector_2.getnodeconnectorNode()
\r
66 Assert.assertTrue(node.getID().equals(
\r
67 hostnodeconnector_2.getnodeconnectornodeId()));
\r
68 Assert.assertTrue(hostnodeconnector_2.getnodeconnectorportId()
\r
69 .equals((short) 2));
\r
70 } catch (ConstructionException e) {
\r
71 Assert.assertTrue(false);
\r
75 hostnodeconnector_3 = new HostNodeConnector(new EthernetAddress(
\r
76 hostMAC_3), hostIP_3, nc2, (short) 3);
\r
77 byte[] hostMAC_3_rb = hostnodeconnector_3
\r
78 .getDataLayerAddressBytes();
\r
79 HostNodeConnector hostnodeconnector_3rb = new HostNodeConnector(
\r
80 new EthernetAddress(hostMAC_3_rb), hostIP_3, nc2, (short) 3);
\r
81 Assert.assertTrue(hostnodeconnector_3.equals(hostnodeconnector_3rb));
\r
83 Assert.assertTrue(hostnodeconnector_3.getVlan() == (short) 3);
\r
85 hostnodeconnector_3.setStaticHost(true);
\r
86 Assert.assertTrue(hostnodeconnector_3.isStaticHost());
\r
88 Assert.assertTrue(hostnodeconnector_3.isRewriteEnabled());
\r
90 hostnodeconnector_3.initArpSendCountDown().setArpSendCountDown(
\r
92 Assert.assertTrue(hostnodeconnector_3.getArpSendCountDown() == (short) 10);
\r
94 } catch (ConstructionException e) {
\r
95 Assert.assertTrue(false);
\r