}
@Test
public void testCacheFlag() throws Exception {
final XPath xpath = new XPath();
final Tuple tuple = mock(Tuple.class);
when(tuple.get(0)).thenReturn(
"<book id=\"bk101\">" +
"<author>Gambardella, Matthew</author>" +
"<title>XML Developer's Guide</title>" +
"<genre>Computer</genre>" +
"<price>44.95</price>" +
"<publish_date>2000-10-01</publish_date>" +
"<description>An in-depth look at creating applications with XML.</description>" +
"</book>");
when(tuple.size()).thenReturn(3);
//cache on
when(tuple.get(2)).thenReturn(true);
when(tuple.get(1)).thenReturn("book/author");
assertEquals("Gambardella, Matthew", xpath.exec(tuple));
assertNotEquals("Someone else", xpath.exec(tuple));
when(tuple.get(1)).thenReturn("book/price");
assertEquals("44.95", xpath.exec(tuple));
assertNotEquals("00.00", xpath.exec(tuple));
//cache off
when(tuple.get(2)).thenReturn(false);
when(tuple.get(1)).thenReturn("book/author");
assertEquals("Gambardella, Matthew", xpath.exec(tuple));
assertNotEquals("Someone else", xpath.exec(tuple));
when(tuple.get(1)).thenReturn("book/price");
assertEquals("44.95", xpath.exec(tuple));
assertNotEquals("00.00", xpath.exec(tuple));
}