blob: ef089a1f82a53f4eb4a99920ae05aaebee5820ae [file] [log] [blame]
chidambar babu344dc812016-05-02 19:13:10 +05301/*
2 * Copyright 2016-present Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.isis.controller.impl;
17
18import org.easymock.EasyMock;
19import org.jboss.netty.channel.Channel;
20import org.junit.After;
21import org.junit.Before;
22import org.junit.Test;
23import org.onlab.packet.Ip4Address;
24import org.onosproject.isis.controller.IsisNetworkType;
25
26import static org.hamcrest.CoreMatchers.is;
27import static org.hamcrest.CoreMatchers.notNullValue;
28import static org.junit.Assert.assertThat;
29
30/**
31 * Unit test class for IsisHelloPduSender.
32 */
33public class IsisHelloPduSenderTest {
34 private final String systemId = "1234.1234.1234";
35 private final String areaId = "490001";
36 private final String circuitId = "0";
37 private final String lanId = "0000.0000.0000.00";
38 private Channel channel;
39 private DefaultIsisInterface isisInterface;
40 private DefaultIsisInterface isisInterface1;
41 private IsisHelloPduSender isisHelloPduSender;
42 private IsisHelloPduSender isisHelloPduSender1;
43 private Ip4Address interfaceAddress = Ip4Address.valueOf("10.10.10.10");
44
45 @Before
46 public void setUp() throws Exception {
47 channel = EasyMock.createNiceMock(Channel.class);
48 isisInterface = new DefaultIsisInterface();
49 isisInterface1 = new DefaultIsisInterface();
50 }
51
52 @After
53 public void tearDown() throws Exception {
54 channel = null;
55 isisInterface = null;
56 }
57
58 /**
59 * Tests run() method.
60 */
sunish vk4b5ce002016-05-09 20:18:35 +053061 @Test(expected = Exception.class)
chidambar babu344dc812016-05-02 19:13:10 +053062 public void testRun() throws Exception {
63 isisInterface.setNetworkType(IsisNetworkType.P2P);
64 isisInterface.setCircuitId(circuitId);
65 isisInterface.setSystemId(systemId);
66 isisInterface.setAreaAddress("490001");
67 isisInterface.setInterfaceIpAddress(interfaceAddress);
68 isisHelloPduSender = new IsisHelloPduSender(channel, isisInterface);
69 isisHelloPduSender.run();
70 assertThat(isisHelloPduSender, is(notNullValue()));
71
72 isisInterface1.setNetworkType(IsisNetworkType.BROADCAST);
73 isisInterface1.setCircuitId(circuitId);
74 isisInterface1.setSystemId(systemId);
75 isisInterface1.setAreaAddress(areaId);
76 isisInterface1.setInterfaceIpAddress(interfaceAddress);
77 isisInterface1.setReservedPacketCircuitType(1);
78 isisInterface1.setL1LanId(lanId);
79 isisHelloPduSender1 = new IsisHelloPduSender(channel, isisInterface1);
80 isisHelloPduSender1.run();
81 assertThat(isisHelloPduSender1, is(notNullValue()));
82
83 isisInterface1.setNetworkType(IsisNetworkType.BROADCAST);
84 isisInterface1.setCircuitId(circuitId);
85 isisInterface1.setSystemId(systemId);
86 isisInterface1.setAreaAddress(areaId);
87 isisInterface1.setInterfaceIpAddress(interfaceAddress);
88 isisInterface1.setReservedPacketCircuitType(2);
89 isisInterface1.setL2LanId(lanId);
90 isisHelloPduSender1 = new IsisHelloPduSender(channel, isisInterface1);
91 isisHelloPduSender1.run();
92 assertThat(isisHelloPduSender1, is(notNullValue()));
93
94 isisInterface1.setNetworkType(IsisNetworkType.BROADCAST);
95 isisInterface1.setCircuitId(circuitId);
96 isisInterface1.setSystemId(systemId);
97 isisInterface1.setAreaAddress(areaId);
98 isisInterface1.setInterfaceIpAddress(interfaceAddress);
99 isisInterface1.setReservedPacketCircuitType(3);
100 isisInterface1.setL1LanId(lanId);
101 isisInterface1.setL2LanId(lanId);
102 isisHelloPduSender1 = new IsisHelloPduSender(channel, isisInterface1);
103 isisHelloPduSender1.run();
104 assertThat(isisHelloPduSender1, is(notNullValue()));
105 }
106}