Search in sources :

Example 6 with ReadResultSet

use of com.hazelcast.ringbuffer.ReadResultSet in project hazelcast by hazelcast.

the class RingbufferAbstractTest method readyManyAsync_whenSomeWaitingForSingleItemNeeded.

@Test
public void readyManyAsync_whenSomeWaitingForSingleItemNeeded() throws ExecutionException, InterruptedException {
    final ICompletableFuture<ReadResultSet<String>> f = ringbuffer.readManyAsync(0, 1, 10, null);
    assertTrueAllTheTime(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertFalse(f.isDone());
        }
    }, 5);
    ringbuffer.add("1");
    assertCompletesEventually(f);
    ReadResultSet<String> resultSet = f.get();
    assertThat(f.get(), contains("1"));
    assertEquals(1, resultSet.readCount());
}
Also used : AssertTask(com.hazelcast.test.AssertTask) ReadResultSet(com.hazelcast.ringbuffer.ReadResultSet) DistributedObjectDestroyedException(com.hazelcast.spi.exception.DistributedObjectDestroyedException) StaleSequenceException(com.hazelcast.ringbuffer.StaleSequenceException) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Aggregations

ReadResultSet (com.hazelcast.ringbuffer.ReadResultSet)6 Test (org.junit.Test)6 PortableReadResultSet (com.hazelcast.ringbuffer.impl.client.PortableReadResultSet)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 StaleSequenceException (com.hazelcast.ringbuffer.StaleSequenceException)2 DistributedObjectDestroyedException (com.hazelcast.spi.exception.DistributedObjectDestroyedException)2 AssertTask (com.hazelcast.test.AssertTask)2 ExecutionException (java.util.concurrent.ExecutionException)2