Search in sources :

Example 26 with NoSuchElementException

use of java.util.NoSuchElementException in project j2objc by google.

the class ConcurrentLinkedQueueTest method testElement.

/**
     * element returns next element, or throws NSEE if empty
     */
public void testElement() {
    ConcurrentLinkedQueue q = populatedQueue(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(i, q.element());
        assertEquals(i, q.poll());
    }
    try {
        q.element();
        shouldThrow();
    } catch (NoSuchElementException success) {
    }
}
Also used : ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) NoSuchElementException(java.util.NoSuchElementException)

Example 27 with NoSuchElementException

use of java.util.NoSuchElementException in project j2objc by google.

the class ConcurrentLinkedQueueTest method testRemove.

/**
     * remove removes next element, or throws NSEE if empty
     */
public void testRemove() {
    ConcurrentLinkedQueue q = populatedQueue(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(i, q.remove());
    }
    try {
        q.remove();
        shouldThrow();
    } catch (NoSuchElementException success) {
    }
}
Also used : ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) NoSuchElementException(java.util.NoSuchElementException)

Example 28 with NoSuchElementException

use of java.util.NoSuchElementException in project j2objc by google.

the class ConcurrentLinkedDequeTest method testPop.

/**
     * pop() removes first element, or throws NSEE if empty
     */
public void testPop() {
    ConcurrentLinkedDeque q = populatedDeque(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(i, q.pop());
    }
    try {
        q.pop();
        shouldThrow();
    } catch (NoSuchElementException success) {
    }
}
Also used : NoSuchElementException(java.util.NoSuchElementException) ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque)

Example 29 with NoSuchElementException

use of java.util.NoSuchElementException in project j2objc by google.

the class ConcurrentLinkedDequeTest method testDescendingIterator.

/**
     * Descending iterator iterates through all elements
     */
public void testDescendingIterator() {
    ConcurrentLinkedDeque q = populatedDeque(SIZE);
    int i = 0;
    Iterator it = q.descendingIterator();
    while (it.hasNext()) {
        assertTrue(q.contains(it.next()));
        ++i;
    }
    assertEquals(i, SIZE);
    assertFalse(it.hasNext());
    try {
        it.next();
        shouldThrow();
    } catch (NoSuchElementException success) {
    }
}
Also used : Iterator(java.util.Iterator) NoSuchElementException(java.util.NoSuchElementException) ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque)

Example 30 with NoSuchElementException

use of java.util.NoSuchElementException in project j2objc by google.

the class ConcurrentLinkedDequeTest method testRemoveFirst.

/**
     * removeFirst() removes first element, or throws NSEE if empty
     */
public void testRemoveFirst() {
    ConcurrentLinkedDeque q = populatedDeque(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(i, q.removeFirst());
    }
    try {
        q.removeFirst();
        shouldThrow();
    } catch (NoSuchElementException success) {
    }
    assertNull(q.peekFirst());
}
Also used : NoSuchElementException(java.util.NoSuchElementException) ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque)

Aggregations

NoSuchElementException (java.util.NoSuchElementException)720 Iterator (java.util.Iterator)122 Test (org.junit.Test)61 Scanner (java.util.Scanner)59 IOException (java.io.IOException)58 ArrayList (java.util.ArrayList)57 StringTokenizer (java.util.StringTokenizer)49 InputMismatchException (java.util.InputMismatchException)46 Locale (java.util.Locale)25 HashMap (java.util.HashMap)22 Map (java.util.Map)22 File (java.io.File)21 List (java.util.List)20 NodeIterator (javax.jcr.NodeIterator)20 HashSet (java.util.HashSet)16 ConcurrentLinkedDeque (java.util.concurrent.ConcurrentLinkedDeque)16 Collection (java.util.Collection)15 LinkedList (java.util.LinkedList)15 Set (java.util.Set)15 Enumeration (java.util.Enumeration)14