ONOS-2740,ONOS-2741,from ONOS-3032 - to ONOS 3071 , OSPF Protocol Implementation Unit Tests
Change-Id: I7cb129186a99bbf3d20fd6731485e3d84905e939
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsaBinImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsaBinImplTest.java
new file mode 100755
index 0000000..90f572b
--- /dev/null
+++ b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsaBinImplTest.java
@@ -0,0 +1,109 @@
+/*
+ * 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