type.setSchemaType(new QName("urn:Bean", "bean"));
// Test reading
ElementReader reader = new ElementReader(getResourceAsStream("bean1.xml"));
SimpleBean bean = (SimpleBean)type.readObject(reader, getContext());
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, getContext());
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, getContext());
assertEquals("", bean.getBleh());
assertEquals("howdy", bean.getHowdy());
reader.getXMLStreamReader().close();
bean.setBleh("bleh");
// Test writing
Element element = writeObjectToElement(type, bean, getContext());
assertValid("/b:root/b:bleh[text()='bleh']", element);