use of com.hazelcast.collection.IQueue in project hazelcast by hazelcast.
the class ClientTxnQueueTest method testTransactionalOfferPoll.
@Test
public void testTransactionalOfferPoll() {
final String item = "offered";
final String queueName = randomString();
final IQueue queue = client.getQueue(queueName);
final TransactionContext context = client.newTransactionContext();
context.beginTransaction();
TransactionalQueue txnQueue = context.getQueue(queueName);
txnQueue.offer(item);
assertEquals(item, txnQueue.poll());
context.commitTransaction();
}
use of com.hazelcast.collection.IQueue in project hazelcast by hazelcast.
the class ClientTxnQueueTest method testQueueSizeAfterTxnOfferPoll.
@Test
public void testQueueSizeAfterTxnOfferPoll() {
final String item = "offered";
final String queueName = randomString();
final IQueue queue = client.getQueue(queueName);
final TransactionContext context = client.newTransactionContext();
context.beginTransaction();
TransactionalQueue txnQueue = context.getQueue(queueName);
txnQueue.offer(item);
txnQueue.poll();
context.commitTransaction();
assertEquals(0, queue.size());
}
use of com.hazelcast.collection.IQueue in project hazelcast by hazelcast.
the class ClientTxnQueueTest method testTransactionalQueueSize.
@Test
public void testTransactionalQueueSize() {
final String item = "offered";
final String name = randomString();
final IQueue queue = client.getQueue(name);
queue.offer(item);
final TransactionContext context = client.newTransactionContext();
context.beginTransaction();
TransactionalQueue<String> txnQueue = context.getQueue(name);
txnQueue.offer(item);
assertEquals(2, txnQueue.size());
context.rollbackTransaction();
}
use of com.hazelcast.collection.IQueue in project hazelcast by hazelcast.
the class TransactionQueueTest method testListener_withOffer.
@Test
public void testListener_withOffer() {
HazelcastInstance hz = createHazelcastInstance();
String name = randomName();
IQueue<VersionedObject<String>> queue = hz.getQueue(name);
EventCountingItemListener listener = new EventCountingItemListener();
queue.addItemListener(listener, true);
hz.executeTransaction((TransactionalTask<Object>) ctx -> {
TransactionalQueue<VersionedObject<Object>> queue1 = ctx.getQueue(name);
return queue1.offer(new VersionedObject<>("item"));
});
assertTrueEventually(() -> assertEquals(1, listener.adds.get()));
}
use of com.hazelcast.collection.IQueue in project hazelcast by hazelcast.
the class MBeanTest method testQueue.
@Test
public void testQueue() throws Exception {
IQueue queue = holder.getHz().getQueue("queue");
queue.size();
holder.assertMBeanExistEventually("IQueue", queue.getName());
}
Aggregations