summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'v3po/v3po2vpp/src/test')
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceEthWriterTest.java4
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceIp4WriterTest.java70
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceIp6WriterTest.java68
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceIpWriterTestUtils.java34
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/util/SubinterfaceUtilsTest.java32
5 files changed, 181 insertions, 27 deletions
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceEthWriterTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceEthWriterTest.java
index a32659a78..b5b85ded9 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceEthWriterTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceEthWriterTest.java
@@ -57,7 +57,7 @@ public class AceEthWriterTest {
@Test
public void testGetClassifyAddDelTableRequest() throws Exception {
final int nextTableIndex = 42;
- final ClassifyAddDelTable request = writer.createClassifyTable(action, aceEth, nextTableIndex);
+ final ClassifyAddDelTable request = writer.createClassifyTable(action, aceEth, nextTableIndex, 0);
assertEquals(1, request.isAdd);
assertEquals(-1, request.tableIndex);
@@ -81,7 +81,7 @@ public class AceEthWriterTest {
@Test
public void testGetClassifyAddDelSessionRequest() throws Exception {
final int tableIndex = 123;
- final ClassifyAddDelSession request = writer.createClassifySession(action, aceEth, tableIndex);
+ final ClassifyAddDelSession request = writer.createClassifySession(action, aceEth, tableIndex, 0);
assertEquals(1, request.isAdd);
assertEquals(tableIndex, request.tableIndex);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceIp4WriterTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceIp4WriterTest.java
index 95b8fc591..bc34a533c 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceIp4WriterTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceIp4WriterTest.java
@@ -16,7 +16,8 @@
package io.fd.honeycomb.translate.v3po.interfaces.acl;
-import static org.junit.Assert.assertArrayEquals;
+import static io.fd.honeycomb.translate.v3po.interfaces.acl.AbstractAceWriter.VLAN_TAG_LEN;
+import static io.fd.honeycomb.translate.v3po.interfaces.acl.AceIpWriterTestUtils.assertArrayEqualsWithOffset;
import static org.junit.Assert.assertEquals;
import static org.mockito.MockitoAnnotations.initMocks;
@@ -58,11 +59,8 @@ public class AceIp4WriterTest {
.build();
}
- @Test
- public void testGetClassifyAddDelTableRequest() throws Exception {
- final int nextTableIndex = 42;
- final ClassifyAddDelTable request = writer.createClassifyTable(action, aceIp, nextTableIndex);
-
+ private static void verifyTableRequest(final ClassifyAddDelTable request, final int nextTableIndex,
+ final int vlanTags) {
assertEquals(1, request.isAdd);
assertEquals(-1, request.tableIndex);
assertEquals(1, request.nbuckets);
@@ -77,14 +75,12 @@ public class AceIp4WriterTest {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1,
-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
- assertArrayEquals(expectedMask, request.mask);
- }
+ assertArrayEqualsWithOffset(expectedMask, request.mask, vlanTags * VLAN_TAG_LEN);
- @Test
- public void testGetClassifyAddDelSessionRequest() throws Exception {
- final int tableIndex = 123;
- final ClassifyAddDelSession request = writer.createClassifySession(action, aceIp, tableIndex);
+ }
+ private static void verifySessionRequest(final ClassifyAddDelSession request, final int tableIndex,
+ final int vlanTags) {
assertEquals(1, request.isAdd);
assertEquals(tableIndex, request.tableIndex);
assertEquals(0, request.hitNextIndex);
@@ -94,7 +90,55 @@ public class AceIp4WriterTest {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 1, 2,
4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
- assertArrayEquals(expectedMatch, request.match);
+ assertArrayEqualsWithOffset(expectedMatch, request.match, vlanTags * VLAN_TAG_LEN);
+
+ }
+
+ @Test
+ public void testGetClassifyAddDelTableRequest() throws Exception {
+ final int nextTableIndex = 42;
+ final ClassifyAddDelTable request = writer.createClassifyTable(action, aceIp, nextTableIndex, 0);
+ verifyTableRequest(request, nextTableIndex, 0);
+ }
+
+ @Test
+ public void testGetClassifyAddDelTableRequest1VlanTag() throws Exception {
+ final int nextTableIndex = 42;
+ final int vlanTags = 1;
+ final ClassifyAddDelTable request = writer.createClassifyTable(action, aceIp, nextTableIndex, vlanTags);
+ verifyTableRequest(request, nextTableIndex, vlanTags);
+ }
+
+ @Test
+ public void testGetClassifyAddDelTableRequest2VlanTags() throws Exception {
+ final int nextTableIndex = 42;
+ final int vlanTags = 2;
+ final ClassifyAddDelTable request = writer.createClassifyTable(action, aceIp, nextTableIndex, vlanTags);
+ verifyTableRequest(request, nextTableIndex, vlanTags);
+ }
+
+ @Test
+ public void testGetClassifyAddDelSessionRequest() throws Exception {
+ final int tableIndex = 123;
+ final ClassifyAddDelSession request = writer.createClassifySession(action, aceIp, tableIndex, 0);
+ verifySessionRequest(request, tableIndex, 0);
+ }
+
+ @Test
+ public void testGetClassifyAddDelSessionRequest1VlanTag() throws Exception {
+ final int tableIndex = 123;
+ final int vlanTags = 1;
+ final ClassifyAddDelSession request = writer.createClassifySession(action, aceIp, tableIndex, vlanTags);
+ verifySessionRequest(request, tableIndex, vlanTags);
+ }
+
+ @Test
+ public void testGetClassifyAddDelSessionRequest2VlanTags() throws Exception {
+ final int tableIndex = 123;
+ final int vlanTags = 2;
+ final ClassifyAddDelSession request = writer.createClassifySession(action, aceIp, tableIndex, vlanTags);
+
+ verifySessionRequest(request, tableIndex, vlanTags);
}
@Test
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceIp6WriterTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceIp6WriterTest.java
index 181846830..4af240c43 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceIp6WriterTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceIp6WriterTest.java
@@ -16,7 +16,8 @@
package io.fd.honeycomb.translate.v3po.interfaces.acl;
-import static org.junit.Assert.assertArrayEquals;
+import static io.fd.honeycomb.translate.v3po.interfaces.acl.AbstractAceWriter.VLAN_TAG_LEN;
+import static io.fd.honeycomb.translate.v3po.interfaces.acl.AceIpWriterTestUtils.assertArrayEqualsWithOffset;
import static org.junit.Assert.assertEquals;
import static org.mockito.MockitoAnnotations.initMocks;
@@ -60,11 +61,9 @@ public class AceIp6WriterTest {
.build();
}
- @Test
- public void testGetClassifyAddDelTableRequest() throws Exception {
- final int nextTableIndex = 42;
- final ClassifyAddDelTable request = writer.createClassifyTable(action, aceIp, nextTableIndex);
+ private static void verifyTableRequest(final ClassifyAddDelTable request, final int nextTableIndex,
+ final int vlanTags) {
assertEquals(1, request.isAdd);
assertEquals(-1, request.tableIndex);
assertEquals(1, request.nbuckets);
@@ -89,14 +88,12 @@ public class AceIp6WriterTest {
// padding to multiple of 16B:
0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
- assertArrayEquals(expectedMask, request.mask);
- }
+ assertArrayEqualsWithOffset(expectedMask, request.mask, vlanTags * VLAN_TAG_LEN);
- @Test
- public void testGetClassifyAddDelSessionRequest() throws Exception {
- final int tableIndex = 123;
- final ClassifyAddDelSession request = writer.createClassifySession(action, aceIp, tableIndex);
+ }
+ private static void verifySessionRequest(final ClassifyAddDelSession request, final int tableIndex,
+ final int vlanTags) {
assertEquals(1, request.isAdd);
assertEquals(tableIndex, request.tableIndex);
assertEquals(0, request.hitNextIndex);
@@ -116,7 +113,54 @@ public class AceIp6WriterTest {
// padding to multiple of 16B:
0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
- assertArrayEquals(expectedMatch, request.match);
+ assertArrayEqualsWithOffset(expectedMatch, request.match, vlanTags * VLAN_TAG_LEN);
+
+ }
+
+ @Test
+ public void testGetClassifyAddDelTableRequest() throws Exception {
+ final int nextTableIndex = 42;
+ final ClassifyAddDelTable request = writer.createClassifyTable(action, aceIp, nextTableIndex, 0);
+ verifyTableRequest(request, nextTableIndex, 0);
+ }
+
+ @Test
+ public void testGetClassifyAddDelTableRequest1VlanTag() throws Exception {
+ final int nextTableIndex = 42;
+ final int vlanTags = 1;
+ final ClassifyAddDelTable request = writer.createClassifyTable(action, aceIp, nextTableIndex, vlanTags);
+ verifyTableRequest(request, nextTableIndex, vlanTags);
+ }
+
+ @Test
+ public void testGetClassifyAddDelTableRequest2VlanTag() throws Exception {
+ final int nextTableIndex = 42;
+ final int vlanTags = 2;
+ final ClassifyAddDelTable request = writer.createClassifyTable(action, aceIp, nextTableIndex, vlanTags);
+ verifyTableRequest(request, nextTableIndex, vlanTags);
+ }
+
+ @Test
+ public void testGetClassifyAddDelSessionRequest() throws Exception {
+ final int tableIndex = 123;
+ final ClassifyAddDelSession request = writer.createClassifySession(action, aceIp, tableIndex, 0);
+ verifySessionRequest(request, tableIndex, 0);
+ }
+
+ @Test
+ public void testGetClassifyAddDelSessionRequest1VlanTag() throws Exception {
+ final int tableIndex = 123;
+ final int vlanTags = 1;
+ final ClassifyAddDelSession request = writer.createClassifySession(action, aceIp, tableIndex, vlanTags);
+ verifySessionRequest(request, tableIndex, vlanTags);
+ }
+
+ @Test
+ public void testGetClassifyAddDelSessionRequest2VlanTag() throws Exception {
+ final int tableIndex = 123;
+ final int vlanTags = 2;
+ final ClassifyAddDelSession request = writer.createClassifySession(action, aceIp, tableIndex, vlanTags);
+ verifySessionRequest(request, tableIndex, vlanTags);
}
@Test
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceIpWriterTestUtils.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceIpWriterTestUtils.java
new file mode 100644
index 000000000..6b176b67e
--- /dev/null
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceIpWriterTestUtils.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2016 Cisco 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.honeycomb.translate.v3po.interfaces.acl;
+
+import static org.junit.Assert.assertArrayEquals;
+
+final class AceIpWriterTestUtils {
+
+ private AceIpWriterTestUtils() {
+ throw new UnsupportedOperationException("This utility class cannot be instantiated");
+ }
+
+ protected static void assertArrayEqualsWithOffset(final byte[] baseExpected, final byte[] actual,
+ final int offset) {
+ byte[] expected = new byte[baseExpected.length];
+ System.arraycopy(baseExpected, 0, expected, offset, expected.length - offset);
+
+ assertArrayEquals(expected, actual);
+ }
+}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/util/SubinterfaceUtilsTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/util/SubinterfaceUtilsTest.java
new file mode 100644
index 000000000..fb8a8066e
--- /dev/null
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/util/SubinterfaceUtilsTest.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2016 Cisco 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.honeycomb.translate.v3po.util;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class SubinterfaceUtilsTest {
+
+ @Test
+ public void testGetSubInterfaceName() throws Exception {
+ final String superIfName = "GigabitEthernet0/9/0";
+ final int subIfaceId = 123;
+ final String expectedSubIfaceName = "GigabitEthernet0/9/0.123";
+ assertEquals(expectedSubIfaceName, SubInterfaceUtils.getSubInterfaceName(superIfName, subIfaceId));
+ }
+} \ No newline at end of file