Skip to content

Commit 168de80

Browse files
committed
update test for subscribeTopic
Signed-off-by: Manish Dait <[email protected]>
1 parent 07489dc commit 168de80

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

hiero-enterprise-spring/src/test/java/com/openelements/hiero/spring/test/TopicClientTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ void testSubmitMessageThrowExceptionFroInvalidId() {
210210
}
211211

212212
@Test
213-
void testSubscribeTopic() throws HieroException {
213+
void testSubscribeTopic() throws Exception {
214214
final String msg = "Hello Hiero";
215215
final List<String> messages = new ArrayList<>();
216216
final TopicId topicId = topicClient.createTopic();
@@ -222,14 +222,16 @@ void testSubscribeTopic() throws HieroException {
222222

223223
topicClient.submitMessage(topicId, msg);
224224
hieroTestUtils.waitForMirrorNodeRecords();
225+
Thread.sleep(5000); // Make sure to wait after message get recorded in mirrornode
225226

226227
Assertions.assertNotNull(handler);
227228
Assertions.assertEquals(1, messages.size());
228229
Assertions.assertEquals(msg,messages.getFirst());
230+
handler.unsubscribe();
229231
}
230232

231233
@Test
232-
void testSubscribeTopicWithLimit() throws HieroException {
234+
void testSubscribeTopicWithLimit() throws Exception {
233235
final String msg = "Hello Hiero";
234236
final long limit = 1;
235237

@@ -243,12 +245,15 @@ void testSubscribeTopicWithLimit() throws HieroException {
243245

244246
topicClient.submitMessage(topicId, msg);
245247
hieroTestUtils.waitForMirrorNodeRecords();
248+
Thread.sleep(5000); // Make sure to wait after message get recorded in mirrornode
246249

247250
topicClient.submitMessage(topicId, msg);
248251
hieroTestUtils.waitForMirrorNodeRecords();
252+
Thread.sleep(5000); // Make sure to wait after message get recorded in mirrornode
249253

250254
Assertions.assertNotNull(handler);
251255
Assertions.assertEquals(limit, messages.size());
256+
handler.unsubscribe();
252257
}
253258

254259
@Test
@@ -278,6 +283,7 @@ void testSubscribeTopicWithStartAndEndTime() throws HieroException {
278283
);
279284

280285
Assertions.assertNotNull(handler);
286+
handler.unsubscribe();
281287
}
282288

283289
@Test

0 commit comments

Comments
 (0)