summaryrefslogtreecommitdiffstats
path: root/srv6/srv6-impl/src/test/java/io/fd/hc2vpp/srv6/write/sid
diff options
context:
space:
mode:
Diffstat (limited to 'srv6/srv6-impl/src/test/java/io/fd/hc2vpp/srv6/write/sid')
-rw-r--r--srv6/srv6-impl/src/test/java/io/fd/hc2vpp/srv6/write/sid/SidCustomizerTest.java81
-rw-r--r--srv6/srv6-impl/src/test/java/io/fd/hc2vpp/srv6/write/sid/request/LocalSidRequestTest.java97
-rw-r--r--srv6/srv6-impl/src/test/java/io/fd/hc2vpp/srv6/write/sid/request/NoProtocolLocalSidRequestTest.java81
-rw-r--r--srv6/srv6-impl/src/test/java/io/fd/hc2vpp/srv6/write/sid/request/TableLookupLocalSidRequestTest.java76
-rw-r--r--srv6/srv6-impl/src/test/java/io/fd/hc2vpp/srv6/write/sid/request/XConnectLocalSidRequestTest.java90
5 files changed, 425 insertions, 0 deletions
diff --git a/srv6/srv6-impl/src/test/java/io/fd/hc2vpp/srv6/write/sid/SidCustomizerTest.java b/srv6/srv6-impl/src/test/java/io/fd/hc2vpp/srv6/write/sid/SidCustomizerTest.java
new file mode 100644
index 000000000..ae72161e5
--- /dev/null
+++ b/srv6/srv6-impl/src/test/java/io/fd/hc2vpp/srv6/write/sid/SidCustomizerTest.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * 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 io.fd.hc2vpp.srv6.write.sid;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import com.google.common.base.Optional;
+import io.fd.hc2vpp.srv6.write.sid.request.LocalSidRequestTest;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6._static.cfg.Sid;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6._static.cfg.SidBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.base.rev180301.srv6.locators.locators.locator.Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.base.rev180301.srv6.locators.locators.locator.PrefixBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.End;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.Srv6LocatorLen;
+
+public class SidCustomizerTest extends LocalSidRequestTest {
+
+ private static final Ipv6Address IP_ADDRESS = new Ipv6Address("a::101");
+
+ @Before
+ public void setup() {
+ when(ctx.readAfter(any())).thenReturn(Optional.of(LOCATOR));
+ when(ctx.readBefore(any())).thenReturn(Optional.of(LOCATOR));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void writeCurrentAttributesNullTest() throws WriteFailedException {
+ SidCustomizer customizer = new SidCustomizer(api, WRITE_REGISTRY);
+ Sid localSid = getSidNull();
+ customizer.writeCurrentAttributes(SID_A_101, localSid, ctx);
+ verify(api, times(0)).srLocalsidAddDel(any());
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void deleteCurrentAttributesNullTest() throws WriteFailedException {
+ SidCustomizer customizer = new SidCustomizer(api, WRITE_REGISTRY);
+ Sid localSid = getSidNull();
+ customizer.deleteCurrentAttributes(SID_A_101, localSid, ctx);
+ verify(api, times(0)).srLocalsidAddDel(any());
+ }
+
+ @Test
+ public void resolveSidAddressTest() {
+ Sid localSid = getSidNull();
+ SidCustomizer customizer = new SidCustomizer(api, WRITE_REGISTRY);
+ Prefix locPrefix = new PrefixBuilder().setAddress(new Ipv6Address("a::")).setLength(new Srv6LocatorLen(
+ (short) 64)).build();
+ Ipv6Address ipv6Address = customizer.resolveSidAddress(locPrefix, localSid);
+ assertTrue((IP_ADDRESS.equals(ipv6Address)));
+ }
+
+ private Sid getSidNull() {
+ return new SidBuilder()
+ .setOpcode(OPCODE_A_101)
+ .setEndBehaviorType(End.class)
+ .setEnd(null)
+ .build();
+ }
+}
diff --git a/srv6/srv6-impl/src/test/java/io/fd/hc2vpp/srv6/write/sid/request/LocalSidRequestTest.java b/srv6/srv6-impl/src/test/java/io/fd/hc2vpp/srv6/write/sid/request/LocalSidRequestTest.java
new file mode 100644
index 000000000..80cf47aa0
--- /dev/null
+++ b/srv6/srv6-impl/src/test/java/io/fd/hc2vpp/srv6/write/sid/request/LocalSidRequestTest.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * 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 io.fd.hc2vpp.srv6.write.sid.request;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+import io.fd.hc2vpp.common.translate.util.AddressTranslator;
+import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
+import io.fd.hc2vpp.srv6.Srv6IIds;
+import io.fd.hc2vpp.srv6.util.JvppRequestTest;
+import io.fd.vpp.jvpp.core.dto.SrLocalsidAddDel;
+import io.fd.vpp.jvpp.core.dto.SrLocalsidAddDelReply;
+import java.util.Arrays;
+import org.junit.Assert;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.Locator1;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.routing.srv6.locators.locator.Static;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.routing.srv6.locators.locator._static.LocalSids;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6._static.cfg.Sid;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6._static.cfg.SidKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.base.rev180301.srv6.locators.locators.Locator;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.base.rev180301.srv6.locators.locators.LocatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.base.rev180301.srv6.locators.locators.LocatorKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.base.rev180301.srv6.locators.locators.locator.PrefixBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.Srv6FuncOpcodeUnreserved;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.Srv6LocatorLen;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public abstract class LocalSidRequestTest extends JvppRequestTest {
+
+ protected static final Srv6FuncOpcodeUnreserved OPCODE_A_101 =
+ new Srv6FuncOpcodeUnreserved(257L); // 101 in hex format for IPv6
+ protected static final InstanceIdentifier<Sid> SID_A_101 =
+ Srv6IIds.RT_SRV6_LOCATORS.child(Locator.class, new LocatorKey("a::")).augmentation(Locator1.class)
+ .child(Static.class).child(LocalSids.class).child(Sid.class, new SidKey(OPCODE_A_101));
+ static final byte[] SID_BYTES = {0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ static final Ipv6Address SID = new Ipv6Address("A::0");
+ protected static Locator LOCATOR = new LocatorBuilder().setName("a::").setPrefix(
+ new PrefixBuilder().setLength(new Srv6LocatorLen((short) 64)).setAddress(new Ipv6Address("a::")).build())
+ .build();
+
+ @Captor
+ ArgumentCaptor<SrLocalsidAddDel> requestcaptor;
+
+ static void assertIsCreate(final SrLocalsidAddDel request) {
+ assertEquals(0, request.isDel);
+ }
+
+ static void assertIsDelete(final SrLocalsidAddDel request) {
+ assertEquals(1, request.isDel);
+ }
+
+ static void assertBaseFields(final SrLocalsidAddDel request, final byte[] localSidAddress,
+ final int installFibTable, final int segmentRoutingBehavior,
+ final int isDecapsulationEnabled) {
+ assertEquals(installFibTable, request.fibTable);
+ assertEquals(isDecapsulationEnabled, request.endPsp);
+ assertEquals(segmentRoutingBehavior, request.behavior);
+ assertTrue(Arrays.equals(localSidAddress, request.localsid.addr));
+ }
+
+ public static void assertRequestEqual(SrLocalsidAddDel srLocalsidAddDel, int behaviour, boolean isWrite,
+ String localSid) {
+ //PSP is true whe USP is false and vice versa
+ Assert.assertFalse(!ByteDataTranslator.INSTANCE.byteToBoolean(srLocalsidAddDel.endPsp));
+ Assert.assertEquals(behaviour, (int) srLocalsidAddDel.behavior);
+ Assert.assertEquals(isWrite, !ByteDataTranslator.INSTANCE.byteToBoolean(srLocalsidAddDel.isDel));
+ IpAddress ipAddress = AddressTranslator.INSTANCE.arrayToIpAddress(true, srLocalsidAddDel.localsid.addr);
+ Assert.assertEquals(localSid.toLowerCase(), ipAddress.getIpv6Address().getValue().toLowerCase());
+ }
+
+ @Override
+ protected void init() {
+ when(api.srLocalsidAddDel(any())).thenReturn(future(new SrLocalsidAddDelReply()));
+ }
+}
diff --git a/srv6/srv6-impl/src/test/java/io/fd/hc2vpp/srv6/write/sid/request/NoProtocolLocalSidRequestTest.java b/srv6/srv6-impl/src/test/java/io/fd/hc2vpp/srv6/write/sid/request/NoProtocolLocalSidRequestTest.java
new file mode 100644
index 000000000..a53fc09ba
--- /dev/null
+++ b/srv6/srv6-impl/src/test/java/io/fd/hc2vpp/srv6/write/sid/request/NoProtocolLocalSidRequestTest.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * 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 io.fd.hc2vpp.srv6.write.sid.request;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import io.fd.hc2vpp.srv6.Srv6IIds;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.vpp.jvpp.core.dto.SrLocalsidAddDel;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+
+public class NoProtocolLocalSidRequestTest extends LocalSidRequestTest {
+
+ private static final int END_VALUE = 1;
+
+ private static void assertRequestBody(final SrLocalsidAddDel jvppRequest) {
+ assertNull(jvppRequest.nhAddr6);
+ assertNull(jvppRequest.nhAddr4);
+ assertEquals(0, jvppRequest.vlanIndex);
+ assertEquals(0, jvppRequest.swIfIndex);
+ }
+
+ private static NoProtocolLocalSidRequest createValidRequest(final FutureJVppCore api) {
+ final NoProtocolLocalSidRequest request = new NoProtocolLocalSidRequest(api);
+ request.setLocalSidAddress(new Ipv6Address("A::0"));
+ request.setFunction(END_VALUE);
+ request.setInstallFibTable(0);
+ return request;
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testNoAddress() throws WriteFailedException {
+ final NoProtocolLocalSidRequest request = new NoProtocolLocalSidRequest(api);
+ request.write(Srv6IIds.RT_SRV6_LOCS_LOC_ST_LS_SID);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testNoBehavior() throws WriteFailedException {
+ final NoProtocolLocalSidRequest request = new NoProtocolLocalSidRequest(api);
+ request.setLocalSidAddress(SID);
+ request.write(Srv6IIds.RT_SRV6_LOCS_LOC_ST_LS_SID);
+ }
+
+ @Test
+ public void testWriteValid() throws WriteFailedException {
+ createValidRequest(api).write(Srv6IIds.RT_SRV6_LOCS_LOC_ST_LS_SID);
+ verify(api, times(1)).srLocalsidAddDel(requestcaptor.capture());
+ final SrLocalsidAddDel jvppRequest = requestcaptor.getValue();
+ assertIsCreate(jvppRequest);
+ assertRequestBody(jvppRequest);
+ }
+
+ @Test
+ public void testDeleteValid() throws WriteFailedException {
+ createValidRequest(api).delete(Srv6IIds.RT_SRV6_LOCS_LOC_ST_LS_SID);
+ verify(api, times(1)).srLocalsidAddDel(requestcaptor.capture());
+ final SrLocalsidAddDel jvppRequest = requestcaptor.getValue();
+ assertIsDelete(jvppRequest);
+ assertBaseFields(jvppRequest, SID_BYTES, 0, END_VALUE, 1);
+ assertRequestBody(jvppRequest);
+ }
+}
diff --git a/srv6/srv6-impl/src/test/java/io/fd/hc2vpp/srv6/write/sid/request/TableLookupLocalSidRequestTest.java b/srv6/srv6-impl/src/test/java/io/fd/hc2vpp/srv6/write/sid/request/TableLookupLocalSidRequestTest.java
new file mode 100644
index 000000000..0cedec73b
--- /dev/null
+++ b/srv6/srv6-impl/src/test/java/io/fd/hc2vpp/srv6/write/sid/request/TableLookupLocalSidRequestTest.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * 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 io.fd.hc2vpp.srv6.write.sid.request;
+
+import static io.fd.vpp.jvpp.Assertions.assertEquals;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import io.fd.hc2vpp.srv6.Srv6IIds;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.vpp.jvpp.core.dto.SrLocalsidAddDel;
+import org.junit.Test;
+
+public class TableLookupLocalSidRequestTest extends LocalSidRequestTest {
+
+ private static final int END_T_VALUE = 3;
+
+ @Test(expected = NullPointerException.class)
+ public void testNoAddress() throws WriteFailedException {
+ final TableLookupLocalSidRequest request = new TableLookupLocalSidRequest(api);
+ request.write(Srv6IIds.RT_SRV6_LOCS_LOC_ST_LS_SID);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testNoBehavior() throws WriteFailedException {
+ final TableLookupLocalSidRequest request = new TableLookupLocalSidRequest(api);
+ request.setLocalSidAddress(SID);
+ request.write(Srv6IIds.RT_SRV6_LOCS_LOC_ST_LS_SID);
+ }
+
+ @Test
+ public void testWriteValid() throws WriteFailedException {
+ createValidRequest().write(Srv6IIds.RT_SRV6_LOCS_LOC_ST_LS_SID);
+ verify(api, times(1)).srLocalsidAddDel(requestcaptor.capture());
+ final SrLocalsidAddDel jvppRequest = requestcaptor.getValue();
+
+ assertIsCreate(jvppRequest);
+ assertBaseFields(jvppRequest, SID_BYTES, 0, END_T_VALUE, 1);
+ assertEquals(7, jvppRequest.swIfIndex);
+ }
+
+ @Test
+ public void testDeleteValid() throws WriteFailedException {
+ createValidRequest().delete(Srv6IIds.RT_SRV6_LOCS_LOC_ST_LS_SID);
+ verify(api, times(1)).srLocalsidAddDel(requestcaptor.capture());
+ final SrLocalsidAddDel jvppRequest = requestcaptor.getValue();
+
+ assertIsDelete(jvppRequest);
+ assertBaseFields(jvppRequest, SID_BYTES, 0, END_T_VALUE, 1);
+ assertEquals(7, jvppRequest.swIfIndex);
+ }
+
+ private TableLookupLocalSidRequest createValidRequest() {
+ final TableLookupLocalSidRequest request = new TableLookupLocalSidRequest(api);
+ request.setLookupFibTable(7);
+ request.setInstallFibTable(0);
+ request.setLocalSidAddress(SID);
+ request.setFunction(END_T_VALUE);
+ return request;
+ }
+
+}
diff --git a/srv6/srv6-impl/src/test/java/io/fd/hc2vpp/srv6/write/sid/request/XConnectLocalSidRequestTest.java b/srv6/srv6-impl/src/test/java/io/fd/hc2vpp/srv6/write/sid/request/XConnectLocalSidRequestTest.java
new file mode 100644
index 000000000..970295001
--- /dev/null
+++ b/srv6/srv6-impl/src/test/java/io/fd/hc2vpp/srv6/write/sid/request/XConnectLocalSidRequestTest.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * 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 io.fd.hc2vpp.srv6.write.sid.request;
+
+import static io.fd.vpp.jvpp.Assertions.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import io.fd.hc2vpp.srv6.Srv6IIds;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.vpp.jvpp.core.dto.SrLocalsidAddDel;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import java.util.Arrays;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+
+public class XConnectLocalSidRequestTest extends LocalSidRequestTest {
+
+ private static final IpAddress NEXT_HOP_ADDRESS = new IpAddress(new Ipv6Address("B::0"));
+ private static final byte[] NEXT_HOP_ADDRESS_BYTES = new byte[]{0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ private static final int END_DX6_VALUE = 6;
+
+ private static XConnectLocalSidRequest createValidRequest(final FutureJVppCore api) {
+ final XConnectLocalSidRequest request = new XConnectLocalSidRequest(api);
+ request.setLocalSidAddress(SID);
+ request.setNextHopAddress(NEXT_HOP_ADDRESS);
+ request.setOutgoingInterfaceIndex(7);
+ request.setVlanIndex(4);
+ request.setInstallFibTable(0);
+ request.setFunction(END_DX6_VALUE);
+ return request;
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testNoAddress() throws WriteFailedException {
+ final XConnectLocalSidRequest request = new XConnectLocalSidRequest(api);
+ request.write(Srv6IIds.RT_SRV6_LOCS_LOC_ST_LS_SID);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testNoBehavior() throws WriteFailedException {
+ final XConnectLocalSidRequest request = new XConnectLocalSidRequest(api);
+ request.setLocalSidAddress(SID);
+ request.write(Srv6IIds.RT_SRV6_LOCS_LOC_ST_LS_SID);
+ }
+
+ @Test
+ public void testWriteValid() throws WriteFailedException {
+ createValidRequest(api).write(Srv6IIds.RT_SRV6_LOCS_LOC_ST_LS_SID);
+ verify(api, times(1)).srLocalsidAddDel(requestcaptor.capture());
+
+ final SrLocalsidAddDel jvppRequest = requestcaptor.getValue();
+
+ assertIsCreate(jvppRequest);
+ assertBaseFields(jvppRequest, SID_BYTES, 0, END_DX6_VALUE, 1);
+ assertEquals(7, jvppRequest.swIfIndex);
+ assertEquals(4, jvppRequest.vlanIndex);
+ assertTrue(Arrays.equals(NEXT_HOP_ADDRESS_BYTES, jvppRequest.nhAddr6));
+ }
+
+ @Test
+ public void testDeleteValid() throws WriteFailedException {
+ createValidRequest(api).delete(Srv6IIds.RT_SRV6_LOCS_LOC_ST_LS_SID);
+ verify(api, times(1)).srLocalsidAddDel(requestcaptor.capture());
+
+ final SrLocalsidAddDel jvppRequest = requestcaptor.getValue();
+
+ assertIsDelete(jvppRequest);
+ assertBaseFields(jvppRequest, SID_BYTES, 0, END_DX6_VALUE, 1);
+ assertEquals(7, jvppRequest.swIfIndex);
+ assertEquals(4, jvppRequest.vlanIndex);
+ assertTrue(Arrays.equals(NEXT_HOP_ADDRESS_BYTES, jvppRequest.nhAddr6));
+ }
+}