use of java.util.NoSuchElementException in project j2objc by google.
the class VectorTest method test_firstElement.
/**
* @tests java.util.Vector#firstElement()
*/
public void test_firstElement() {
// Test for method java.lang.Object java.util.Vector.firstElement()
assertEquals("Returned incorrect firstElement", "Test 0", tVector.firstElement());
tVector.insertElementAt(null, 0);
assertNull("Returned incorrect firstElement--wanted null", tVector.firstElement());
Vector v = new Vector();
try {
v.firstElement();
fail("Should throw NoSuchElementException");
} catch (NoSuchElementException e) {
// Excepted
}
}
use of java.util.NoSuchElementException in project j2objc by google.
the class StringTokenizerTest method test_nextElement.
/**
* @tests java.util.StringTokenizer#nextElement()
*/
public void test_nextElement() {
// Test for method java.lang.Object
// java.util.StringTokenizer.nextElement()
StringTokenizer st = new StringTokenizer("This is a test String");
assertEquals("nextElement returned incorrect value", "This", ((String) st.nextElement()));
assertEquals("nextElement returned incorrect value", "is", ((String) st.nextElement()));
assertEquals("nextElement returned incorrect value", "a", ((String) st.nextElement()));
assertEquals("nextElement returned incorrect value", "test", ((String) st.nextElement()));
assertEquals("nextElement returned incorrect value", "String", ((String) st.nextElement()));
try {
st.nextElement();
fail("nextElement failed to throw a NoSuchElementException when it should have been out of elements");
} catch (NoSuchElementException e) {
return;
}
}
use of java.util.NoSuchElementException in project j2objc by google.
the class StringTokenizerTest method test_nextToken.
/**
* @tests java.util.StringTokenizer#nextToken()
*/
public void test_nextToken() {
// Test for method java.lang.String
// java.util.StringTokenizer.nextToken()
StringTokenizer st = new StringTokenizer("This is a test String");
assertEquals("nextToken returned incorrect value", "This", st.nextToken());
assertEquals("nextToken returned incorrect value", "is", st.nextToken());
assertEquals("nextToken returned incorrect value", "a", st.nextToken());
assertEquals("nextToken returned incorrect value", "test", st.nextToken());
assertEquals("nextToken returned incorrect value", "String", st.nextToken());
try {
st.nextToken();
fail("nextToken failed to throw a NoSuchElementException when it should have been out of elements");
} catch (NoSuchElementException e) {
return;
}
}
use of java.util.NoSuchElementException in project j2objc by google.
the class VectorTest method test_lastElement.
/**
* @tests java.util.Vector#isEmpty()
*/
/* TODO(tball): enable when threading is supported.
public void test_isEmpty_subtest0() {
final Vector v = new Vector();
v.addElement("initial");
Thread t1 = new Thread() {
public void run() {
while (!v.isEmpty())
;
v.addElement("final");
}
};
t1.start();
for (int i = 0; i < 10000; i++) {
synchronized (v) {
v.removeElementAt(0);
v.addElement(String.valueOf(i));
}
int size;
if ((size = v.size()) != 1) {
String result = "Size is not 1: " + size + " " + v;
// terminate the thread
v.removeAllElements();
fail(result);
}
}
// terminate the thread
v.removeElementAt(0);
}
*/
/**
* @tests java.util.Vector#lastElement()
*/
public void test_lastElement() {
// Test for method java.lang.Object java.util.Vector.lastElement()
assertEquals("Incorrect last element returned", "Test 99", tVector.lastElement());
tVector.addElement(null);
assertNull("Incorrect last element returned--wanted null", tVector.lastElement());
Vector vector = new Vector();
try {
vector.lastElement();
fail("Should throw NoSuchElementException");
} catch (NoSuchElementException e) {
// Excepted
}
}
use of java.util.NoSuchElementException in project okhttp by square.
the class RouteSelectorTest method singleRouteReturnsFailedRoute.
@Test
public void singleRouteReturnsFailedRoute() throws Exception {
Address address = httpAddress();
RouteSelector routeSelector = new RouteSelector(address, routeDatabase);
assertTrue(routeSelector.hasNext());
dns.set(uriHost, dns.allocate(1));
Route route = routeSelector.next();
routeDatabase.failed(route);
routeSelector = new RouteSelector(address, routeDatabase);
assertRoute(routeSelector.next(), address, NO_PROXY, dns.lookup(uriHost, 0), uriPort);
assertFalse(routeSelector.hasNext());
try {
routeSelector.next();
fail();
} catch (NoSuchElementException expected) {
}
}
Aggregations