Kalyankumar Asangi
Committed by Thomas Vachuska

ONOS-2740,ONOS-2741,from ONOS-3032 - to ONOS 3071 , OSPF Protocol Implementation Unit Tests

Change-Id: I7cb129186a99bbf3d20fd6731485e3d84905e939
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.ospf.controller.area;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onosproject.ospf.controller.OspfProcess;
import java.util.ArrayList;
import java.util.List;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* Unit test class for Configuration.
*/
public class ConfigurationTest {
private Configuration configuration;
private List<OspfProcess> ospfProcesses;
private List result;
private OspfProcessImpl ospfProcessImpl;
@Before
public void setUp() throws Exception {
configuration = new Configuration();
}
@After
public void tearDown() throws Exception {
configuration = null;
ospfProcessImpl = new OspfProcessImpl();
result = null;
ospfProcesses = null;
}
/**
* Tests getProcesses() getter method.
*/
@Test
public void testGetOspfProcess() throws Exception {
ospfProcesses = new ArrayList();
ospfProcesses.add(ospfProcessImpl);
ospfProcesses.add(ospfProcessImpl);
configuration.setProcesses(ospfProcesses);
result = configuration.getProcesses();
assertThat(result.size(), is(2));
}
/**
* Tests setProcesses() setter method.
*/
@Test
public void testSetOspfProcess() throws Exception {
ospfProcesses = new ArrayList();
ospfProcesses.add(ospfProcessImpl);
ospfProcesses.add(ospfProcessImpl);
configuration.setProcesses(ospfProcesses);
result = configuration.getProcesses();
assertThat(result.size(), is(2));
}
/**
* Tests getMethod() getter method.
*/
@Test
public void testGetMethod() throws Exception {
configuration.setMethod("method");
assertThat(configuration.getMethod(), is("method"));
}
/**
* Tests setMethod() setter method.
*/
@Test
public void testSetMethod() throws Exception {
configuration.setMethod("method");
assertThat(configuration.getMethod(), is("method"));
}
/**
* Tests to string method.
*/
@Test
public void testToString() throws Exception {
assertThat(configuration.toString(), is(notNullValue()));
}
}
\ No newline at end of file
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.ospf.controller.area;
import org.easymock.EasyMock;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onlab.packet.Ip4Address;
import org.onosproject.ospf.controller.OspfAreaAddressRange;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* Unit test class for OspfAreaAddressRangeImpl.
*/
public class OspfAreaAddressRangeImplTest {
private OspfAreaAddressRange ospfAreaAddressRange;
private int result;
private String result1;
@Before
public void setUp() throws Exception {
ospfAreaAddressRange = new OspfAreaAddressRangeImpl();
}
@After
public void tearDown() throws Exception {
ospfAreaAddressRange = null;
}
/**
* Tests ipAddress() getter method.
*/
@Test
public void testGetIpAddress() throws Exception {
ospfAreaAddressRange.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
assertThat(ospfAreaAddressRange.ipAddress(), is(Ip4Address.valueOf("1.1.1.1")));
}
/**
* Tests ipAddress() setter method.
*/
@Test
public void testSetIpAddress() throws Exception {
ospfAreaAddressRange.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
assertThat(ospfAreaAddressRange.ipAddress(), is(Ip4Address.valueOf("1.1.1.1")));
}
/**
* Tests mask() getter method.
*/
@Test
public void testGetMask() throws Exception {
ospfAreaAddressRange.setMask("1.1.1.1");
assertThat(ospfAreaAddressRange.mask(), is("1.1.1.1"));
}
/**
* Tests mask() setter method.
*/
@Test
public void testSetMask() throws Exception {
ospfAreaAddressRange.setMask("1.1.1.1");
assertThat(ospfAreaAddressRange.mask(), is("1.1.1.1"));
}
/**
* Tests isAdvertise() getter method.
*/
@Test
public void testIsAdvertise() throws Exception {
ospfAreaAddressRange.setAdvertise(true);
assertThat(ospfAreaAddressRange.isAdvertise(), is(true));
}
/**
* Tests isAdvertise() setter method.
*/
@Test
public void testSetAdvertise() throws Exception {
ospfAreaAddressRange.setAdvertise(true);
assertThat(ospfAreaAddressRange.isAdvertise(), is(true));
}
/**
* Tests equals() method.
*/
@Test
public void testEquals() throws Exception {
assertThat(ospfAreaAddressRange.equals(new OspfAreaAddressRangeImpl()), is(false));
}
/**
* Tests equals() method.
*/
@Test
public void testEquals1() throws Exception {
assertThat(ospfAreaAddressRange.equals(EasyMock.createMock(OspfAreaAddressRange.class)), is(false));
}
@Test
public void testHashCode() throws Exception {
result = ospfAreaAddressRange.hashCode();
assertThat(result, is(notNullValue()));
}
/**
* Tests to string method.
*/
@Test
public void testToString() throws Exception {
result1 = ospfAreaAddressRange.toString();
assertThat(result1, is(notNullValue()));
}
}
\ No newline at end of file
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.ospf.controller.lsdb;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onosproject.ospf.controller.LsaWrapper;
import org.onosproject.ospf.protocol.lsa.LsaHeader;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* Unit test class for LsaBinImpl.
*/
public class LsaBinImplTest {
private LsaBinImpl lsaBin;
private LsaHeader ospflsa1;
private LsaWrapper lsaWrapper;
@Before
public void setUp() throws Exception {
ospflsa1 = new LsaHeader();
ospflsa1.setAge(20);
lsaBin = new LsaBinImpl(1);
}
@After
public void tearDown() throws Exception {
ospflsa1 = null;
lsaBin = null;
}
/**
* Tests binNumber() getter method.
*/
@Test
public void testGetBinNumber() throws Exception {
lsaWrapper = new LsaWrapperImpl();
lsaBin.addOspfLsa("lsa1", lsaWrapper);
assertThat(lsaBin.binNumber(), is(1));
}
/**
* Tests addOspfLsa() method.
*/
@Test
public void testAddOspfLsa() throws Exception {
LsaWrapper lsaWrapper = new LsaWrapperImpl();
lsaBin.addOspfLsa("lsa1", lsaWrapper);
assertThat(lsaBin, is(notNullValue()));
}
/**
* Tests ospfLsa() getter method.
*/
@Test
public void testGetOspfLsa() throws Exception {
lsaWrapper = new LsaWrapperImpl();
lsaBin.addOspfLsa("lsa1", lsaWrapper);
assertThat(lsaBin, is(notNullValue()));
assertThat(lsaBin.ospfLsa("lsa1"), is(lsaWrapper));
}
/**
* Tests removeOspfLsa() method.
*/
@Test
public void testRemoveOspfLsa() throws Exception {
lsaWrapper = new LsaWrapperImpl();
lsaBin.addOspfLsa("lsa1", lsaWrapper);
lsaBin.removeOspfLsa("lsa1", lsaWrapper);
assertThat(lsaBin, is(notNullValue()));
}
/**
* Tests listOfLsa() method.
*/
@Test
public void testGetListOfLsa() throws Exception {
lsaWrapper = new LsaWrapperImpl();
lsaBin.addOspfLsa("lsa1", lsaWrapper);
assertThat(lsaBin.listOfLsa().size(), is(1));
}
/**
* Tests to string method.
*/
@Test
public void testToString() throws Exception {
assertThat(lsaBin.toString(), is(notNullValue()));
}
}
\ No newline at end of file
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.ospf.controller.lsdb;
import org.easymock.EasyMock;
import org.jboss.netty.channel.Channel;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onosproject.ospf.controller.LsaWrapper;
import org.onosproject.ospf.controller.OspfArea;
import org.onosproject.ospf.controller.OspfLsaType;
import org.onosproject.ospf.controller.area.OspfAreaImpl;
import org.onosproject.ospf.controller.area.OspfInterfaceImpl;
import org.onosproject.ospf.protocol.lsa.LsaHeader;
import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
import org.onosproject.ospf.protocol.util.OspfInterfaceState;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* Unit test class for LsaQueueConsumer.
*/
public class LsaQueueConsumerTest {
private LsaQueueConsumer lsaQueueConsumer;
private BlockingQueue<LsaWrapper> blockingQueue;
private Channel channel;
private LsaWrapperImpl lsaWrapper;
private OspfArea ospfArea;
private RouterLsa routerLsa;
private OspfInterfaceImpl ospfInterface;
private LsaHeader lsaHeader;
private LsdbAgeImpl lsdbAge;
@Before
public void setUp() throws Exception {
lsaQueueConsumer = EasyMock.createMock(LsaQueueConsumer.class);
}
@After
public void tearDown() throws Exception {
lsaQueueConsumer = null;
blockingQueue = null;
channel = null;
lsaWrapper = null;
lsdbAge = null;
lsaHeader = null;
ospfInterface = null;
ospfArea = null;
routerLsa = null;
}
/**
* Tests run() method.
*/
@Test
public void testRun() throws Exception {
blockingQueue = new ArrayBlockingQueue(5);
channel = EasyMock.createMock(Channel.class);
ospfArea = new OspfAreaImpl();
lsaWrapper = new LsaWrapperImpl();
lsaWrapper.setLsaProcessing("verifyChecksum");
blockingQueue.add(lsaWrapper);
lsaQueueConsumer = new LsaQueueConsumer(blockingQueue, channel, ospfArea);
lsaQueueConsumer.run();
assertThat(lsaQueueConsumer, is(notNullValue()));
}
/**
* Tests run() method.
*/
@Test
public void testRun1() throws Exception {
blockingQueue = new ArrayBlockingQueue(5);
channel = EasyMock.createMock(Channel.class);
ospfArea = new OspfAreaImpl();
lsaWrapper = new LsaWrapperImpl();
routerLsa = new RouterLsa();
routerLsa.setLsType(1);
lsaWrapper.addLsa(OspfLsaType.ROUTER, routerLsa);
ospfInterface = new OspfInterfaceImpl();
ospfInterface.setState(OspfInterfaceState.DR);
lsaWrapper.setOspfInterface(ospfInterface);
lsaWrapper.setIsSelfOriginated(true);
lsaHeader = new LsaHeader();
lsaHeader.setLsType(1);
lsaWrapper.setLsaHeader(lsaHeader);
lsaWrapper.setLsaProcessing("refreshLsa");
lsaWrapper.setLsdbAge(new LsdbAgeImpl(new OspfAreaImpl()));
blockingQueue.add(lsaWrapper);
lsaQueueConsumer = new LsaQueueConsumer(blockingQueue, channel, ospfArea);
lsaQueueConsumer.run();
assertThat(lsaQueueConsumer, is(notNullValue()));
}
@Test
public void testRun3() throws Exception {
blockingQueue = new ArrayBlockingQueue(5);
channel = EasyMock.createMock(Channel.class);
ospfArea = new OspfAreaImpl();
lsaWrapper = new LsaWrapperImpl();
routerLsa = new RouterLsa();
routerLsa.setLsType(2);
lsaWrapper.addLsa(OspfLsaType.NETWORK, routerLsa);
ospfInterface = new OspfInterfaceImpl();
ospfInterface.setState(OspfInterfaceState.BDR);
lsaWrapper.setOspfInterface(ospfInterface);
lsaWrapper.setIsSelfOriginated(true);
lsaHeader = new LsaHeader();
lsaHeader.setLsType(2);
lsaWrapper.setLsaHeader(lsaHeader);
lsaWrapper.setLsaProcessing("refreshLsa");
lsaWrapper.setLsdbAge(new LsdbAgeImpl(new OspfAreaImpl()));
blockingQueue.add(lsaWrapper);
lsaQueueConsumer = new LsaQueueConsumer(blockingQueue, channel, ospfArea);
lsaQueueConsumer.run();
assertThat(lsaQueueConsumer, is(notNullValue()));
}
/**
* Tests run() method.
*/
@Test
public void testRun5() throws Exception {
blockingQueue = new ArrayBlockingQueue(5);
channel = EasyMock.createMock(Channel.class);
ospfArea = new OspfAreaImpl();
lsaWrapper = new LsaWrapperImpl();
routerLsa = new RouterLsa();
routerLsa.setLsType(2);
lsaWrapper.addLsa(OspfLsaType.NETWORK, routerLsa);
ospfInterface = new OspfInterfaceImpl();
ospfInterface.setState(OspfInterfaceState.DR);
lsaWrapper.setOspfInterface(ospfInterface);
lsaWrapper.setIsSelfOriginated(true);
lsaHeader = new LsaHeader();
lsaHeader.setLsType(2);
lsaWrapper.setLsaHeader(lsaHeader);
lsaWrapper.setLsaProcessing("maxAgeLsa");
lsaWrapper.setLsdbAge(new LsdbAgeImpl(new OspfAreaImpl()));
blockingQueue.add(lsaWrapper);
lsaQueueConsumer = new LsaQueueConsumer(blockingQueue, channel, ospfArea);
lsaQueueConsumer.run();
assertThat(lsaQueueConsumer, is(notNullValue()));
}
/**
* Tests setChannel() method.
*/
@Test
public void testSetChannel() throws Exception {
channel = EasyMock.createMock(Channel.class);
lsdbAge = new LsdbAgeImpl(new OspfAreaImpl());
lsdbAge.startDbAging();
lsdbAge.setChannel(channel);
assertThat(lsaQueueConsumer, is(notNullValue()));
}
}
\ No newline at end of file
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.ospf.controller.lsdb;
import org.easymock.EasyMock;
import org.jboss.netty.channel.Channel;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.onosproject.ospf.controller.LsaBin;
import org.onosproject.ospf.controller.OspfArea;
import org.onosproject.ospf.controller.area.OspfAreaImpl;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* Unit test class for LsdbAgeImpl.
*/
public class LsdbAgeImplTest {
private LsdbAgeImpl lsdbAge;
private OspfAreaImpl ospfAreaImpl;
private LsaBinImpl lsaBin;
private LsaBin lsaBin1;
private LsaWrapperImpl lsaWrapper;
private OspfArea ospfArea;
private Channel channel;
@Before
public void setUp() throws Exception {
ospfAreaImpl = EasyMock.createMock(OspfAreaImpl.class);
lsdbAge = new LsdbAgeImpl(ospfAreaImpl);
}
@After
public void tearDown() throws Exception {
lsdbAge = null;
lsaBin = null;
lsaBin1 = null;
ospfAreaImpl = null;
lsaWrapper = null;
channel = null;
ospfArea = null;
}
/**
* Tests getLsaBin() method.
*/
@Test
public void testGetLsaBin() throws Exception {
lsaBin = new LsaBinImpl(1);
lsdbAge.addLsaBin(1, lsaBin);
assertThat(lsdbAge, is(notNullValue()));
lsaBin1 = lsdbAge.getLsaBin(1);
assertThat(lsaBin, instanceOf(LsaBin.class));
assertThat(lsaBin1, instanceOf(LsaBin.class));
}
/**
* Tests addLsaBin() method.
*/
@Test
public void testAddLsaBin() throws Exception {
lsaBin = new LsaBinImpl(1);
lsdbAge.addLsaBin(1, lsaBin);
assertThat(lsdbAge, is(notNullValue()));
assertThat(lsaBin, instanceOf(LsaBin.class));
}
/**
* Tests equals() method.
*/
@Test
public void testEquals() throws Exception {
assertThat(lsdbAge.equals(lsdbAge), is(true));
}
/**
* Tests hashCode() method.
*/
@Test
public void testHashCode() throws Exception {
int hashCode = lsdbAge.hashCode();
assertThat(hashCode, is(notNullValue()));
}
/**
* Tests addLsaToMaxAgeBin() method.
*/
@Test
public void testAddLsaToMaxAgeBin() throws Exception {
lsaWrapper = EasyMock.createMock(LsaWrapperImpl.class);
lsdbAge.addLsaToMaxAgeBin("lsa1", lsaWrapper);
assertThat(lsdbAge, is(notNullValue()));
}
/**
* Tests removeLsaFromBin() method.
*/
@Test
public void testRemoveLsaFromBin() throws Exception {
lsaBin = EasyMock.createMock(LsaBinImpl.class);
lsaWrapper = new LsaWrapperImpl();
lsaWrapper.setBinNumber(-1);
lsaBin.addOspfLsa("1", lsaWrapper);
lsdbAge.startDbAging();
lsdbAge.addLsaToMaxAgeBin("3600", lsaWrapper);
lsdbAge.addLsaBin(-1, lsaBin);
lsdbAge.removeLsaFromBin(lsaWrapper);
assertThat(lsdbAge, is(notNullValue()));
}
/**
* Tests startDbAging() method.
*/
@Test
public void testStartDbAging() throws Exception {
lsaWrapper = EasyMock.createMock(LsaWrapperImpl.class);
lsdbAge.addLsaToMaxAgeBin("lsa1", lsaWrapper);
lsaWrapper = EasyMock.createMock(LsaWrapperImpl.class);
lsdbAge.addLsaToMaxAgeBin("lsa2", lsaWrapper);
lsdbAge.startDbAging();
assertThat(lsdbAge, is(notNullValue()));
}
/**
* Tests ageLsaAndFlood() method.
*/
@Test
public void testAgeLsaAndFlood() throws Exception {
lsaWrapper = EasyMock.createMock(LsaWrapperImpl.class);
lsdbAge.addLsaToMaxAgeBin("lsa1", lsaWrapper);
lsaWrapper = EasyMock.createMock(LsaWrapperImpl.class);
lsdbAge.addLsaToMaxAgeBin("lsa2", lsaWrapper);
lsdbAge.startDbAging();
lsdbAge.ageLsaAndFlood();
Assert.assertNotNull(lsdbAge);
}
/**
* Tests maxAgeLsa() method.
*/
@Test
public void testMaxageLsa() throws Exception {
lsaWrapper = EasyMock.createMock(LsaWrapperImpl.class);
ospfArea = new OspfAreaImpl();
lsdbAge = new LsdbAgeImpl(ospfArea);
lsaWrapper.setLsdbAge(lsdbAge);
lsdbAge.addLsaToMaxAgeBin("lsa1", lsaWrapper);
lsaBin = new LsaBinImpl(1);
lsaBin.addOspfLsa("1", lsaWrapper);
lsaWrapper = EasyMock.createMock(LsaWrapperImpl.class);
lsdbAge.addLsaToMaxAgeBin("lsa2", lsaWrapper);
lsaBin.addOspfLsa("2", lsaWrapper);
lsdbAge.startDbAging();
lsdbAge = new LsdbAgeImpl(new OspfAreaImpl());
lsdbAge.ageLsaAndFlood();
lsdbAge.maxAgeLsa();
assertThat(lsdbAge, is(notNullValue()));
}
/**
* Tests refreshLsa() method.
*/
@Test
public void testRefereshLsa() throws Exception {
lsaWrapper = EasyMock.createMock(LsaWrapperImpl.class);
lsaWrapper.setBinNumber(0);
lsdbAge.addLsaToMaxAgeBin("lsa1", lsaWrapper);
lsdbAge.ageLsaAndFlood();
lsaWrapper.setBinNumber(0);
lsaWrapper = EasyMock.createMock(LsaWrapperImpl.class);
lsdbAge.addLsaToMaxAgeBin("lsa2", lsaWrapper);
lsdbAge.ageLsaAndFlood();
lsdbAge.startDbAging();
lsaBin = new LsaBinImpl(1809);
lsdbAge.refreshLsa();
assertThat(lsdbAge, is(notNullValue()));
}
/**
* Tests checkAges() method.
*/
@Test
public void testCheckAges() throws Exception {
lsaWrapper = EasyMock.createMock(LsaWrapperImpl.class);
lsdbAge.addLsaToMaxAgeBin("lsa1", lsaWrapper);
lsaWrapper = EasyMock.createMock(LsaWrapperImpl.class);
lsdbAge.addLsaToMaxAgeBin("lsa2", lsaWrapper);
lsdbAge.startDbAging();
lsdbAge.checkAges();
assertThat(lsdbAge, is(notNullValue()));
}
/**
* Tests getChannel() getter method.
*/
@Test
public void testGetChannel() throws Exception {
channel = EasyMock.createMock(Channel.class);
lsdbAge.setChannel(channel);
assertThat(lsdbAge.getChannel(), is(notNullValue()));
}
/**
* Tests setChannel() setter method.
*/
@Test
public void testSetChannel() throws Exception {
channel = EasyMock.createMock(Channel.class);
lsdbAge.setChannel(channel);
assertThat(lsdbAge.getChannel(), is(notNullValue()));
}
/**
* Tests getAgeCounter() method.
*/
@Test
public void testGetAgeCounter() throws Exception {
lsaBin = new LsaBinImpl(1);
lsdbAge.addLsaBin(1, lsaBin);
int age = lsdbAge.getAgeCounter();
assertThat(age, is(notNullValue()));
}
/**
* Tests getAgeCounterRollOver() method.
*/
@Test
public void testGetAgeCounterRollOver() throws Exception {
lsaBin = new LsaBinImpl(1);
lsdbAge.addLsaBin(1, lsaBin);
lsdbAge.startDbAging();
assertThat(lsdbAge.getAgeCounterRollOver(), is(notNullValue()));
}
/**
* Tests getMaxAgeBin() method.
*/
@Test
public void testGetMaxAgeBin() throws Exception {
lsaBin = new LsaBinImpl(1);
lsdbAge.addLsaBin(1, lsaBin);
lsdbAge.startDbAging();
assertThat(lsdbAge.getMaxAgeBin(), is(notNullValue()));
}
/**
* Tests age2Bin() method.
*/
@Test
public void testAge2Bin() throws Exception {
int age = lsdbAge.age2Bin(0);
assertThat(age, is(notNullValue()));
}
}
\ No newline at end of file
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.ospf.controller.util;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onlab.packet.Ip4Address;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* Unit test class for OspfEligibleRouter.
*/
public class OspfEligibleRouterTest {
private OspfEligibleRouter ospfEligibleRouter;
@Before
public void setUp() throws Exception {
ospfEligibleRouter = new OspfEligibleRouter();
}
@After
public void tearDown() throws Exception {
ospfEligibleRouter = null;
}
/**
* Tests getIpAddress() getter method.
*/
@Test
public void testGetIpAddress() throws Exception {
ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
assertThat(ospfEligibleRouter.getIpAddress(), is(Ip4Address.valueOf("1.1.1.1")));
}
/**
* Tests setIpAddress() setter method.
*/
@Test
public void testSetIpAddress() throws Exception {
ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
assertThat(ospfEligibleRouter.getIpAddress(), is(Ip4Address.valueOf("1.1.1.1")));
}
/**
* Tests getRouterId() getter method.
*/
@Test
public void testGetRouterId() throws Exception {
ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
assertThat(ospfEligibleRouter.getRouterId(), is(Ip4Address.valueOf("1.1.1.1")));
}
/**
* Tests setRouterId() setter method.
*/
@Test
public void testSetRouterId() throws Exception {
ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
assertThat(ospfEligibleRouter.getRouterId(), is(Ip4Address.valueOf("1.1.1.1")));
}
/**
* Tests getRouterPriority() getter method.
*/
@Test
public void testGetRouterPriority() throws Exception {
ospfEligibleRouter.setRouterPriority(1);
assertThat(ospfEligibleRouter.getRouterPriority(), is(1));
}
/**
* Tests getRouterPriority() setter method.
*/
@Test
public void testSetRouterPriority() throws Exception {
ospfEligibleRouter.setRouterPriority(1);
assertThat(ospfEligibleRouter.getRouterPriority(), is(1));
}
/**
* Tests isDr() getter method.
*/
@Test
public void testIsDr() throws Exception {
ospfEligibleRouter.setIsDr(true);
assertThat(ospfEligibleRouter.isDr(), is(true));
}
/**
* Tests isDr() setter method.
*/
@Test
public void testSetIsDr() throws Exception {
ospfEligibleRouter.setIsDr(true);
assertThat(ospfEligibleRouter.isDr(), is(true));
}
/**
* Tests isBdr() getter method.
*/
@Test
public void testIsBdr() throws Exception {
ospfEligibleRouter.setIsBdr(true);
assertThat(ospfEligibleRouter.isBdr(), is(true));
}
/**
* Tests isBdr() setter method.
*/
@Test
public void testSetIsBdr() throws Exception {
ospfEligibleRouter.setIsBdr(true);
assertThat(ospfEligibleRouter.isBdr(), is(true));
}
}