Methods Summary |
---|
protected void | setUp()
// TODO Auto-generated method stub
super.setUp();
|
public void | testParseAtom()
GOMPersonImpl impl = new GOMPersonImpl();
QName name = new QName(GOMNamespace.ATOM_NS_URI, "name");
AtomParser childParser = impl.getChildParser(name);
String nameValue = "simonw";
{
assertTrue(childParser instanceof GOMPersonImpl.NameParser);
childParser.processElementValue(nameValue);
childParser.processEndElement();
assertEquals(impl.getName(), nameValue);
try {
childParser.processElementValue(nameValue);
childParser.processEndElement();
fail("duplicated element");
} catch (GDataParseException e) {
//
}
}
{
name = new QName(GOMNamespace.ATOM_NS_URI, "uri");
childParser = impl.getChildParser(name);
assertTrue(childParser instanceof GOMPersonImpl.UriParser);
childParser.processElementValue(nameValue);
childParser.processEndElement();
assertEquals(impl.getUri(), nameValue);
try {
childParser.processElementValue(nameValue);
childParser.processEndElement();
fail("duplicated element");
} catch (GDataParseException e) {
//
}
}
{
name = new QName(GOMNamespace.ATOM_NS_URI, "email");
childParser = impl.getChildParser(name);
assertTrue(childParser instanceof GOMPersonImpl.EmailParser);
childParser.processElementValue(nameValue);
childParser.processEndElement();
assertEquals(impl.getEmail(), nameValue);
try {
childParser.processElementValue(nameValue);
childParser.processEndElement();
fail("duplicated element");
} catch (GDataParseException e) {
//
}
}
|
public void | testProcessEndElement()
GOMPersonImpl impl = new GOMPersonImpl();
try {
impl.processEndElement();
fail("name must be set");
} catch (GDataParseException e) {
//
}
|
public void | testWriteAtomOutput()
StringWriter stW = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(stW);
GOMPersonImpl impl = new GOMPersonImpl();
impl.writeRssOutput(writer);
writer.flush();
writer.close();
// test with name
stW = new StringWriter();
writer = new GOMStaxWriter(stW);
impl.setName("test");
impl.writeAtomOutput(writer);
writer.flush();
assertEquals("<person><name>test</name></person>", stW.toString());
writer.close();
// test with name
stW = new StringWriter();
writer = new GOMStaxWriter(stW);
impl.setEmail("simonw@apache.org");
impl.setUri("http://www.apache.org");
impl.writeAtomOutput(writer);
writer.flush();
assertEquals(
"<person><name>test</name><email>simonw@apache.org</email><uri>http://www.apache.org</uri></person>",
stW.toString());
try {
impl.writeAtomOutput(null);
fail("must not be null");
} catch (GDataParseException e) {
//
}
|
public void | testWriteRssOutput()
StringWriter stW = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(stW);
GOMPersonImpl impl = new GOMPersonImpl();
impl.writeRssOutput(writer);
writer.flush();
assertEquals(0, stW.toString().length());
|