GOMGenereatorImplTestpublic class GOMGenereatorImplTest extends TestCase
Fields Summary |
---|
private GOMGeneratorImpl | impl |
Methods Summary |
---|
protected void | setUp()
this.impl = new GOMGeneratorImpl();
| public void | testGOMGeneratorImpl()
this.impl = new GOMGeneratorImpl();
assertEquals(GOMGenerator.LOCALNAME, this.impl.getLocalName());
assertEquals(GOMGenerator.LOCALNAME, this.impl.getQname()
.getLocalPart());
assertEquals(GOMNamespace.ATOM_NS_URI, this.impl.getQname()
.getNamespaceURI());
| public void | testProcessAttribute()
this.impl.processAttribute(new QName(GOMNamespace.ATOM_NS_URI, "uri"),
"test");
assertEquals("test", this.impl.getUri());
try {
this.impl.processAttribute(new QName(GOMNamespace.ATOM_NS_URI,
"uri"), "test");
fail("duplicated");
} catch (GDataParseException e) {
}
this.impl.processAttribute(new QName(GOMNamespace.ATOM_NS_URI,
"version"), "test");
assertEquals("test", this.impl.getGeneratorVersion());
try {
this.impl.processAttribute(new QName(GOMNamespace.ATOM_NS_URI,
"version"), "test");
fail("duplicated");
} catch (GDataParseException e) {
}
// check call to super.processAttribute
this.impl.processAttribute(new QName(GOMNamespace.XML_NS_URI, "base",
GOMNamespace.XML_NS_PREFIX), "test");
assertEquals("test", this.impl.xmlBase);
try {
this.impl.processAttribute(null, "test");
fail("qname is null");
} catch (IllegalArgumentException e) {
//
}
try {
this.impl.processAttribute(new QName(GOMNamespace.XML_NS_URI,
"base", GOMNamespace.XML_NS_PREFIX), null);
fail("value is null");
} catch (IllegalArgumentException e) {
//
}
| public void | testProcessElementValue()
this.impl.processElementValue("myGenerator");
assertEquals("myGenerator", this.impl.getTextValue());
try {
this.impl.processElementValue("testme");
fail("duplicated");
} catch (GDataParseException e) {
//
}
| public void | testProcessEndElement()
this.impl.processEndElement();
{
this.impl.setUri("some invalid uri");
try {
this.impl.processEndElement();
fail("must be an absolute uri");
} catch (GDataParseException e) {
//
}
}
{
this.impl.setUri("/uri");
try {
this.impl.processEndElement();
fail("must be an absolute uri or xml:base must be set");
} catch (GDataParseException e) {
//
}
}
this.impl.xmlBase = "http://apache.org";
this.impl.processEndElement();
this.impl.xmlBase = null;
this.impl.setUri("http://apache.org/uri");
this.impl.processEndElement();
| public void | testWriteAtomOutput()
{
StringWriter stW = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(stW);
this.impl.writeAtomOutput(writer);
assertEquals("<" + this.impl.getLocalName() + "/>", stW.toString());
}
{
StringWriter stW = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(stW);
this.impl.setTextValue("Lucene");
this.impl.writeAtomOutput(writer);
assertEquals("<" + this.impl.getLocalName() + ">Lucene</"
+ this.impl.getLocalName() + ">", stW.toString());
}
{
StringWriter stW = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(stW);
this.impl.setUri("http://apache.org");
this.impl.writeAtomOutput(writer);
assertEquals("<" + this.impl.getLocalName()
+ " uri=\"http://apache.org\">Lucene</"
+ this.impl.getLocalName() + ">", stW.toString());
}
{
StringWriter stW = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(stW);
this.impl.setGeneratorVersion("1");
this.impl.writeAtomOutput(writer);
assertEquals("<" + this.impl.getLocalName()
+ " uri=\"http://apache.org\" version=\"1\">Lucene</"
+ this.impl.getLocalName() + ">", stW.toString());
}
| public void | testWriteRssOutput()
{
StringWriter stW = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(stW);
this.impl.setTextValue("Lucene");
this.impl.writeRssOutput(writer);
assertEquals("<" + this.impl.getLocalName() + ">Lucene</"
+ this.impl.getLocalName() + ">", stW.toString());
}
{
StringWriter stW = new StringWriter();
GOMOutputWriter writer = new GOMStaxWriter(stW);
this.impl.setUri("http://apache.org");
this.impl.setGeneratorVersion("1");
this.impl.writeRssOutput(writer);
assertEquals("<" + this.impl.getLocalName() + ">Lucene</"
+ this.impl.getLocalName() + ">", stW.toString());
}
|
|