ONOS-2740,ONOS-2741,from ONOS-3032 - to ONOS 3071 , OSPF Protocol Implementation Unit Tests
Change-Id: Ie7f02bd9bff16902647c7af406f7ece9cdf0ae6c
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfDeviceTedImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfDeviceTedImplTest.java
new file mode 100755
index 0000000..d919fc0
--- /dev/null
+++ b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfDeviceTedImplTest.java
@@ -0,0 +1,148 @@
+/*
+ * 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.impl;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.Ip4Address;
+import org.onlab.packet.Ip6Address;
+
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Unit test class for OspfDeviceTedImpl.
+ */
+public class OspfDeviceTedImplTest {
+ private OspfDeviceTedImpl ospfDeviceTed;
+
+ @Before
+ public void setUp() throws Exception {
+ ospfDeviceTed = new OspfDeviceTedImpl();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ ospfDeviceTed = null;
+ }
+
+ /**
+ * Tests ipv4RouterIds() getter method.
+ */
+ @Test
+ public void testIpv4RouterIds() throws Exception {
+ List list = new ArrayList();
+ list.add(Ip4Address.valueOf("1.1.1.1"));
+ ospfDeviceTed.setIpv4RouterIds(list);
+ assertThat(ospfDeviceTed.ipv4RouterIds().size(), is(1));
+ }
+
+ /**
+ * Tests ipv4RouterIds() setter method.
+ */
+ @Test
+ public void testSetIpv4RouterIds() throws Exception {
+ List list = new ArrayList();
+ list.add(Ip4Address.valueOf("1.1.1.1"));
+ ospfDeviceTed.setIpv4RouterIds(list);
+ assertThat(ospfDeviceTed.ipv4RouterIds().size(), is(1));
+ }
+
+ /**
+ * Tests abr() getter method.
+ */
+ @Test
+ public void testAbr() throws Exception {
+ ospfDeviceTed.setAbr(true);
+ assertThat(ospfDeviceTed.abr(), is(true));
+ }
+
+ /**
+ * Tests abr() setter method.
+ */
+ @Test
+ public void testSetAbr() throws Exception {
+ ospfDeviceTed.setAbr(true);
+ assertThat(ospfDeviceTed.abr(), is(true));
+ }
+
+ /**
+ * Tests asbr() getter method.
+ */
+ @Test
+ public void testAsbr() throws Exception {
+ ospfDeviceTed.setAsbr(true);
+ assertThat(ospfDeviceTed.asbr(), is(true));
+ }
+
+ /**
+ * Tests asbr() setter method.
+ */
+ @Test
+ public void testSetAsbr() throws Exception {
+ ospfDeviceTed.setAsbr(true);
+ assertThat(ospfDeviceTed.asbr(), is(true));
+ }
+
+ /**
+ * Tests topologyIds() getter method.
+ */
+ @Test
+ public void testTopologyIds() throws Exception {
+ List list = new ArrayList();
+ list.add(Ip4Address.valueOf("1.1.1.1"));
+ ospfDeviceTed.setTopologyIds(list);
+ assertThat(ospfDeviceTed.topologyIds().size(), is(1));
+ }
+
+ /**
+ * Tests topologyIds() setter method.
+ */
+ @Test
+ public void testSetTopologyIds() throws Exception {
+ List list = new ArrayList();
+ list.add(Ip4Address.valueOf("1.1.1.1"));
+ ospfDeviceTed.setTopologyIds(list);
+ assertThat(ospfDeviceTed.topologyIds().size(), is(1));
+ }
+
+ /**
+ * Tests ipv6RouterIds() getter method.
+ */
+ @Test(expected = Exception.class)
+ public void testIpv6RouterIds() throws Exception {
+ List list = new ArrayList();
+ list.add(Ip6Address.valueOf(InetAddress.getLocalHost()));
+ ospfDeviceTed.setIpv6RouterIds(list);
+ assertThat(ospfDeviceTed.ipv6RouterIds().size(), is(1));
+ }
+
+ /**
+ * Tests ipv6RouterIds() setter method.
+ */
+ @Test(expected = Exception.class)
+ public void testSetIpv6RouterIds() throws Exception {
+ List list = new ArrayList();
+ list.add(Ip6Address.valueOf(InetAddress.getLocalHost()));
+ ospfDeviceTed.setIpv6RouterIds(list);
+ assertThat(ospfDeviceTed.ipv6RouterIds().size(), is(1));
+ }
+}
\ No newline at end of file