Search in sources :

Example 1 with ChildElement

use of org.codice.ddf.parser.xml.domain.ChildElement in project ddf by codice.

the class TestXmlParser method testUnmarshalBadCast.

@Test
public void testUnmarshalBadCast() throws Exception {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    parser.marshal(configurator, mother, os);
    ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
    thrown.expect(ClassCastException.class);
    ChildElement unmarshal = parser.unmarshal(configurator, ChildElement.class, is);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ChildElement(org.codice.ddf.parser.xml.domain.ChildElement) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 2 with ChildElement

use of org.codice.ddf.parser.xml.domain.ChildElement in project ddf by codice.

the class TestXmlParser method setUp.

@Before
public void setUp() throws Exception {
    parser = new XmlParser();
    List<String> ctxPath = ImmutableList.of(MotherElement.class.getPackage().getName());
    configurator = parser.configureParser(ctxPath, TestXmlParser.class.getClassLoader());
    mother = new MotherElement();
    mother.setFirstname("Padme");
    mother.setLastname("Skywalker");
    mother.setAge(25);
    luke = new ChildElement();
    luke.setAge(2);
    luke.setFirstname("Luke");
    luke.setLastname("Skywalker");
    leia = new ChildElement();
    leia.setAge(2);
    leia.setFirstname("Leia");
    leia.setLastname("Organa");
    mother.getChild().add(luke);
    mother.getChild().add(leia);
}
Also used : MotherElement(org.codice.ddf.parser.xml.domain.MotherElement) ChildElement(org.codice.ddf.parser.xml.domain.ChildElement) Before(org.junit.Before)

Aggregations

ChildElement (org.codice.ddf.parser.xml.domain.ChildElement)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 MotherElement (org.codice.ddf.parser.xml.domain.MotherElement)1 Before (org.junit.Before)1 Test (org.junit.Test)1