From 4d43c7c571b213e9de026d7a8c3899d4cea37307 Mon Sep 17 00:00:00 2001 From: Darius Maitia Date: Mon, 19 Feb 2024 12:13:54 +0100 Subject: [PATCH] feature(user attachment): refactor tests --- .../kotlin/io/zenoh/AttachmentTest.kt | 64 +++++++------------ 1 file changed, 22 insertions(+), 42 deletions(-) diff --git a/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/AttachmentTest.kt b/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/AttachmentTest.kt index 13b003bf..97707c72 100644 --- a/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/AttachmentTest.kt +++ b/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/AttachmentTest.kt @@ -65,48 +65,6 @@ class AttachmentTest { assertAttachmentOk(receivedSample!!.attachment) } - @Test - fun replyWithAttachmentTest() { - var reply: Reply? = null - val session = Session.open().getOrThrow() - - val queryable = session.declareQueryable(keyExpr).with { query -> - query.reply(keyExpr).success("message").withAttachment(attachment).res() - }.res().getOrThrow() - - session.get(keyExpr).with { reply = it }.timeout(Duration.ofMillis(1000)).res() - Thread.sleep(1000) - - queryable.close() - session.close() - - assertNotNull(reply) - assertTrue(reply is Reply.Success) - assertAttachmentOk((reply as Reply.Success).sample.attachment!!) - } - - @Test - fun replyWithoutAttachmentTest() { - var reply: Reply? = null - val session = Session.open().getOrThrow() - val queryable = session.declareQueryable(keyExpr).with { query -> - query.reply(keyExpr).success("message").res() - }.res().getOrThrow() - - session.get(QueryableTest.TEST_KEY_EXP).with { - reply = it - }.timeout(Duration.ofMillis(1000)).res() - - Thread.sleep(1000) - - queryable.close() - session.close() - - assertNotNull(reply) - assertTrue(reply is Reply.Success) - assertNull((reply as Reply.Success).sample.attachment) - } - @Test fun publisherPutWithAttachmentTest() { val session = Session.open().getOrThrow() @@ -246,6 +204,28 @@ class AttachmentTest { assertAttachmentOk(receivedAttachment) } + @Test + fun queryReplyWithoutAttachmentTest() { + var reply: Reply? = null + val session = Session.open().getOrThrow() + val queryable = session.declareQueryable(keyExpr).with { query -> + query.reply(keyExpr).success("test").res() + }.res().getOrThrow() + + session.get(QueryableTest.TEST_KEY_EXP).with { + reply = it + }.timeout(Duration.ofMillis(1000)).res() + + Thread.sleep(1000) + + queryable.close() + session.close() + + assertNotNull(reply) + assertTrue(reply is Reply.Success) + assertNull((reply as Reply.Success).sample.attachment) + } + @Test fun encodeAndDecodeNumbersTest() { val numbers: List = arrayListOf(0, 1, -1, 12345, -12345, 123567, 123456789, -123456789)