diff options
author | Hongjun Ni <hongjun.ni@intel.com> | 2016-10-15 01:08:28 +0800 |
---|---|---|
committer | Hongjun Ni <hongjun.ni@intel.com> | 2016-10-15 01:37:43 +0800 |
commit | 74d5f495d67f4e53d88142e9773559b15e0d9807 (patch) | |
tree | 3376c2711f61e58a8bd2da9bdcab6023b6ae6fbc /nsh/impl/src | |
parent | 6e9cb1fb7f2e808d016e9426142f2b5a78e980d9 (diff) |
Raise test coverage of nsh plugin. HONEYCOMB-198
Change-Id: Iaf57bced6f07799e26470dd5c1700a8bbe7960f4
Signed-off-by: Hongjun Ni <hongjun.ni@intel.com>
Diffstat (limited to 'nsh/impl/src')
2 files changed, 76 insertions, 0 deletions
diff --git a/nsh/impl/src/test/java/io/fd/honeycomb/vppnsh/impl/oper/NshEntryReaderCustomizerTest.java b/nsh/impl/src/test/java/io/fd/honeycomb/vppnsh/impl/oper/NshEntryReaderCustomizerTest.java index 61e89bc1c..804346f75 100644 --- a/nsh/impl/src/test/java/io/fd/honeycomb/vppnsh/impl/oper/NshEntryReaderCustomizerTest.java +++ b/nsh/impl/src/test/java/io/fd/honeycomb/vppnsh/impl/oper/NshEntryReaderCustomizerTest.java @@ -89,6 +89,7 @@ public class NshEntryReaderCustomizerTest extends public void setUp() throws VppBaseCallException { nshContext = new NamingContext("nsh_entry", ENTRY_CTX_NAME); defineMapping(mappingContext, ENTRY_NAME_1, ENTRY_INDEX_1, ENTRY_CTX_NAME); + defineMapping(mappingContext, ENTRY_NAME_2, ENTRY_INDEX_2, ENTRY_CTX_NAME); final NshEntryDetailsReplyDump reply = new NshEntryDetailsReplyDump(); final NshEntryDetails nshEntryDetails = new NshEntryDetails(); @@ -124,4 +125,42 @@ public class NshEntryReaderCustomizerTest extends verify(jvppNsh).nshEntryDump(any(NshEntryDump.class)); } + + @Test + public void testGetAllIds() throws ReadFailedException { + final NshEntryDetailsReplyDump reply = new NshEntryDetailsReplyDump(); + + final NshEntryDetails nshEntryDetails_1 = new NshEntryDetails(); + nshEntryDetails_1.entryIndex = ENTRY_INDEX_1; + nshEntryDetails_1.verOC = 0; + nshEntryDetails_1.length = 6; + nshEntryDetails_1.mdType = 1; + nshEntryDetails_1.nextProtocol = 3; + nshEntryDetails_1.nspNsi = (123<<8 | 4); + nshEntryDetails_1.c1 = 1; + nshEntryDetails_1.c2 = 2; + nshEntryDetails_1.c3 = 3; + nshEntryDetails_1.c4 = 4; + reply.nshEntryDetails = Lists.newArrayList(nshEntryDetails_1); + + final NshEntryDetails nshEntryDetails_2 = new NshEntryDetails(); + nshEntryDetails_2.entryIndex = ENTRY_INDEX_2; + nshEntryDetails_2.verOC = 0; + nshEntryDetails_2.length = 6; + nshEntryDetails_2.mdType = 1; + nshEntryDetails_2.nextProtocol = 2; + nshEntryDetails_2.nspNsi = (223<<8 | 24); + nshEntryDetails_2.c1 = 21; + nshEntryDetails_2.c2 = 22; + nshEntryDetails_2.c3 = 23; + nshEntryDetails_2.c4 = 24; + reply.nshEntryDetails = Lists.newArrayList(nshEntryDetails_2); + + doReturn(future(reply)).when(jvppNsh).nshEntryDump(any(NshEntryDump.class)); + + final List<NshEntryKey> allIds = getCustomizer().getAllIds(getNshEntryId(ENTRY_NAME_1), ctx); + + assertEquals(reply.nshEntryDetails.size(), allIds.size()); + + } } diff --git a/nsh/impl/src/test/java/io/fd/honeycomb/vppnsh/impl/oper/NshMapReaderCustomizerTest.java b/nsh/impl/src/test/java/io/fd/honeycomb/vppnsh/impl/oper/NshMapReaderCustomizerTest.java index 0c14939c1..67db740aa 100644 --- a/nsh/impl/src/test/java/io/fd/honeycomb/vppnsh/impl/oper/NshMapReaderCustomizerTest.java +++ b/nsh/impl/src/test/java/io/fd/honeycomb/vppnsh/impl/oper/NshMapReaderCustomizerTest.java @@ -41,11 +41,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh. import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.VppNshStateBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.state.NshMaps; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.state.NshMapsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.state.nsh.entries.NshEntryKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.state.nsh.maps.NshMap; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.state.nsh.maps.NshMapBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.state.nsh.maps.NshMapKey; import io.fd.vpp.jvpp.VppBaseCallException; +import io.fd.vpp.jvpp.nsh.dto.NshEntryDetails; +import io.fd.vpp.jvpp.nsh.dto.NshEntryDetailsReplyDump; +import io.fd.vpp.jvpp.nsh.dto.NshEntryDump; import io.fd.vpp.jvpp.nsh.dto.NshMapDetails; import io.fd.vpp.jvpp.nsh.dto.NshMapDetailsReplyDump; import io.fd.vpp.jvpp.nsh.dto.NshMapDump; @@ -59,6 +63,9 @@ public class NshMapReaderCustomizerTest extends private static final int MAP_INDEX_1 = 1; private static final String MAP_NAME_1 = "map1"; + private static final int MAP_INDEX_2 = 2; + private static final String MAP_NAME_2 = "map2"; + private static final String INT_CTX_NAME = "interface-instance"; private static final int ITF_INDEX = 3; private static final String ITF_NAME = "vxlanGpeTun3"; @@ -88,6 +95,8 @@ public class NshMapReaderCustomizerTest extends public void setUp() throws VppBaseCallException { nshContext = new NamingContext("nsh_map", MAP_CTX_NAME); defineMapping(mappingContext, MAP_NAME_1, MAP_INDEX_1, MAP_CTX_NAME); + defineMapping(mappingContext, MAP_NAME_2, MAP_INDEX_2, MAP_CTX_NAME); + interfaceContext = new NamingContext("interface", INT_CTX_NAME); defineMapping(mappingContext, ITF_NAME, ITF_INDEX, INT_CTX_NAME); @@ -116,4 +125,32 @@ public class NshMapReaderCustomizerTest extends verify(jvppNsh).nshMapDump(any(NshMapDump.class)); } + + @Test + public void testGetAllIds() throws ReadFailedException { + final NshMapDetailsReplyDump reply = new NshMapDetailsReplyDump(); + + final NshMapDetails nshMapDetails_1 = new NshMapDetails(); + nshMapDetails_1.mapIndex = MAP_INDEX_1; + nshMapDetails_1.nspNsi = (184<<8 | 255); + nshMapDetails_1.mappedNspNsi = (183<<8 | 254); + nshMapDetails_1.swIfIndex = ITF_INDEX; + nshMapDetails_1.nextNode = 2; + reply.nshMapDetails = Lists.newArrayList(nshMapDetails_1); + + final NshMapDetails nshMapDetails_2 = new NshMapDetails(); + nshMapDetails_2.mapIndex = MAP_INDEX_2; + nshMapDetails_2.nspNsi = (84<<8 | 255); + nshMapDetails_2.mappedNspNsi = (83<<8 | 254); + nshMapDetails_2.swIfIndex = ITF_INDEX; + nshMapDetails_2.nextNode = 1; + reply.nshMapDetails = Lists.newArrayList(nshMapDetails_2); + + doReturn(future(reply)).when(jvppNsh).nshMapDump(any(NshMapDump.class)); + + final List<NshMapKey> allIds = getCustomizer().getAllIds(getNshMapId(MAP_NAME_1), ctx); + + assertEquals(reply.nshMapDetails.size(), allIds.size()); + + } } |