summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/test/java/io/fd
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2018-07-02 14:29:50 +0200
committerMarek Gradzki <mgradzki@cisco.com>2018-07-02 14:31:56 +0200
commitec365fe22b9f52fce8daa667c0f0fa9cc25e64f6 (patch)
tree7e581226a0c14df0c984c5f830af635c5caa81b6 /v3po/v3po2vpp/src/test/java/io/fd
parent99db0d333b6e7b101fb55c759f5a4ac028ee0d0b (diff)
Fix VXLAN state read
Use UnsignedInts.toLong instead of (long) cast. Change-Id: I1b6875860019f3449bc32f16cd959f3084583d20 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src/test/java/io/fd')
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizerTest.java45
1 files changed, 30 insertions, 15 deletions
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizerTest.java
index f2384979e..f8ab8673b 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizerTest.java
@@ -76,22 +76,11 @@ public class VxlanCustomizerTest extends ReaderCustomizerTest<Vxlan, VxlanBuilde
v.interfaceName = "vxlan-tunnel4".getBytes();
when(dumpCacheManager.getInterfaceDetail(IID, ctx, IF_NAME)).thenReturn(v);
-
- final VxlanTunnelDetailsReplyDump value = new VxlanTunnelDetailsReplyDump();
- final VxlanTunnelDetails vxlanTunnelDetails = new VxlanTunnelDetails();
- vxlanTunnelDetails.isIpv6 = 0;
- vxlanTunnelDetails.dstAddress = InetAddresses.forString("1.2.3.4").getAddress();
- vxlanTunnelDetails.srcAddress = InetAddresses.forString("1.2.3.5").getAddress();
- vxlanTunnelDetails.encapVrfId = 55;
- vxlanTunnelDetails.swIfIndex = 0;
- vxlanTunnelDetails.vni = 9;
- vxlanTunnelDetails.decapNextIndex = 1;
- value.vxlanTunnelDetails = Lists.newArrayList(vxlanTunnelDetails);
- doReturn(future(value)).when(api).vxlanTunnelDump(any(VxlanTunnelDump.class));
+ doReturn(future(getVxlanTunnelDetailsReplyDump(55))).when(api).vxlanTunnelDump(any(VxlanTunnelDump.class));
}
@Test
- public void testReadCurrentAttributes() throws Exception {
+ public void testRead() throws Exception {
final VxlanBuilder builder = getCustomizer().getBuilder(IID);
getCustomizer().readCurrentAttributes(IID, builder, ctx);
@@ -110,8 +99,20 @@ public class VxlanCustomizerTest extends ReaderCustomizerTest<Vxlan, VxlanBuilde
verify(api).vxlanTunnelDump(any(VxlanTunnelDump.class));
}
+ @Test
+ public void testReadVniOverflow() throws Exception {
+ final long encapVrfId = 4294967295L;
+ doReturn(future(getVxlanTunnelDetailsReplyDump((int) encapVrfId))).when(api)
+ .vxlanTunnelDump(any(VxlanTunnelDump.class));
+ final VxlanBuilder builder = getCustomizer().getBuilder(IID);
+ getCustomizer().readCurrentAttributes(IID, builder, ctx);
+
+ assertEquals(encapVrfId, builder.getEncapVrfId().getValue().longValue());
+ verify(api).vxlanTunnelDump(any(VxlanTunnelDump.class));
+ }
+
@Test(expected = IllegalArgumentException.class)
- public void testReadCurrentAttributesVppNameNotCached() throws Exception {
+ public void testReadVppNameNotCached() throws Exception {
when(dumpCacheManager.getInterfaceDetail(IID, ctx, IF_NAME))
.thenThrow(new IllegalArgumentException("Detail for interface not found"));
@@ -120,7 +121,7 @@ public class VxlanCustomizerTest extends ReaderCustomizerTest<Vxlan, VxlanBuilde
}
@Test
- public void testReadCurrentAttributesWrongType() throws Exception {
+ public void testReadWrongType() throws Exception {
final SwInterfaceDetails v = new SwInterfaceDetails();
v.interfaceName = "tap-2".getBytes();
@@ -137,4 +138,18 @@ public class VxlanCustomizerTest extends ReaderCustomizerTest<Vxlan, VxlanBuilde
protected ReaderCustomizer<Vxlan, VxlanBuilder> initCustomizer() {
return new VxlanCustomizer(api, interfacesContext, dumpCacheManager);
}
+
+ private static VxlanTunnelDetailsReplyDump getVxlanTunnelDetailsReplyDump(final int encapVrfId) {
+ final VxlanTunnelDetailsReplyDump replyDump = new VxlanTunnelDetailsReplyDump();
+ final VxlanTunnelDetails vxlanTunnelDetails = new VxlanTunnelDetails();
+ vxlanTunnelDetails.isIpv6 = 0;
+ vxlanTunnelDetails.dstAddress = InetAddresses.forString("1.2.3.4").getAddress();
+ vxlanTunnelDetails.srcAddress = InetAddresses.forString("1.2.3.5").getAddress();
+ vxlanTunnelDetails.encapVrfId = encapVrfId;
+ vxlanTunnelDetails.swIfIndex = 0;
+ vxlanTunnelDetails.vni = 9;
+ vxlanTunnelDetails.decapNextIndex = 1;
+ replyDump.vxlanTunnelDetails = Lists.newArrayList(vxlanTunnelDetails);
+ return replyDump;
+ }
} \ No newline at end of file