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