it seems that i misunderstand the usage of the "Container"-interface: why
does the following unit test fail?
thank you very much for any help!
public class XpathUtilTest extends TestCase {
public void testEval2(){
Foo foo = new Foo();
foo.setBar( new Bar() );
JXPathContext ctx = JXPathContext.newContext(foo);
// this test succeeds:
assertEquals(foo.getBar().getValue(),
ctx.getValue("/bar"));
// fails because "/bar[1]" returns whole arraylist:
assertEquals("1", ctx.getValue("/bar[1]"));
// fails because of JXPathException:
// "No value for xpath: /bar[2]"
assertEquals("2", ctx.getValue("/bar[2]"));
}
public class Foo{
private Bar bar;
public Bar getBar() {
return bar;
}
public void setBar(Bar bar){
this.bar = bar;
}
}
public class Bar implements Container{
private List list;
public Bar(){
l = new ArrayList();
l.add("1");l.add("2");l.add("3");
}
public Object getValue() {
return l;
}
public void setValue(Object arg0) { /* not needed */ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]