use of java.util.concurrent.ConcurrentLinkedDeque in project mapdb by jankotek.
the class ConcurrentLinkedDequeTest method testRemoveLast.
/**
* removeLast() removes last element, or throws NSEE if empty
*/
public void testRemoveLast() {
ConcurrentLinkedDeque q = populatedDeque(SIZE);
for (int i = SIZE - 1; i >= 0; --i) {
assertEquals(i, q.removeLast());
}
try {
q.removeLast();
shouldThrow();
} catch (NoSuchElementException success) {
}
assertNull(q.peekLast());
}
use of java.util.concurrent.ConcurrentLinkedDeque in project mapdb by jankotek.
the class ConcurrentLinkedDequeTest method testRemoveLastOccurrence.
/**
* removeLastOccurrence(x) removes x and returns true if present
*/
public void testRemoveLastOccurrence() {
ConcurrentLinkedDeque q = populatedDeque(SIZE);
for (int i = 1; i < SIZE; i += 2) {
assertTrue(q.removeLastOccurrence(new Integer(i)));
}
for (int i = 0; i < SIZE; i += 2) {
assertTrue(q.removeLastOccurrence(new Integer(i)));
assertFalse(q.removeLastOccurrence(new Integer(i + 1)));
}
assertTrue(q.isEmpty());
}
use of java.util.concurrent.ConcurrentLinkedDeque in project mapdb by jankotek.
the class ConcurrentLinkedDequeTest method testAddAll3.
/**
* addAll of a collection with any null elements throws NPE after
* possibly adding some elements
*/
public void testAddAll3() {
ConcurrentLinkedDeque q = new ConcurrentLinkedDeque();
Integer[] ints = new Integer[SIZE];
for (int i = 0; i < SIZE - 1; ++i) ints[i] = new Integer(i);
try {
q.addAll(Arrays.asList(ints));
shouldThrow();
} catch (NullPointerException success) {
}
}
use of java.util.concurrent.ConcurrentLinkedDeque in project mapdb by jankotek.
the class ConcurrentLinkedDequeTest method testRetainAll.
/**
* retainAll(c) retains only those elements of c and reports true if change
*/
public void testRetainAll() {
ConcurrentLinkedDeque q = populatedDeque(SIZE);
ConcurrentLinkedDeque p = populatedDeque(SIZE);
for (int i = 0; i < SIZE; ++i) {
boolean changed = q.retainAll(p);
if (i == 0)
assertFalse(changed);
else
assertTrue(changed);
assertTrue(q.containsAll(p));
assertEquals(SIZE - i, q.size());
p.remove();
}
}
use of java.util.concurrent.ConcurrentLinkedDeque in project mapdb by jankotek.
the class ConcurrentLinkedDequeTest method testRemoveFirstOccurrence.
/**
* removeFirstOccurrence(x) removes x and returns true if present
*/
public void testRemoveFirstOccurrence() {
ConcurrentLinkedDeque q = populatedDeque(SIZE);
for (int i = 1; i < SIZE; i += 2) {
assertTrue(q.removeFirstOccurrence(new Integer(i)));
}
for (int i = 0; i < SIZE; i += 2) {
assertTrue(q.removeFirstOccurrence(new Integer(i)));
assertFalse(q.removeFirstOccurrence(new Integer(i + 1)));
}
assertTrue(q.isEmpty());
}
Aggregations