use of java.util.concurrent.LinkedTransferQueue in project j2objc by google.
the class LinkedTransferQueueTest method testRemoveElementAndAdd.
/**
* An add following remove(x) succeeds
*/
public void testRemoveElementAndAdd() throws InterruptedException {
LinkedTransferQueue q = new LinkedTransferQueue();
assertTrue(q.add(one));
assertTrue(q.add(two));
assertTrue(q.remove(one));
assertTrue(q.remove(two));
assertTrue(q.add(three));
assertSame(q.take(), three);
}
use of java.util.concurrent.LinkedTransferQueue in project j2objc by google.
the class LinkedTransferQueueTest method testTryTransfer8.
/**
* tryTransfer attempts to enqueue into the queue and fails
* returning false not enqueueing and the successive poll is null
*/
public void testTryTransfer8() throws InterruptedException {
final LinkedTransferQueue q = new LinkedTransferQueue();
assertTrue(q.offer(four));
assertEquals(1, q.size());
long startTime = System.nanoTime();
assertFalse(q.tryTransfer(five, timeoutMillis(), MILLISECONDS));
assertTrue(millisElapsedSince(startTime) >= timeoutMillis());
assertEquals(1, q.size());
assertSame(four, q.poll());
assertNull(q.poll());
checkEmpty(q);
}
use of java.util.concurrent.LinkedTransferQueue in project dubbo by alibaba.
the class StringToTransferQueueConverterTest method testConvert.
@Test
public void testConvert() {
TransferQueue values = new LinkedTransferQueue(asList(1, 2, 3));
TransferQueue result = (TransferQueue) converter.convert("1,2,3", List.class, Integer.class);
assertTrue(CollectionUtils.equals(values, result));
values.clear();
values.addAll(asList("123"));
result = (TransferQueue) converter.convert("123", NavigableSet.class, String.class);
assertTrue(CollectionUtils.equals(values, result));
assertNull(converter.convert(null, Collection.class, Integer.class));
assertNull(converter.convert("", Collection.class, null));
}
use of java.util.concurrent.LinkedTransferQueue in project mapdb by jankotek.
the class LinkedTransferQueueTest method testRemoveAll.
/**
* removeAll(c) removes only those elements of c and reports true
* if changed
*/
public void testRemoveAll() {
for (int i = 1; i < SIZE; ++i) {
LinkedTransferQueue q = populatedQueue(SIZE);
LinkedTransferQueue p = populatedQueue(i);
assertTrue(q.removeAll(p));
assertEquals(SIZE - i, q.size());
for (int j = 0; j < i; ++j) {
assertFalse(q.contains(p.remove()));
}
}
}
use of java.util.concurrent.LinkedTransferQueue in project mapdb by jankotek.
the class LinkedTransferQueueTest method testToArray.
/**
* toArray() contains all elements in FIFO order
*/
public void testToArray() {
LinkedTransferQueue q = populatedQueue(SIZE);
Object[] o = q.toArray();
for (int i = 0; i < o.length; i++) {
assertSame(o[i], q.poll());
}
}
Aggregations