summaryrefslogtreecommitdiffstats
path: root/lisp/lisp2vpp/src/test
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2017-05-02 10:41:35 +0200
committerMarek Gradzki <mgradzki@cisco.com>2017-05-02 11:31:10 +0000
commit9faea02da937dc9468f557a00ed5c9dacec7f2e2 (patch)
tree08d7ee5d4ce09d0d5669cd04eacd7c17f3f6f9c7 /lisp/lisp2vpp/src/test
parentd8b2e9bf2db11dec21a8ebd27c038c4ab6bd1473 (diff)
HC2VPP-131 - checking of lisp state before/after according to operation
Change-Id: I190562527c68d022a9b16fc76ad6a011161f4308 Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'lisp/lisp2vpp/src/test')
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/service/LispStateCheckServiceImplTest.java33
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LispWriterCustomizerTest.java9
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizerTest.java4
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRegisterCustomizerTest.java6
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRequestModeCustomizerTest.java4
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizerTest.java4
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizerTest.java4
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PetrCfgCustomizerTest.java6
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PitrCfgCustomizerTest.java6
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/RlocProbeCustomizerTest.java6
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizerTest.java4
11 files changed, 56 insertions, 30 deletions
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/service/LispStateCheckServiceImplTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/service/LispStateCheckServiceImplTest.java
index 4aa9335bc..78a897e71 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/service/LispStateCheckServiceImplTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/service/LispStateCheckServiceImplTest.java
@@ -57,24 +57,45 @@ public class LispStateCheckServiceImplTest implements FutureProducer {
}
@Test(expected = IllegalStateException.class)
- public void testCheckLispEnabledNoConfig() throws Exception {
+ public void testCheckLispEnabledBeforeNoConfig() throws Exception {
+ when(writeContext.readBefore(InstanceIdentifier.create(Lisp.class))).thenReturn(Optional.absent());
+ impl.checkLispEnabledBefore(writeContext);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testCheckLispEnabledBeforeDisabledConfig() throws Exception {
+ when(writeContext.readBefore(InstanceIdentifier.create(Lisp.class)))
+ .thenReturn(Optional.of(new LispBuilder().setEnable(false).build()));
+ impl.checkLispEnabledBefore(writeContext);
+ }
+
+ @Test
+ public void testCheckLispEnabledBeforeEnabledConfig() throws Exception {
+ // no exception should be thrown here
+ when(writeContext.readBefore(InstanceIdentifier.create(Lisp.class)))
+ .thenReturn(Optional.of(new LispBuilder().setEnable(true).build()));
+ impl.checkLispEnabledBefore(writeContext);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testCheckLispEnabledAfterNoConfig() throws Exception {
when(writeContext.readAfter(InstanceIdentifier.create(Lisp.class))).thenReturn(Optional.absent());
- impl.checkLispEnabled(writeContext);
+ impl.checkLispEnabledAfter(writeContext);
}
@Test(expected = IllegalStateException.class)
- public void testCheckLispEnabledDisabledConfig() throws Exception {
+ public void testCheckLispEnabledAfterDisabledConfig() throws Exception {
when(writeContext.readAfter(InstanceIdentifier.create(Lisp.class)))
.thenReturn(Optional.of(new LispBuilder().setEnable(false).build()));
- impl.checkLispEnabled(writeContext);
+ impl.checkLispEnabledAfter(writeContext);
}
@Test
- public void testCheckLispEnabledEnabledConfig() throws Exception {
+ public void testCheckLispEnabledAfterEnabledConfig() throws Exception {
// no exception should be thrown here
when(writeContext.readAfter(InstanceIdentifier.create(Lisp.class)))
.thenReturn(Optional.of(new LispBuilder().setEnable(true).build()));
- impl.checkLispEnabled(writeContext);
+ impl.checkLispEnabledAfter(writeContext);
}
@Test
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LispWriterCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LispWriterCustomizerTest.java
index a2d772159..51ef1255b 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LispWriterCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LispWriterCustomizerTest.java
@@ -29,9 +29,14 @@ public abstract class LispWriterCustomizerTest extends WriterCustomizerTest{
@Mock
protected LispStateCheckService lispStateCheckService;
- protected void mockLispDisabled(){
+ protected void mockLispDisabledAfter(){
doThrow(IllegalArgumentException.class)
- .when(lispStateCheckService).checkLispEnabled(any(WriteContext.class));
+ .when(lispStateCheckService).checkLispEnabledAfter(any(WriteContext.class));
+ }
+
+ protected void mockLispDisabledBefore(){
+ doThrow(IllegalArgumentException.class)
+ .when(lispStateCheckService).checkLispEnabledBefore(any(WriteContext.class));
}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizerTest.java
index 00c9f3eff..ba4163fde 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizerTest.java
@@ -203,7 +203,7 @@ public class LocatorSetCustomizerTest extends LispWriterCustomizerTest {
@Test
public void testWriteLispDisabled() throws WriteFailedException {
- mockLispDisabled();
+ mockLispDisabledAfter();
try {
customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
} catch (IllegalArgumentException e) {
@@ -215,7 +215,7 @@ public class LocatorSetCustomizerTest extends LispWriterCustomizerTest {
@Test
public void testDeleteLispDisabled() throws WriteFailedException {
- mockLispDisabled();
+ mockLispDisabledBefore();
try {
customizer.deleteCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
} catch (IllegalArgumentException e) {
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRegisterCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRegisterCustomizerTest.java
index f4f3d2fb6..f8a95ca84 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRegisterCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRegisterCustomizerTest.java
@@ -90,7 +90,7 @@ public class MapRegisterCustomizerTest extends LispWriterCustomizerTest implemen
@Test
public void testWriteLispDisabled() throws WriteFailedException {
- mockLispDisabled();
+ mockLispDisabledAfter();
try {
customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
} catch (IllegalArgumentException e) {
@@ -102,7 +102,7 @@ public class MapRegisterCustomizerTest extends LispWriterCustomizerTest implemen
@Test
public void testUpdateLispDisabled() throws WriteFailedException {
- mockLispDisabled();
+ mockLispDisabledAfter();
try {
customizer.updateCurrentAttributes(EMPTY_ID, EMPTY_DATA,EMPTY_DATA, writeContext);
} catch (IllegalArgumentException e) {
@@ -114,7 +114,7 @@ public class MapRegisterCustomizerTest extends LispWriterCustomizerTest implemen
@Test
public void testDeleteLispDisabled() throws WriteFailedException {
- mockLispDisabled();
+ mockLispDisabledBefore();
try {
customizer.deleteCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
} catch (IllegalArgumentException e) {
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRequestModeCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRequestModeCustomizerTest.java
index c43960e20..7a48e84a4 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRequestModeCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRequestModeCustomizerTest.java
@@ -79,7 +79,7 @@ public class MapRequestModeCustomizerTest extends LispWriterCustomizerTest {
@Test
public void testWriteLispDisabled() throws WriteFailedException {
- mockLispDisabled();
+ mockLispDisabledAfter();
try {
customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
} catch (IllegalArgumentException e) {
@@ -91,7 +91,7 @@ public class MapRequestModeCustomizerTest extends LispWriterCustomizerTest {
@Test
public void testUpdateLispDisabled() throws WriteFailedException {
- mockLispDisabled();
+ mockLispDisabledAfter();
try {
customizer.updateCurrentAttributes(EMPTY_ID, EMPTY_DATA,EMPTY_DATA, writeContext);
} catch (IllegalArgumentException e) {
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizerTest.java
index bc7703b20..a18fa0ef6 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizerTest.java
@@ -106,7 +106,7 @@ public class MapResolverCustomizerTest extends LispWriterCustomizerTest implemen
@Test
public void testWriteLispDisabled() throws WriteFailedException {
- mockLispDisabled();
+ mockLispDisabledAfter();
try {
customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
} catch (IllegalArgumentException e) {
@@ -118,7 +118,7 @@ public class MapResolverCustomizerTest extends LispWriterCustomizerTest implemen
@Test
public void testDeleteLispDisabled() throws WriteFailedException {
- mockLispDisabled();
+ mockLispDisabledBefore();
try {
customizer.deleteCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
} catch (IllegalArgumentException e) {
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizerTest.java
index 14ff2c58c..fb4561c38 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizerTest.java
@@ -91,7 +91,7 @@ public class MapServerCustomizerTest extends LispWriterCustomizerTest implements
@Test
public void testWriteLispDisabled() throws WriteFailedException {
- mockLispDisabled();
+ mockLispDisabledAfter();
try {
customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
} catch (IllegalArgumentException e) {
@@ -103,7 +103,7 @@ public class MapServerCustomizerTest extends LispWriterCustomizerTest implements
@Test
public void testDeleteLispDisabled() throws WriteFailedException {
- mockLispDisabled();
+ mockLispDisabledBefore();
try {
customizer.deleteCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
} catch (IllegalArgumentException e) {
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PetrCfgCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PetrCfgCustomizerTest.java
index f46d79547..329aeb35d 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PetrCfgCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PetrCfgCustomizerTest.java
@@ -86,7 +86,7 @@ public class PetrCfgCustomizerTest extends LispWriterCustomizerTest {
@Test
public void testWriteLispDisabled() throws WriteFailedException {
- mockLispDisabled();
+ mockLispDisabledAfter();
try {
customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
} catch (IllegalArgumentException e) {
@@ -98,7 +98,7 @@ public class PetrCfgCustomizerTest extends LispWriterCustomizerTest {
@Test
public void testUpdateLispDisabled() throws WriteFailedException {
- mockLispDisabled();
+ mockLispDisabledAfter();
try {
customizer.updateCurrentAttributes(EMPTY_ID, EMPTY_DATA,EMPTY_DATA, writeContext);
} catch (IllegalArgumentException e) {
@@ -110,7 +110,7 @@ public class PetrCfgCustomizerTest extends LispWriterCustomizerTest {
@Test
public void testDeleteLispDisabled() throws WriteFailedException {
- mockLispDisabled();
+ mockLispDisabledBefore();
try {
customizer.deleteCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
} catch (IllegalArgumentException e) {
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PitrCfgCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PitrCfgCustomizerTest.java
index 520b5ee72..9c301fb42 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PitrCfgCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PitrCfgCustomizerTest.java
@@ -120,7 +120,7 @@ public class PitrCfgCustomizerTest extends LispWriterCustomizerTest {
@Test
public void testWriteLispDisabled() throws WriteFailedException {
- mockLispDisabled();
+ mockLispDisabledAfter();
try {
customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
} catch (IllegalArgumentException e) {
@@ -132,7 +132,7 @@ public class PitrCfgCustomizerTest extends LispWriterCustomizerTest {
@Test
public void testUpdateLispDisabled() throws WriteFailedException {
- mockLispDisabled();
+ mockLispDisabledAfter();
try {
customizer.updateCurrentAttributes(EMPTY_ID, EMPTY_DATA,EMPTY_DATA, writeContext);
} catch (IllegalArgumentException e) {
@@ -144,7 +144,7 @@ public class PitrCfgCustomizerTest extends LispWriterCustomizerTest {
@Test
public void testDeleteLispDisabled() throws WriteFailedException {
- mockLispDisabled();
+ mockLispDisabledBefore();
try {
customizer.deleteCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
} catch (IllegalArgumentException e) {
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/RlocProbeCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/RlocProbeCustomizerTest.java
index 6ae8277e4..5917ddded 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/RlocProbeCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/RlocProbeCustomizerTest.java
@@ -82,7 +82,7 @@ public class RlocProbeCustomizerTest extends LispWriterCustomizerTest implements
@Test
public void testWriteLispDisabled() throws WriteFailedException {
- mockLispDisabled();
+ mockLispDisabledAfter();
try {
customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
} catch (IllegalArgumentException e) {
@@ -94,7 +94,7 @@ public class RlocProbeCustomizerTest extends LispWriterCustomizerTest implements
@Test
public void testUpdateLispDisabled() throws WriteFailedException {
- mockLispDisabled();
+ mockLispDisabledAfter();
try {
customizer.updateCurrentAttributes(EMPTY_ID, EMPTY_DATA,EMPTY_DATA, writeContext);
} catch (IllegalArgumentException e) {
@@ -106,7 +106,7 @@ public class RlocProbeCustomizerTest extends LispWriterCustomizerTest implements
@Test
public void testDeleteLispDisabled() throws WriteFailedException {
- mockLispDisabled();
+ mockLispDisabledBefore();
try {
customizer.deleteCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
} catch (IllegalArgumentException e) {
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizerTest.java
index 1bf4b772f..04a50bc6c 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizerTest.java
@@ -89,7 +89,7 @@ public class VniTableCustomizerTest extends LispWriterCustomizerTest {
@Test
public void testWriteLispDisabled() throws WriteFailedException {
- mockLispDisabled();
+ mockLispDisabledAfter();
try {
customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
} catch (IllegalArgumentException e) {
@@ -101,7 +101,7 @@ public class VniTableCustomizerTest extends LispWriterCustomizerTest {
@Test
public void testDeleteLispDisabled() throws WriteFailedException {
- mockLispDisabled();
+ mockLispDisabledBefore();
try {
customizer.deleteCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
} catch (IllegalArgumentException e) {