public LoopbackChannel () { super(); cnt = new int[SIZEOF_CNT]; queue = new BlockingQueue(); }
public OperatorLogListener (Configuration cfg) { super(); this.cfg = cfg; queue = new BlockingQueue(); new Thread(this).start(); } public void setConfiguration (Configuration cfg)
@SuppressWarnings("unchecked") @Test public void testPending() throws Throwable { BlockingQueue blockingQueue = new BlockingQueue(); LinkedList queue = new LinkedList(); queue.add(Integer.valueOf(100)); blockingQueue.setQueue(queue); int result = blockingQueue.pending(); assertEquals("result", 1, result); }
@SuppressWarnings("unchecked") @Test public void testSetQueue() throws Throwable { LinkedList queue = new LinkedList(); BlockingQueue blockingQueue = new BlockingQueue(); blockingQueue.setQueue(queue); assertSame("blockingQueue.getQueue()", queue, blockingQueue.getQueue()); } }
@Test public void testConsumerCount() throws Throwable { int result = new BlockingQueue().consumerCount(); assertEquals("result", 0, result); }
@Test public void testReady() throws Throwable { boolean result = new BlockingQueue().ready(); assertTrue("result", result); }
@Test public void testEnqueue() throws Throwable { BlockingQueue blockingQueue = new BlockingQueue(); blockingQueue.enqueue("testString"); assertEquals("blockingQueue.getQueue().size()", 1, blockingQueue.getQueue().size()); assertEquals("blockingQueue.getQueue().get(0)", "testString", blockingQueue.getQueue().get(0)); }
@Test public void testRequeue() throws Throwable { BlockingQueue blockingQueue = new BlockingQueue(); blockingQueue.requeue("testString"); assertEquals("blockingQueue.getQueue().size()", 1, blockingQueue.getQueue().size()); assertEquals("blockingQueue.getQueue().get(0)", "testString", blockingQueue.getQueue().get(0)); }
@Test public void testPendingThrowsNullPointerException() throws Throwable { BlockingQueue blockingQueue = new BlockingQueue(); blockingQueue.setQueue(null); try { blockingQueue.pending(); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertNull("ex.getMessage()", ex.getMessage()); } }
@Test public void testReady1() throws Throwable { BlockingQueue blockingQueue = new BlockingQueue(); blockingQueue.close(); boolean result = blockingQueue.ready(); assertFalse("result", result); }
@Test public void testClose() throws Throwable { BlockingQueue blockingQueue = new BlockingQueue(); blockingQueue.close(); assertFalse("blockingQueue.ready()", blockingQueue.ready()); }
@Test public void testPending1() throws Throwable { BlockingQueue blockingQueue = new BlockingQueue(); blockingQueue.dequeue(-2L); int result = blockingQueue.pending(); assertEquals("result", 0, result); }
@Test public void testRequeueThrowsNullPointerException() throws Throwable { BlockingQueue blockingQueue = new BlockingQueue(); blockingQueue.setQueue(null); try { blockingQueue.requeue(Integer.valueOf(0)); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertNull("ex.getMessage()", ex.getMessage()); assertNull("blockingQueue.getQueue()", blockingQueue.getQueue()); } }
@SuppressWarnings("unchecked") @Test public void testDequeue8() throws Throwable { BlockingQueue blockingQueue = new BlockingQueue(); LinkedList queue = new LinkedList(); Integer integer = Integer.valueOf(100); queue.add(integer); blockingQueue.setQueue(queue); Integer result = (Integer) blockingQueue.dequeue(0L); assertSame("blockingQueue.getQueue()", queue, blockingQueue.getQueue()); assertFalse("blockingQueue.getQueue().contains(integer)", blockingQueue.getQueue().contains(integer)); assertSame("result", integer, result); assertEquals("blockingQueue.consumerCount()", 0, blockingQueue.consumerCount()); }
@Test public void testEnqueueThrowsClosed() throws Throwable { BlockingQueue blockingQueue = new BlockingQueue(); blockingQueue.close(); try { blockingQueue.enqueue(Integer.valueOf(-32)); fail("Expected Closed to be thrown"); } catch (BlockingQueue.Closed ex) { assertEquals("ex.getMessage()", "queue-closed", ex.getMessage()); assertEquals("blockingQueue.getQueue().size()", 0, blockingQueue.getQueue().size()); } }
@Test public void testDequeue6() throws Throwable { BlockingQueue blockingQueue = new BlockingQueue(); Integer o = Integer.valueOf(0); blockingQueue.enqueue(o); Integer result = (Integer) blockingQueue.dequeue(100L); assertEquals("blockingQueue.getQueue().size()", 0, blockingQueue.getQueue().size()); assertFalse("blockingQueue.getQueue().contains(o)", blockingQueue.getQueue().contains(o)); assertSame("result", o, result); assertEquals("blockingQueue.consumerCount()", 0, blockingQueue.consumerCount()); }
@Test public void testDequeue5() throws Throwable { BlockingQueue blockingQueue = new BlockingQueue(); Object result = blockingQueue.dequeue(2L); assertNull("result", result); assertEquals("blockingQueue.getQueue().size()", 0, blockingQueue.getQueue().size()); assertEquals("blockingQueue.consumerCount()", 0, blockingQueue.consumerCount()); }
@Test public void testEnqueueThrowsNullPointerException() throws Throwable { BlockingQueue blockingQueue = new BlockingQueue(); blockingQueue.setQueue(null); try { blockingQueue.enqueue(""); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertNull("ex.getMessage()", ex.getMessage()); assertNull("blockingQueue.getQueue()", blockingQueue.getQueue()); } }
@Test public void testConstructor() throws Throwable { BlockingQueue blockingQueue = new BlockingQueue(); assertEquals("blockingQueue.consumerCount()", 0, blockingQueue.consumerCount()); assertTrue("blockingQueue.ready()", blockingQueue.ready()); assertEquals("blockingQueue.getQueue().size()", 0, blockingQueue.getQueue().size()); }
@Test public void testRequeueThrowsClosed() throws Throwable { BlockingQueue blockingQueue = new BlockingQueue(); blockingQueue.close(); try { blockingQueue.requeue(""); fail("Expected Closed to be thrown"); } catch (BlockingQueue.Closed ex) { assertEquals("ex.getMessage()", "queue-closed", ex.getMessage()); assertEquals("blockingQueue.getQueue().size()", 0, blockingQueue.getQueue().size()); } }