diff options
author | Marek Gradzki <mgradzki@cisco.com> | 2016-06-27 10:16:31 +0200 |
---|---|---|
committer | Marek Gradzki <mgradzki@cisco.com> | 2016-06-27 10:16:36 +0200 |
commit | 6e3de9c3e99fdf284e63f303d3a32bd4dfbd124e (patch) | |
tree | 09dd72073767af3b26b6a8cdb4c20e5e6f8dc9ad /v3po/vpp-translate-utils/src/test/java/io/fd | |
parent | c05597d26843210570d49f9675c57a13b668ad32 (diff) |
HONEYCOMB-100: introduce default 5s timeout
in TranslateUtils.getReplyFor* calls
Change-Id: Iac2bb428ea6adcc8d3da2238db1dec708df550f0
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'v3po/vpp-translate-utils/src/test/java/io/fd')
-rw-r--r-- | v3po/vpp-translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtilsTest.java | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/v3po/vpp-translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtilsTest.java b/v3po/vpp-translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtilsTest.java index 89e7d9d89..334887430 100644 --- a/v3po/vpp-translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtilsTest.java +++ b/v3po/vpp-translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtilsTest.java @@ -3,12 +3,62 @@ package io.fd.honeycomb.v3po.translate.v3po.util; import static io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils.reverseBytes; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Matchers.anyLong; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import org.junit.Test; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone; +import org.opendaylight.yangtools.yang.binding.DataContainer; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.openvpp.jvpp.dto.JVppReply; public class TranslateUtilsTest { + private static class AnDataObject implements DataObject { + @Override + public Class<? extends DataContainer> getImplementedInterface() { + return null; + } + } + + @Test + public void testGetReplyForWriteTimeout() throws Exception { + final Future<JVppReply<?>> future = mock(Future.class); + when(future.get(anyLong(), eq(TimeUnit.SECONDS))).thenThrow(TimeoutException.class); + final InstanceIdentifier<AnDataObject> replyType = InstanceIdentifier.create(AnDataObject.class); + try { + TranslateUtils.getReplyForWrite(future, replyType); + } catch (WriteTimeoutException e) { + assertTrue(e.getCause() instanceof TimeoutException); + assertEquals(replyType, e.getFailedId()); + return; + } + fail("WriteTimeoutException was expected"); + } + + @Test + public void testGetReplyForReadTimeout() throws Exception { + final Future<JVppReply<?>> future = mock(Future.class); + final InstanceIdentifier<AnDataObject> replyType = InstanceIdentifier.create(AnDataObject.class); + when(future.get(anyLong(), eq(TimeUnit.SECONDS))).thenThrow(TimeoutException.class); + try { + TranslateUtils.getReplyForRead(future, replyType); + } catch (ReadTimeoutException e) { + assertTrue(e.getCause() instanceof TimeoutException); + assertEquals(replyType, e.getFailedId()); + return; + } + fail("ReadTimeoutException was expected"); + } + @Test public void testIpv4NoZone() throws Exception { final Ipv4AddressNoZone ipv4Addr = new Ipv4AddressNoZone("192.168.1.1"); @@ -83,4 +133,5 @@ public class TranslateUtilsTest { public void testByteToBooleanFailed() { TranslateUtils.byteToBoolean((byte) 123); } + }
\ No newline at end of file |