summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'v3po/v3po2vpp/src')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizer.java2
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizerTest.java45
2 files changed, 31 insertions, 16 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizer.java
index dac59d6f4..6cb94fd0d 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizer.java
@@ -126,7 +126,7 @@ public class VxlanCustomizer extends FutureJVppCustomizer
builder.setSrc(new IpAddress(arrayToIpv4AddressNoZone(swInterfaceVxlanDetails.srcAddress)));
}
builder.setEncapVrfId(new VniReference(UnsignedInts.toLong(swInterfaceVxlanDetails.encapVrfId)));
- builder.setVni(new VxlanVni((long) swInterfaceVxlanDetails.vni));
+ builder.setVni(new VxlanVni(UnsignedInts.toLong(swInterfaceVxlanDetails.vni)));
switch (swInterfaceVxlanDetails.decapNextIndex) {
case 1:
builder.setDecapNext(L2Input.class);
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