1 package org.jaxen.test;
2
3 import java.util.List;
4
5 import junit.framework.TestCase;
6
7 import org.jaxen.JaxenException;
8 import org.jaxen.javabean.JavaBeanXPath;
9 import org.jaxen.saxpath.helpers.XPathReaderFactory;
10
11 public class JavaBeanNavigatorTest
12 extends TestCase
13 {
14
15 protected void setUp() throws Exception
16 {
17 System.setProperty( XPathReaderFactory.DRIVER_PROPERTY,
18 "" );
19 }
20
21 public void testSomething() throws JaxenException {
22
23
24
25
26 JavaBeanXPath xpath = new JavaBeanXPath( "brother[position()<4]/name" );
27
28 Person bob = new Person( "bob", 30 );
29
30 bob.addBrother( new Person( "billy", 34 ) );
31 bob.addBrother( new Person( "seth", 29 ) );
32 bob.addBrother( new Person( "dave", 32 ) );
33 bob.addBrother( new Person( "jim", 29 ) );
34 bob.addBrother( new Person( "larry", 42 ) );
35 bob.addBrother( new Person( "ted", 22 ) );
36
37 List result = (List) xpath.evaluate( bob );
38 assertEquals(3, result.size());
39
40 }
41
42 }