Code example for ReferenceQueue

Methods: poll

0
		// This fails... 
		assertTrue("Should remain enqueued.", !ref.isEnqueued());
		assertTrue("Can not enqueue twice.", (!ref.enqueue())
				&& (rq.poll() == null));
 
		rq = new ReferenceQueue();
		obj = new Object();
		ref = new WeakReference(obj, rq);
		assertTrue("Enqueue failed2.", (!ref.isEnqueued())
				&& ((ref.enqueue()) && (ref.isEnqueued())));
		assertTrue("Not properly enqueued2.", rq.poll().get() == obj);
		assertTrue("Should remain enqueued2.", !ref.isEnqueued()); // This
		// fails. 
		assertTrue("Can not enqueue twice2.", (!ref.enqueue())
				&& (rq.poll() == null));
	} 
 
	/** 
	 * @tests java.lang.ref.Reference#enqueue() 
	 */ 
	public void test_general() throws Exception {