ivankelly commented on a change in pull request #1550: Issue #1517: make 
getLastConfirmedEntry in ManagedLedgerImpl return real LAC
URL: https://github.com/apache/incubator-pulsar/pull/1550#discussion_r180784775
 
 

 ##########
 File path: 
pulsar-broker/src/test/java/org/apache/pulsar/client/api/TopicReaderTest.java
 ##########
 @@ -448,4 +448,34 @@ public void 
testReaderReachEndofTopicOnMessageWithBatches() throws Exception {
         assertFalse(reader.hasMessageAvailable());
         producer.close();
     }
+
+    @Test
+    public void testMessageAvailableAfterRestart() throws Exception {
+        String topic = 
"persistent://my-property/use/my-ns/testMessageAvailableAfterRestart";
+        // stop retention from cleaning up
+        
pulsarClient.newConsumer().topic(topic).subscriptionName("sub1").subscribe().close();
+
+        try (Reader<byte[]> reader = pulsarClient.newReader().topic(topic)
+            .startMessageId(MessageId.earliest).create()) {
+            assertFalse(reader.hasMessageAvailable());
+        }
+
+        try (Producer<byte[]> producer = 
pulsarClient.newProducer().topic(topic).create()) {
+            producer.send("my-message-1".getBytes());
+        }
+
+        try (Reader<byte[]> reader = pulsarClient.newReader().topic(topic)
+            .startMessageId(MessageId.earliest).create()) {
+            assertTrue(reader.hasMessageAvailable());
+        }
+
+        // cause broker to drop topic. Will be loaded next time we access it
+        pulsar.getBrokerService().getTopicReference(topic).get().close().get();
+
+        try (Reader<byte[]> reader = pulsarClient.newReader().topic(topic)
+            .startMessageId(MessageId.earliest).create()) {
+            assertTrue(reader.hasMessageAvailable());
 
 Review comment:
   Should assert that the returned id matches the id returned from send().

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to