FileDocCategorySizeDatePackage
AtomUriElementTest.javaAPI DocApache Lucene 2.1.03813Wed Feb 14 10:45:58 GMT 2007org.apache.lucene.gdata.gom.core

AtomUriElementTest

public class AtomUriElementTest extends TestCase
author
Simon Willnauer

Fields Summary
GOMIconImpl
iconImpl
GOMLogoImpl
logoImpl
Constructors Summary
Methods Summary
protected voidsetUp()

		this.iconImpl = new GOMIconImpl();
		this.logoImpl = new GOMLogoImpl();

	
public voidtestConstructor()

		assertEquals(GOMIcon.LOCALNAME, this.iconImpl.getLocalName());
		assertEquals(GOMIcon.LOCALNAME, this.iconImpl.getQname().getLocalPart());
		assertEquals(GOMLogo.LOCALNAME, this.logoImpl.getLocalName());
		assertEquals(GOMLogo.LOCALNAME, this.logoImpl.getQname().getLocalPart());
	
public voidtestProcessEndElement()

		try {
			this.iconImpl.processEndElement();
			fail("no text value");
		} catch (GDataParseException e) {
			assertTrue(e.getMessage().indexOf("requires a element value") > 0);
		}

		try {
			this.iconImpl.setTextValue("test");

			this.iconImpl.processEndElement();
			fail("no text value");
		} catch (GDataParseException e) {
			assertTrue(e.getMessage().indexOf("must be a") > 0);
		}
		try {
			this.iconImpl.setTextValue("/test");

			this.iconImpl.processEndElement();
			fail("no text value");
		} catch (GDataParseException e) {
			assertTrue(e.getMessage().indexOf("must be a") > 0);
		}
		this.iconImpl.xmlBase = "http://www.apache.org";
		this.iconImpl.setTextValue("/test");

		this.iconImpl.processEndElement();

		this.iconImpl.xmlBase = null;
		this.iconImpl.setTextValue("http://www.apache.org/test");

	
public voidtestWriteAtomOutput()

		{
			StringWriter stW = new StringWriter();
			GOMOutputWriter writer = new GOMStaxWriter(stW);
			this.iconImpl.writeAtomOutput(writer);
			assertEquals("<icon/>", stW.toString());
		}
		{
			StringWriter stW = new StringWriter();
			GOMOutputWriter writer = new GOMStaxWriter(stW);
			this.iconImpl.setTextValue("test");
			this.iconImpl.writeAtomOutput(writer);
			assertEquals("<icon>test</icon>", stW.toString());
		}

		{
			StringWriter stW = new StringWriter();
			GOMOutputWriter writer = new GOMStaxWriter(stW);
			this.logoImpl.writeAtomOutput(writer);
			assertEquals("<logo/>", stW.toString());
		}
		{
			StringWriter stW = new StringWriter();
			GOMOutputWriter writer = new GOMStaxWriter(stW);
			this.logoImpl.setTextValue("test");
			this.logoImpl.writeAtomOutput(writer);
			assertEquals("<logo>test</logo>", stW.toString());
		}
	
public voidtestWriteRssOutput()


		{
			StringWriter stW = new StringWriter();
			GOMOutputWriter writer = new GOMStaxWriter(stW);
			this.iconImpl.writeRssOutput(writer);
			assertEquals("<url/>", stW.toString());
		}
		{
			StringWriter stW = new StringWriter();
			GOMOutputWriter writer = new GOMStaxWriter(stW);
			this.iconImpl.setTextValue("test");
			this.iconImpl.writeRssOutput(writer);
			assertEquals("<url>test</url>", stW.toString());
		}

		{
			StringWriter stW = new StringWriter();
			GOMOutputWriter writer = new GOMStaxWriter(stW);
			this.logoImpl.writeRssOutput(writer);
			assertEquals("<url/>", stW.toString());
		}
		{
			StringWriter stW = new StringWriter();
			GOMOutputWriter writer = new GOMStaxWriter(stW);
			this.logoImpl.setTextValue("test");
			this.logoImpl.writeRssOutput(writer);
			assertEquals("<url>test</url>", stW.toString());
		}