type.setSchemaType(new QName("urn:Bean", "bean"));
// Test reading
ElementReader reader = new ElementReader(getResourceAsStream("/org/codehaus/xfire/aegis/type/basic/bean1.xml"));
SimpleBean bean = (SimpleBean) type.readObject(reader, new MessageContext());
assertEquals("bleh", bean.getBleh());
assertEquals("howdy", bean.getHowdy());
reader.getXMLStreamReader().close();
// Test reading with extra elements
reader = new ElementReader(getResourceAsStream("/org/codehaus/xfire/aegis/type/basic/bean2.xml"));
bean = (SimpleBean) type.readObject(reader, new MessageContext());
assertEquals("bleh", bean.getBleh());
assertEquals("howdy", bean.getHowdy());
reader.getXMLStreamReader().close();
// test <bleh/> element
reader = new ElementReader(getResourceAsStream("/org/codehaus/xfire/aegis/type/basic/bean7.xml"));
bean = (SimpleBean) type.readObject(reader, new MessageContext());
assertEquals("", bean.getBleh());
assertEquals("howdy", bean.getHowdy());
reader.getXMLStreamReader().close();
bean.setBleh("bleh");
// Test writing
Element element = new Element("root", "b", "urn:Bean");
Document doc = new Document(element);
type.writeObject(bean, new JDOMWriter(element), new MessageContext());
assertValid("/b:root/b:bleh[text()='bleh']", element);
assertValid("/b:root/b:howdy[text()='howdy']", element);
}