154155156157158159160161162163164
} assertTrue(latch.await(5, TimeUnit.SECONDS)); queue.removeItemListener(id); queue.offer("item-a"); queue.poll(); assertTrue(notCalled.get()); } private static class TestItemListener implements ItemListener { int offer;
6465666768697071727374
} assertEquals("item0", q1.peek()); assertEquals("item0", q2.peek()); for (int i = 0; i < 100; i++) { assertEquals("item" + i, q1.poll()); assertEquals("item" + i, q2.poll()); } } /** * Test for issue 730. (google)
147148149150151152153154155156157
h1.getLifecycleService().shutdown(); for (int i = 40; i < 100; i++) { assertTrue(q2.offer("item" + i, 100, TimeUnit.SECONDS)); } for (int i = 0; i < 100; i++) { assertEquals("item" + i, q2.poll()); } } @Test public void testPollNull() throws Exception {
161162163164165166167168169170171
final HazelcastInstance h2 = instances[1]; final IQueue q1 = h1.getQueue("default"); final IQueue q2 = h2.getQueue("default"); for (int i = 0; i < 100; i++) { assertNull(q1.poll()); assertNull(q2.poll()); } assertNull(q1.poll(2, TimeUnit.SECONDS)); assertNull(q2.poll(2, TimeUnit.SECONDS)); }
164165166167168169170171172173174
for (int i = 0; i < 100; i++) { assertNull(q1.poll()); assertNull(q2.poll()); } assertNull(q1.poll(2, TimeUnit.SECONDS)); assertNull(q2.poll(2, TimeUnit.SECONDS)); } @Test public void testTake() throws Exception { TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
268269270271272273274275276277278
} }); es.execute(new Runnable() { public void run() { try { if ("item".equals(q2.poll(5, TimeUnit.SECONDS))) { latch.countDown(); } } catch (InterruptedException e) { e.printStackTrace(); }
308309310311312313314315316317318
Thread.sleep(3000); for (int i = 0; i < 100; i++) { if (("item" + i).equals(q1.poll(2, TimeUnit.SECONDS))) { pollLatch.countDown(); } if (("item" + i).equals(q2.poll(2, TimeUnit.SECONDS))) { pollLatch.countDown(); } } } catch (InterruptedException e) { e.printStackTrace();
235236237238239240241242243244245
try { latch.await(30, TimeUnit.SECONDS); } catch (InterruptedException e) { e.printStackTrace(); } q.poll(); } }.start(); client.send(new OfferRequest(queueName, 500, ss.toData("item7"))); result = client.receive();