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
16 import org.opendaylight.controller.sal.core.ConstructionException;
\r
17 import org.opendaylight.controller.sal.core.Node;
\r
18 import org.opendaylight.controller.sal.core.NodeConnector;
\r
19 import org.opendaylight.controller.sal.packet.address.EthernetAddress;
\r
20 import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
\r
21 import org.opendaylight.controller.sal.utils.NodeCreator;
\r
23 public class HostNodeConnectorTest {
\r
26 public void testHostNodeConnector() throws UnknownHostException {
\r
27 HostNodeConnector hostnodeconnector_1, hostnodeconnector_2, hostnodeconnector_3;
\r
28 InetAddress hostIP_1 = InetAddress.getByName("192.168.0.8");
\r
29 InetAddress hostIP_2 = InetAddress
\r
30 .getByName("2001:420:281:1004:e123:e688:d655:a1b0");
\r
31 InetAddress hostIP_3 = InetAddress.getByName("192.168.0.28");
\r
32 byte[] hostMAC_2 = new byte[] { (byte) 0x11, (byte) 0x22, (byte) 0x33,
\r
33 (byte) 0x22, (byte) 0x22, (byte) 0x22 };
\r
34 byte[] hostMAC_3 = new byte[] { (byte) 0x11, (byte) 0x22, (byte) 0x33,
\r
35 (byte) 0x33, (byte) 0x33, (byte) 0x33 };
\r
37 Node node = NodeCreator.createOFNode(1L);
\r
38 NodeConnector nc1 = NodeConnectorCreator.createOFNodeConnector(
\r
40 NodeConnector nc2 = NodeConnectorCreator.createOFNodeConnector(
\r
44 hostnodeconnector_1 = new HostNodeConnector(hostIP_1);
\r
45 Assert.assertTrue(hostnodeconnector_1.equalsByIP(hostIP_1));
\r
46 Assert.assertTrue(hostnodeconnector_1.isV4Host());
\r
47 Assert.assertTrue(hostnodeconnector_1.equalsByIP(hostIP_1));
\r
48 } catch (ConstructionException e) {
\r
49 Assert.assertTrue(false);
\r
53 hostnodeconnector_2 = new HostNodeConnector(hostMAC_2, hostIP_2,
\r
55 Assert.assertTrue(hostnodeconnector_2.isV6Host());
\r
56 Assert.assertTrue(hostnodeconnector_2.getnodeConnector()
\r
58 Assert.assertTrue(hostnodeconnector_2.getnodeconnectorNode()
\r
60 Assert.assertTrue(node.getID().equals(
\r
61 hostnodeconnector_2.getnodeconnectornodeId()));
\r
62 Assert.assertTrue(hostnodeconnector_2.getnodeconnectorportId()
\r
63 .equals((short) 2));
\r
64 } catch (ConstructionException e) {
\r
65 Assert.assertTrue(false);
\r
69 hostnodeconnector_3 = new HostNodeConnector(new EthernetAddress(
\r
70 hostMAC_3), hostIP_3, nc2, (short) 3);
\r
71 byte[] hostMAC_3_rb = hostnodeconnector_3
\r
72 .getDataLayerAddressBytes();
\r
73 HostNodeConnector hostnodeconnector_3rb = new HostNodeConnector(
\r
74 new EthernetAddress(hostMAC_3_rb), hostIP_3, nc2, (short) 3);
\r
75 Assert.assertTrue(hostnodeconnector_3.equals(hostnodeconnector_3rb));
\r
77 Assert.assertTrue(hostnodeconnector_3.getVlan() == (short) 3);
\r
79 hostnodeconnector_3.setStaticHost(true);
\r
80 Assert.assertTrue(hostnodeconnector_3.isStaticHost());
\r
82 Assert.assertTrue(hostnodeconnector_3.isRewriteEnabled());
\r
84 hostnodeconnector_3.initArpSendCountDown().setArpSendCountDown(
\r
86 Assert.assertTrue(hostnodeconnector_3.getArpSendCountDown() == (short) 10);
\r
88 } catch (ConstructionException e) {
\r
89 Assert.assertTrue(false);
\r