* @tests java.lang.ref.Reference#enqueue()
*/
public void test_enqueue() {
ReferenceQueue rq = new ReferenceQueue();
obj = new Object();
Reference ref = new SoftReference(obj, rq);
assertTrue("Enqueue failed.", (!ref.isEnqueued())
&& ((ref.enqueue()) && (ref.isEnqueued())));
assertTrue("Not properly enqueued.", rq.poll().get() == obj);
// 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));
}