diff options
author | Marek Gradzki <mgradzki@cisco.com> | 2016-09-27 14:24:06 +0200 |
---|---|---|
committer | Marek Gradzki <mgradzki@cisco.com> | 2016-09-27 14:24:06 +0200 |
commit | a4b65a2de72906e53c94de3beb098744d6fc14ae (patch) | |
tree | 1d491daab017b3b96eda81f40c4872786dc2b44b /vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/vpp/util/JvppReplyConsumerTest.java | |
parent | c9820abdccb612d000a7a8bf6ddb763b3aec0a1d (diff) |
HONEYCOMB-206: change package name to match groupId
Change-Id: I74f769c09e86f08b1753e685a134d20e801bd7da
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/vpp/util/JvppReplyConsumerTest.java')
-rw-r--r-- | vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/vpp/util/JvppReplyConsumerTest.java | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/vpp/util/JvppReplyConsumerTest.java b/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/vpp/util/JvppReplyConsumerTest.java new file mode 100644 index 000000000..af05ffd8f --- /dev/null +++ b/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/vpp/util/JvppReplyConsumerTest.java @@ -0,0 +1,60 @@ +package io.fd.honeycomb.translate.vpp.util; + +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.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 JvppReplyConsumerTest implements JvppReplyConsumer { + + 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 { + 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 { + getReplyForRead(future, replyType); + } catch (ReadTimeoutException e) { + assertTrue(e.getCause() instanceof TimeoutException); + assertEquals(replyType, e.getFailedId()); + return; + } + fail("ReadTimeoutException was expected"); + } +}
\ No newline at end of file |