package org.apache.stratum.xo.person;
import java.io.File;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.apache.stratum.xo.Mapper;
public class TestPersonMapper
extends TestCase
{
private static String TEST_DOCUMENT =
"src/test/org/apache/stratum/xo/person/person.xml";
private static String TEST_CLASS =
"org.apache.stratum.xo.person.Person";
public TestPersonMapper(String testName)
{
super(testName);
}
public static Test suite()
{
return new TestSuite(TestPersonMapper.class);
}
public void setUp()
{
}
public void tearDown()
{
}
public void testPersonMapping()
{
try
{
Mapper m = new Mapper();
m.setDebug(true);
Person p = (Person) m.map(new File(TEST_DOCUMENT), TEST_CLASS);
assertEquals("Jason",p.getFirstName());
assertEquals("van Zyl",p.getLastName());
assertEquals("somnambulism",p.getHobby(0));
assertEquals("squash",p.getHobby(1));
// Check child address object.
assertEquals("50 King",p.getAddress().getStreet());
assertEquals("Guelph",p.getAddress().getCity());
assertEquals("Canada",p.getAddress().getCountry());
}
catch (Exception e)
{
e.printStackTrace();
fail(e.getMessage());
}
}
}