Methods Summary |
---|
protected void | setUp()
this.titleImpl = new GOMTitleImpl();
this.subTitleImpl = new GOMSubtitleImpl();
|
public void | testGetChildParser()
try {
this.titleImpl.getChildParser(null);
fail("qname must not be null");
} catch (GDataParseException e) {
//
}
try {
this.titleImpl.getChildParser(new QName("test"));
fail("no such child supported");
} catch (GDataParseException e) {
//
}
try {
this.titleImpl.getChildParser(new QName("div"));
fail("content type not set");
} catch (GDataParseException e) {
//
}
this.titleImpl.contentType = ContentType.XHTML;
AtomParser childParser = this.titleImpl
.getChildParser(new QName("div"));
assertNotNull(childParser);
assertTrue(childParser instanceof XMLBlobContentParser);
try {
this.titleImpl.getChildParser(new QName("div"));
fail("duplicated element");
} catch (GDataParseException e) {
//
}
|
public void | testProcessAttribute()
try {
this.titleImpl.processAttribute(null, "test");
fail("qname is null");
} catch (GDataParseException e) {
//
}
this.titleImpl.processAttribute(new QName("type"), "text");
assertEquals(ContentType.TEXT, this.titleImpl.getContentType());
this.titleImpl.contentType = null;
this.titleImpl.processAttribute(new QName("type"), "html");
assertEquals(ContentType.HTML, this.titleImpl.getContentType());
this.titleImpl.contentType = null;
this.titleImpl.processAttribute(new QName("type"), "xhtml");
assertEquals(ContentType.XHTML, this.titleImpl.getContentType());
|
public void | testProcessElementValue()
this.titleImpl.processElementValue("test");
assertEquals("test", this.titleImpl.getTextValue());
assertNull(this.titleImpl.htmlBuilder);
this.titleImpl.processAttribute(new QName("type"), "html");
assertNotNull(this.titleImpl.htmlBuilder);
this.titleImpl.processElementValue("test");
assertEquals("test", this.titleImpl.getTextValue());
assertEquals("test", this.titleImpl.htmlBuilder.toString());
|
public void | testProcessEndElement()
try {
this.titleImpl.processEndElement();
fail("no content type");
} catch (GDataParseException e) {
//
}
this.titleImpl.contentType = ContentType.TEXT;
this.titleImpl.processEndElement();
|
public void | testWriteAtomOutput()
{
this.titleImpl.contentType = ContentType.TEXT;
StringWriter strWriter = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(strWriter);
this.titleImpl.writeAtomOutput(writer);
assertEquals("<title type=\"text\"/>", strWriter.toString());
}
{
this.titleImpl.setTextValue("><hello world");
StringWriter strWriter = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(strWriter);
this.titleImpl.writeAtomOutput(writer);
assertEquals("<title type=\"text\">><hello world</title>",
strWriter.toString());
}
{
this.titleImpl.contentType = ContentType.HTML;
StringWriter strWriter = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(strWriter);
this.titleImpl.writeAtomOutput(writer);
assertEquals("<title type=\"html\">><hello world</title>",
strWriter.toString());
}
{
this.titleImpl.contentType = ContentType.XHTML;
StringWriter strWriter = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(strWriter);
this.titleImpl.writeAtomOutput(writer);
assertEquals("<title type=\"xhtml\">><hello world</title>",
strWriter.toString());
}
|
public void | testWriteRssOutput()
{
this.titleImpl.contentType = ContentType.TEXT;
StringWriter strWriter = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(strWriter);
this.titleImpl.writeRssOutput(writer);
assertEquals("<title/>", strWriter.toString());
}
{
this.titleImpl.setTextValue("><hello world");
StringWriter strWriter = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(strWriter);
this.titleImpl.writeRssOutput(writer);
assertEquals("<title>><hello world</title>", strWriter
.toString());
}
{
this.titleImpl.contentType = ContentType.HTML;
StringWriter strWriter = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(strWriter);
this.titleImpl.writeRssOutput(writer);
assertEquals("<title>><hello world</title>", strWriter
.toString());
}
{
this.titleImpl.contentType = ContentType.XHTML;
StringWriter strWriter = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(strWriter);
this.titleImpl.writeRssOutput(writer);
// no markup in rss
assertEquals("<title>><hello world</title>", strWriter
.toString());
}
{
this.titleImpl.contentType = ContentType.XHTML;
this.titleImpl.xmlBase = "http://www.apache.org";
this.titleImpl.xmlLang = "en";
StringWriter strWriter = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(strWriter);
this.titleImpl.writeRssOutput(writer);
// no markup in rss
assertEquals(
"<title xml:base=\"http://www.apache.org\" xml:lang=\"en\">><hello world</title>",
strWriter.toString());
}
{
this.subTitleImpl.contentType = ContentType.XHTML;
StringWriter strWriter = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(strWriter);
this.subTitleImpl.writeRssOutput(writer);
assertEquals("<description/>", strWriter.toString());
}
{
this.subTitleImpl.contentType = ContentType.XHTML;
this.subTitleImpl.setTextValue("><hello world");
StringWriter strWriter = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(strWriter);
this.subTitleImpl.writeRssOutput(writer);
assertEquals("<description>><hello world</description>",
strWriter.toString());
}
|