new BasicHeader("no", "token0 token1"),
new BasicHeader("pre", "<token0,token1"),
new BasicHeader("post", "token0,token1="),
};
HeaderIterator hit = new BasicHeaderIterator(headers, "in");
TokenIterator ti = new BasicTokenIterator(hit);
// constructor located token0
assertTrue(ti.hasNext());
try {
ti.nextToken();
fail("invalid infix character not detected");
} catch (ParseException px) {
// expected
}
// constructor located token0
hit = new BasicHeaderIterator(headers, "no");
ti = new BasicTokenIterator(hit);
assertTrue(ti.hasNext());
try {
ti.nextToken();
fail("missing token separator not detected");
} catch (ParseException px) {
// expected
}
// constructor seeks for the first token
hit = new BasicHeaderIterator(headers, "pre");
try {
new BasicTokenIterator(hit);
fail("invalid prefix character not detected");
} catch (ParseException px) {
// expected
}
hit = new BasicHeaderIterator(headers, "post");
ti = new BasicTokenIterator(hit);
assertTrue(ti.hasNext());
assertEquals("token0", "token0", ti.nextToken());
assertTrue(ti.hasNext());
// failure after the last must not go unpunished
try {
ti.nextToken();
fail("invalid postfix character not detected");
} catch (ParseException px) {
// expected
}
}