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

GOMDateConstructImplTest

public class GOMDateConstructImplTest extends TestCase
author
Simon Willnauer

Fields Summary
private static final String
DATE
private static final String
DATE_RSS
private static final String
DATE1
private GOMUpdatedImpl
updateImpl
private GOMPublishedImpl
publishImpl
Constructors Summary
Methods Summary
protected voidsetUp()


	     
		this.updateImpl = new GOMUpdatedImpl();
		this.publishImpl = new GOMPublishedImpl();
	
public voidtestProcessElementValue()

		try {
			this.updateImpl.processElementValue(null);
			fail("must not be null");
		} catch (IllegalArgumentException e) {
			// 
		}
		try {
			this.updateImpl.processElementValue("not a date");
			fail("illegal string");
		} catch (GDataParseException e) {
			// 
		}

		this.updateImpl.processElementValue(DATE);
		assertNotNull(this.updateImpl.getDate());
		this.updateImpl.processElementValue(DATE1);
		assertNotNull(this.updateImpl.getDate());

	
public voidtestProcessEndElement()

		try {
			this.updateImpl.processEndElement();
			fail("no element value");
		} catch (GDataParseException e) {
			// 
		}
		this.updateImpl.setDate(new Date());
		this.updateImpl.processEndElement();
	
public voidtestWriteAtomOutput()

		{
			StringWriter strWriter = new StringWriter();
			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
			this.updateImpl.writeAtomOutput(writer);
			assertTrue(strWriter.toString().startsWith("<updated>"));
			assertTrue(strWriter.toString().endsWith("</updated>"));
		}
		{
			this.updateImpl.processElementValue(DATE);
			StringWriter strWriter = new StringWriter();
			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
			this.updateImpl.writeAtomOutput(writer);
			assertEquals("<updated>" + DATE + "</updated>", strWriter
					.toString());
		}

		{
			StringWriter strWriter = new StringWriter();
			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
			this.publishImpl.writeAtomOutput(writer);
			assertTrue(strWriter.toString().startsWith("<published>"));
			assertTrue(strWriter.toString().endsWith("</published>"));
		}
		{
			this.publishImpl.processElementValue(DATE);
			StringWriter strWriter = new StringWriter();
			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
			this.publishImpl.writeAtomOutput(writer);
			assertEquals("<published>" + DATE + "</published>", strWriter
					.toString());
		}

	
public voidtestWriteRssOutput()

		{
			StringWriter strWriter = new StringWriter();
			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
			this.updateImpl.writeRssOutput(writer);
			assertTrue(strWriter.toString().startsWith("<atom:updated>"));
			assertTrue(strWriter.toString().endsWith("</atom:updated>"));
		}
		{
			this.updateImpl.processElementValue(DATE);
			StringWriter strWriter = new StringWriter();
			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
			this.updateImpl.writeRssOutput(writer);
			assertEquals("<atom:updated>" + DATE + "</atom:updated>", strWriter
					.toString());
		}

		{
			StringWriter strWriter = new StringWriter();
			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
			this.publishImpl.writeRssOutput(writer);

			assertTrue(strWriter.toString().startsWith("<pubDate>"));
			assertTrue(strWriter.toString().endsWith("</pubDate>"));
		}
		{
			this.publishImpl.processElementValue(DATE);
			StringWriter strWriter = new StringWriter();
			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
			this.publishImpl.writeRssOutput(writer);
			assertEquals("<pubDate>" + DATE_RSS + "</pubDate>", strWriter
					.toString());
		}