ArrayBlockingQueueEx extends ArrayBlockingQueue<E> implements
                                                                  NotificationBlockingQueue<E> { @Override public void put(E o) throws InterruptedException { if (o == null) { throw new NullPointerException(); } queueLock.lock(); try { while (size() == capacity) { notFull.await(); } super.put(o); notEmpty.signal(); } finally { queueLock.unlock(); } } ArrayBlockingQueueEx(int capacity, boolean fair);  ArrayBlockingQueueEx(int capacity); @Override void finishQueueing(); @Override boolean offer(E o, long timeout, TimeUnit unit); @Override boolean offer(E o); @Override void put(E o); @Override E peek(); @Override E poll(long timeout, TimeUnit unit); @Override E poll(); @Override boolean isEmpty();  }
@Test public void testPut001() throws Exception { int capacity = 1; ArrayBlockingQueueEx<DataValueObject> queue = new ArrayBlockingQueueEx<DataValueObject>(capacity); try { queue.put(null); fail(); } catch (NullPointerException e) { } catch (Exception e) { fail(); } }
@Test public void testPut002() throws Exception { int capacity = 1; DataValueObject obj1 = new DataValueObject("hoge1"); final CountDownLatch threadSync = new CountDownLatch(1); final ArrayBlockingQueueEx<DataValueObject> queue = new ArrayBlockingQueueEx<DataValueObject>(capacity); queue.put(obj1); ErrorFeedBackThread thread01 = new ErrorFeedBackThread() { @Override public void doRun() throws Exception { DataValueObject obj2 = new DataValueObject("hoge2"); long timeStart = System.currentTimeMillis(); threadSync.countDown(); try { queue.put(obj2); throw new RuntimeException("An exception did not occur within a definite period of time."); } catch (InterruptedException e) { } long timeEnd = System.currentTimeMillis(); long timeDiff = timeEnd - timeStart; if (timeDiff < 950) { throw new RuntimeException("An exception did not occur within a definite period of time."); } } }; thread01.start(); threadSync.await(); TimeUnit.MILLISECONDS.sleep(1000); thread01.interrupt(); thread01.throwErrorOrExceptionIfThrown(); }