GOMContentImplTestpublic class GOMContentImplTest extends TestCase
Fields Summary |
---|
private GOMContentImpl | impl |
Methods Summary |
---|
protected void | setUp()
super.setUp();
this.impl = new GOMContentImpl();
| public void | testGOMContentImpl()
GOMContentImpl impl2 = new GOMContentImpl();
assertEquals(GOMContent.LOCALNAME, impl2.getLocalName());
assertEquals(GOMContent.LOCALNAME, impl2.getQname().getLocalPart());
assertEquals(GOMNamespace.ATOM_NS_URI, impl2.getQname()
.getNamespaceURI());
| public void | testGetChildParser()
try {
this.impl.getChildParser(new QName("test"));
fail("no blob specified");
} catch (GDataParseException e) {
//
}
this.impl.setAtomMediaType(AtomMediaType.XML);
AtomParser childParser = this.impl.getChildParser(new QName("test"));
assertNotNull(childParser);
assertTrue(childParser instanceof XMLBlobContentParser);
| public void | testProcessAttribute()
try {
this.impl.processAttribute(null, "test");
fail("qname is null");
} catch (GDataParseException e) {
//
}
try {
this.impl.processAttribute(new QName("test"), null);
fail("value is null");
} catch (GDataParseException e) {
//
}
this.impl.processAttribute(new QName(GOMNamespace.ATOM_NS_URI, "type"),
"text/xml");
assertSame(AtomMediaType.XML, this.impl.getAtomMediaType());
try {
this.impl.processAttribute(new QName(GOMNamespace.ATOM_NS_URI,
"type"), "text/xml");
fail("duplicated attribute");
} catch (GDataParseException e) {
//
}
this.impl.setAtomMediaType(null);
this.impl.processAttribute(new QName(GOMNamespace.ATOM_NS_URI, "type"),
"text/plain");
assertSame(AtomMediaType.TEXT, this.impl.getAtomMediaType());
this.impl.setAtomMediaType(null);
this.impl.processAttribute(new QName(GOMNamespace.ATOM_NS_URI, "type"),
"image/jpeg");
assertSame(AtomMediaType.BINARY, this.impl.getAtomMediaType());
// test if super is called
this.impl.setAtomMediaType(null);
this.impl.processAttribute(new QName(GOMNamespace.ATOM_NS_URI, "type"),
"xhtml");
assertNull(this.impl.getAtomMediaType());
assertSame(ContentType.XHTML, this.impl.getContentType());
this.impl.processAttribute(new QName(GOMNamespace.ATOM_NS_URI, "src"),
"test");
assertEquals("test", this.impl.getSrc());
try {
this.impl.processAttribute(new QName(GOMNamespace.ATOM_NS_URI,
"src"), "text/xml");
fail("duplicated attribute");
} catch (GDataParseException e) {
//
}
| public void | testProcessElementValue()
assertNull(this.impl.getTextValue());
this.impl.processElementValue("test");
assertEquals("test", this.impl.getTextValue());
this.impl.setSrc("http://www.apache.org");
try {
this.impl.processElementValue("test");
fail("src is set no element value allowed");
} catch (GDataParseException e) {
//
}
| public void | testProcessEndElement()
try {
this.impl.processEndElement();
fail("no type attribute");
} catch (GDataParseException e) {
//
}
this.impl.processAttribute(new QName(GOMNamespace.ATOM_NS_URI, "type"),
"text/plain");
this.impl.processEndElement();
this.impl.setSrc("http://www.apache.org");
this.impl.processEndElement();
this.impl.setSrc("/test");
try {
this.impl.processEndElement();
fail("must be absolut uri");
} catch (GDataParseException e) {
//
}
this.impl.xmlBase = "http://www.apache.org";
this.impl.processEndElement();
| public void | testWriteAtomOutput()
{
StringWriter stW = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(stW);
this.impl.writeAtomOutput(writer);
assertEquals("<content type=\"text\"/>", stW.toString());
}
{
this.impl.processAttribute(new QName(GOMNamespace.ATOM_NS_URI,
"type"), "image/jpeg");
StringWriter stW = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(stW);
this.impl.writeAtomOutput(writer);
assertEquals("<content type=\"image/jpeg\"/>", stW.toString());
}
{
this.impl.setSrc("http://www.apache.org");
this.impl.setTextValue("hello world");
StringWriter stW = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(stW);
this.impl.writeAtomOutput(writer);
assertEquals(
"<content type=\"image/jpeg\" src=\"http://www.apache.org\"/>",
stW.toString());
}
{
this.impl.setSrc(null);
this.impl.setTextValue("hello world");
StringWriter stW = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(stW);
this.impl.writeAtomOutput(writer);
assertEquals("<content type=\"image/jpeg\">hello world</content>",
stW.toString());
}
| public void | testWriteRssOutputGOMOutputWriter()
{
StringWriter stW = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(stW);
this.impl.writeRssOutput(writer);
assertEquals("<description/>", stW.toString());
}
{
this.impl.setSrc("http://www.apache.org");
this.impl.setAtomMediaType(AtomMediaType.TEXT);
StringWriter stW = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(stW);
this.impl.writeRssOutput(writer);
assertEquals("<link>http://www.apache.org</link>", stW.toString());
}
{
this.impl.setSrc(null);
this.impl.setAtomMediaType(AtomMediaType.TEXT);
this.impl.setTextValue("test");
StringWriter stW = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(stW);
this.impl.writeRssOutput(writer);
assertEquals("<description>test</description>", stW.toString());
}
{
this.impl.setAtomMediaType(null);
this.impl.processAttribute(new QName(GOMNamespace.ATOM_NS_URI,
"type"), "image/jpeg");
StringWriter stW = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(stW);
this.impl.writeRssOutput(writer);
assertEquals("<content type=\"image/jpeg\">test</content>", stW
.toString());
}
|
|