You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by si...@apache.org on 2006/12/13 13:40:04 UTC

svn commit: r486627 [8/9] - in /lucene/java/trunk/contrib/gdata-server/src/gom: java/org/ java/org/apache/ java/org/apache/lucene/ java/org/apache/lucene/gdata/ java/org/apache/lucene/gdata/gom/ java/org/apache/lucene/gdata/gom/core/ java/org/apache/lu...

Added: lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMAuthorImplTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMAuthorImplTest.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMAuthorImplTest.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMAuthorImplTest.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,84 @@
+package org.apache.lucene.gdata.gom.core;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.io.StringWriter;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.lucene.gdata.gom.GOMAuthor;
+import org.apache.lucene.gdata.gom.writer.GOMStaxWriter;
+import org.apache.lucene.gdata.gom.writer.GOMOutputWriter;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Simon Willnauer
+ * 
+ */
+public class GOMAuthorImplTest extends TestCase {
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMAuthorImpl.writeRssOutput(GOMWriter)'
+	 */
+	public void testWriteRssOutput() throws XMLStreamException {
+		GOMAuthorImpl impl = new GOMAuthorImpl();
+		try {
+			impl.writeRssOutput(null);
+			fail("writer is null");
+		} catch (GDataParseException e) {
+		}
+		StringWriter writer2 = new StringWriter();
+
+		GOMOutputWriter writer = new GOMStaxWriter(writer2);
+		impl.writeRssOutput(writer, "test");
+		writer.flush();
+		writer2.flush();
+
+		assertEquals("<test></test>", writer2.toString());
+		impl.setEmail("simonw@apache.org");
+		impl.setUri("someuri");
+		writer.close();
+
+		writer2 = new StringWriter();
+		writer = new GOMStaxWriter(writer2);
+		impl.writeRssOutput(writer);
+		writer.flush();
+		writer2.flush();
+		assertTrue(writer2.toString().length() > 0);
+
+		assertEquals("<" + GOMAuthor.LOCALNAME + ">" + impl.getEmail() + "</"
+				+ GOMAuthor.LOCALNAME + ">", writer2.toString());
+
+		writer.close();
+
+		impl.setName("simonw");
+		writer2 = new StringWriter();
+		writer = new GOMStaxWriter(writer2);
+		impl.writeRssOutput(writer);
+		writer.flush();
+		writer2.flush();
+		assertTrue(writer2.toString().length() > 0);
+
+		assertEquals("<" + GOMAuthor.LOCALNAME + ">" + impl.getEmail() + "("
+				+ impl.getName() + ")</" + GOMAuthor.LOCALNAME + ">", writer2
+				.toString());
+
+	}
+
+}

Added: lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMCategoryTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMCategoryTest.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMCategoryTest.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMCategoryTest.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,262 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.lucene.gdata.gom.core;
+
+import java.io.StringWriter;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.lucene.gdata.gom.GOMNamespace;
+import org.apache.lucene.gdata.gom.writer.GOMStaxWriter;
+import org.apache.lucene.gdata.gom.writer.GOMOutputWriter;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Simon Willnauer
+ * 
+ */
+public class GOMCategoryTest extends TestCase {
+	private QName qname = new QName(GOMNamespace.ATOM_NS_URI, "testme", "");
+
+	GOMCategoryImpl cat;
+
+	protected void setUp() throws Exception {
+		this.cat = new GOMCategoryImpl();
+	}
+
+	protected void tearDown() throws Exception {
+		super.tearDown();
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMCategoryImpl.writeAtomOutput(GOMWriter)'
+	 */
+	public void testWriteAtomOutput() throws XMLStreamException {
+		try {
+			this.cat.writeAtomOutput(null);
+			fail("wirter is null");
+		} catch (NullPointerException e) {
+			// 
+		}
+		{
+			StringWriter strWriter = new StringWriter();
+			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
+			this.cat.writeAtomOutput(writer);
+			assertEquals("<category term=\"\"/>", strWriter.toString());
+
+		}
+
+		{
+			StringWriter strWriter = new StringWriter();
+			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
+			this.cat.term = "test";
+			this.cat.writeAtomOutput(writer);
+			assertEquals("<category term=\"test\"/>", strWriter.toString());
+
+		}
+
+		{
+			StringWriter strWriter = new StringWriter();
+			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
+			this.cat.label = "python";
+			this.cat.scheme = "monty";
+
+			this.cat.writeAtomOutput(writer);
+			assertEquals(
+					"<category term=\"test\" scheme=\"monty\" label=\"python\"/>",
+					strWriter.toString());
+
+		}
+
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMCategoryImpl.writeRssOutput(GOMWriter)'
+	 */
+	public void testWriteRssOutput() throws XMLStreamException {
+		try {
+			this.cat.writeRssOutput(null);
+			fail("wirter is null");
+		} catch (NullPointerException e) {
+			// 
+		}
+
+		{
+			StringWriter strWriter = new StringWriter();
+			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
+			this.cat.writeRssOutput(writer);
+			assertEquals("<category domain=\"\"/>", strWriter.toString());
+		}
+
+		{
+			StringWriter strWriter = new StringWriter();
+			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
+			this.cat.scheme = "www.apache.org";
+			this.cat.writeRssOutput(writer);
+			assertEquals("<category domain=\"www.apache.org\"/>", strWriter
+					.toString());
+		}
+
+		{
+			StringWriter strWriter = new StringWriter();
+			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
+			this.cat.scheme = "www.apache.org";
+			this.cat.term = "Goo Data";
+			this.cat.writeRssOutput(writer);
+			assertEquals(
+					"<category domain=\"www.apache.org\">Goo Data</category>",
+					strWriter.toString());
+		}
+
+		{
+			StringWriter strWriter = new StringWriter();
+			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
+			this.cat.scheme = "www.apache.org";
+			this.cat.term = "Goo Data";
+			this.cat.label = "ignore";
+			this.cat.writeRssOutput(writer);
+			assertEquals(
+					"<category domain=\"www.apache.org\">Goo Data</category>",
+					strWriter.toString());
+		}
+
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.AbstractGOMElement.processAttribute(QName,
+	 * String)'
+	 */
+	public void testProcessAttribute() {
+		try {
+			this.cat.processAttribute(null, "test");
+			fail("qname is null");
+		} catch (GDataParseException e) {
+			// 
+		}
+		{
+			QName name = new QName("term");
+			this.cat.processAttribute(name, "helloworld");
+			assertEquals("helloworld", this.cat.getTerm());
+
+			try {
+				this.cat.processAttribute(name, "helloworld");
+				fail("duplicated attribute");
+			} catch (GDataParseException e) {
+				// 
+			}
+		}
+
+		{
+			QName name = new QName("scheme");
+			this.cat.processAttribute(name, "helloworld1");
+			assertEquals("helloworld1", this.cat.getScheme());
+
+			try {
+				this.cat.processAttribute(name, "helloworld1");
+				fail("duplicated attribute");
+			} catch (GDataParseException e) {
+				// 
+			}
+		}
+
+		{
+			QName name = new QName("label");
+			this.cat.processAttribute(name, "John Cleese");
+			assertEquals("John Cleese", this.cat.getLabel());
+
+			try {
+				this.cat.processAttribute(name, "John Cleese");
+				fail("duplicated attribute");
+			} catch (GDataParseException e) {
+				// 
+			}
+		}
+
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.AbstractGOMElement.processElementValue(String)'
+	 */
+	public void testProcessElementValue() {
+		try {
+			this.cat.processElementValue(null);
+			fail("element value is null");
+		} catch (GDataParseException e) {
+			// 
+		}
+
+		try {
+			this.cat.processElementValue("and again");
+			fail("can't contain a text value");
+		} catch (GDataParseException e) {
+			//
+			assertNull(this.cat.getTextValue());
+		}
+
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.AbstractGOMElement.processEndElement()'
+	 */
+	public void testProcessEndElement() {
+		try {
+			this.cat.processEndElement();
+			fail("term is not set");
+		} catch (GDataParseException e) {
+			// 
+		}
+		this.cat.setTerm("my Term");
+		this.cat.processEndElement();
+		this.cat.setScheme("test");
+
+		try {
+			this.cat.processEndElement();
+			fail("scheme is not a absoulte uri");
+		} catch (GDataParseException e) {
+			// 
+		}
+
+		this.cat.setScheme("/test");
+
+		try {
+			this.cat.processEndElement();
+			fail("scheme is not a absoulte uri and no xmlbase is set");
+		} catch (GDataParseException e) {
+			// 
+		}
+		{
+			this.cat.xmlBase = "http://www.apache.org";
+			this.cat.processEndElement();
+		}
+
+		{
+			this.cat.xmlBase = null;
+			this.cat.setScheme("http://www.apache.org/test");
+			this.cat.processEndElement();
+		}
+
+	}
+
+}

Added: lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMContentImplTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMContentImplTest.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMContentImplTest.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMContentImplTest.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,275 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.lucene.gdata.gom.core;
+
+import java.io.StringWriter;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.lucene.gdata.gom.AtomMediaType;
+import org.apache.lucene.gdata.gom.ContentType;
+import org.apache.lucene.gdata.gom.GOMContent;
+import org.apache.lucene.gdata.gom.GOMNamespace;
+import org.apache.lucene.gdata.gom.core.GOMTextContructImpl.XMLBlobContentParser;
+import org.apache.lucene.gdata.gom.writer.GOMOutputWriter;
+import org.apache.lucene.gdata.gom.writer.GOMStaxWriter;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Simon Willnauer
+ * 
+ */
+public class GOMContentImplTest extends TestCase {
+
+	private GOMContentImpl impl;
+
+	protected void setUp() throws Exception {
+		super.setUp();
+		this.impl = new GOMContentImpl();
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMContentImpl.getChildParser(QName)'
+	 */
+	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);
+
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMContentImpl.processAttribute(QName,
+	 * String)'
+	 */
+	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) {
+			// 
+		}
+
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMContentImpl.processElementValue(String)'
+	 */
+	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) {
+			// 
+		}
+
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMContentImpl.processEndElement()'
+	 */
+	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();
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMContentImpl.writeAtomOutput(GOMOutputWriter)'
+	 */
+	public void testWriteAtomOutput() throws XMLStreamException,
+			FactoryConfigurationError {
+		{
+			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());
+		}
+
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMContentImpl.writeRssOutput(GOMOutputWriter)'
+	 */
+	public void testWriteRssOutputGOMOutputWriter() throws XMLStreamException {
+		{
+			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());
+		}
+
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMContentImpl.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());
+
+	}
+
+}

Added: lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMDateConstructImplTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMDateConstructImplTest.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMDateConstructImplTest.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMDateConstructImplTest.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,171 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.gdata.gom.core;
+
+import java.io.StringWriter;
+import java.util.Date;
+
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLStreamException;
+
+import junit.framework.TestCase;
+
+import org.apache.lucene.gdata.gom.writer.GOMStaxWriter;
+import org.apache.lucene.gdata.gom.writer.GOMOutputWriter;
+
+/**
+ * @author Simon Willnauer
+ * 
+ */
+public class GOMDateConstructImplTest extends TestCase {
+	private static final String DATE = "2003-12-13T18:30:02+02:00";
+
+	private static final String DATE_RSS = "Sat, 13 Dec 2003 16:30:02 +0000";
+
+	private static final String DATE1 = "2003-12-13T18:30:02.25Z";
+
+	private GOMUpdatedImpl updateImpl;
+
+	private GOMPublishedImpl publishImpl;
+
+	protected void setUp() throws Exception {
+		this.updateImpl = new GOMUpdatedImpl();
+		this.publishImpl = new GOMPublishedImpl();
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMDateConstructImpl.processElementValue(String)'
+	 */
+	public void testProcessElementValue() {
+		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());
+
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMDateConstructImpl.processEndElement()'
+	 */
+	public void testProcessEndElement() {
+		try {
+			this.updateImpl.processEndElement();
+			fail("no element value");
+		} catch (GDataParseException e) {
+			// 
+		}
+		this.updateImpl.setDate(new Date());
+		this.updateImpl.processEndElement();
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMDateConstructImpl.writeAtomOutput(GOMWriter)'
+	 */
+	public void testWriteAtomOutput() throws XMLStreamException,
+			FactoryConfigurationError {
+		{
+			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());
+		}
+
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMDateConstructImpl.writeRssOutput(GOMWriter)'
+	 */
+	public void testWriteRssOutput() throws XMLStreamException,
+			FactoryConfigurationError {
+		{
+			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());
+		}
+
+	}
+
+}

Added: lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMDocumentImplTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMDocumentImplTest.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMDocumentImplTest.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMDocumentImplTest.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,107 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.lucene.gdata.gom.core;
+
+import java.io.StringWriter;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.lucene.gdata.gom.writer.GOMStaxWriter;
+import org.apache.lucene.gdata.gom.writer.GOMOutputWriter;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Simon Willnauer
+ * 
+ */
+public class GOMDocumentImplTest extends TestCase {
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMDocumentImpl.writeAtomOutput(GOMWriter)'
+	 */
+	public void testWriteAtomOutput() throws XMLStreamException,
+			FactoryConfigurationError {
+		GOMDocumentImpl<ArbitraryGOMXml> impl = new GOMDocumentImpl<ArbitraryGOMXml>();
+		impl.setRootElement(new ArbitraryGOMXml(new QName("test")));
+		{
+			StringWriter strWriter = new StringWriter();
+			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
+			impl.writeAtomOutput(writer);
+			assertEquals("<?xml version='1.0' encoding='UTF-8'?><test/>",
+					strWriter.toString());
+		}
+		impl.setRootElement(null);
+		{
+			StringWriter strWriter = new StringWriter();
+			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
+			impl.writeAtomOutput(writer);
+			assertEquals("<?xml version='1.0' encoding='UTF-8'?>", strWriter
+					.toString());
+		}
+
+		impl.setVersion("2.0");
+		impl.setCharacterEncoding("ISO-8859-1");
+		{
+			StringWriter strWriter = new StringWriter();
+			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
+			impl.writeAtomOutput(writer);
+			assertEquals("<?xml version='2.0' encoding='ISO-8859-1'?>",
+					strWriter.toString());
+		}
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMDocumentImpl.writeRssOutput(GOMWriter)'
+	 */
+	public void testWriteRssOutput() throws XMLStreamException,
+			FactoryConfigurationError {
+		GOMDocumentImpl<ArbitraryGOMXml> impl = new GOMDocumentImpl<ArbitraryGOMXml>();
+		impl.setRootElement(new ArbitraryGOMXml(new QName("test")));
+		{
+			StringWriter strWriter = new StringWriter();
+			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
+			impl.writeRssOutput(writer);
+			assertEquals("<?xml version='1.0' encoding='UTF-8'?><test/>",
+					strWriter.toString());
+		}
+		impl.setRootElement(null);
+		{
+			StringWriter strWriter = new StringWriter();
+			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
+			impl.writeRssOutput(writer);
+			assertEquals("<?xml version='1.0' encoding='UTF-8'?>", strWriter
+					.toString());
+		}
+
+		impl.setVersion("2.0");
+		impl.setCharacterEncoding("ISO-8859-1");
+		{
+			StringWriter strWriter = new StringWriter();
+			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
+			impl.writeRssOutput(writer);
+			assertEquals("<?xml version='2.0' encoding='ISO-8859-1'?>",
+					strWriter.toString());
+		}
+	}
+
+}

Added: lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMEntryImplTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMEntryImplTest.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMEntryImplTest.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMEntryImplTest.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,526 @@
+package org.apache.lucene.gdata.gom.core;
+
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.lucene.gdata.gom.AtomMediaType;
+import org.apache.lucene.gdata.gom.GOMAuthor;
+import org.apache.lucene.gdata.gom.GOMCategory;
+import org.apache.lucene.gdata.gom.GOMContent;
+import org.apache.lucene.gdata.gom.GOMContributor;
+import org.apache.lucene.gdata.gom.GOMEntry;
+import org.apache.lucene.gdata.gom.GOMExtension;
+import org.apache.lucene.gdata.gom.GOMGenerator;
+import org.apache.lucene.gdata.gom.GOMIcon;
+import org.apache.lucene.gdata.gom.GOMId;
+import org.apache.lucene.gdata.gom.GOMLink;
+import org.apache.lucene.gdata.gom.GOMLogo;
+import org.apache.lucene.gdata.gom.GOMNamespace;
+import org.apache.lucene.gdata.gom.GOMPublished;
+import org.apache.lucene.gdata.gom.GOMRights;
+import org.apache.lucene.gdata.gom.GOMSource;
+import org.apache.lucene.gdata.gom.GOMSubtitle;
+import org.apache.lucene.gdata.gom.GOMSummary;
+import org.apache.lucene.gdata.gom.GOMTitle;
+import org.apache.lucene.gdata.gom.GOMUpdated;
+import org.apache.lucene.gdata.gom.core.GOMFeedImplTest.TestExtendsionFactory;
+import org.apache.lucene.gdata.gom.core.GOMFeedImplTest.TestExtension;
+import org.apache.lucene.gdata.gom.writer.GOMOutputWriter;
+import org.apache.lucene.gdata.gom.writer.GOMStaxWriter;
+
+import junit.framework.TestCase;
+
+public class GOMEntryImplTest extends TestCase {
+	private static final String TEST_LOCAL_NAME = GOMFeedImplTest.TEST_LOCAL_NAME;
+
+	private GOMEntryImpl impl;
+
+	protected void setUp() throws Exception {
+		super.setUp();
+		this.impl = new GOMEntryImpl();
+	}
+
+	public void testSetNamespace() {
+		assertEquals(0, this.impl.getNamespaces().size());
+		assertNotNull(this.impl.getDefaultNamespace());
+		this.impl.addNamespace(GOMNamespace.ATOM_NAMESPACE);
+		assertSame(GOMNamespace.ATOM_NAMESPACE, this.impl.getDefaultNamespace());
+		this.impl.addNamespace(GOMNamespace.OPENSEARCH_NAMESPACE);
+		assertEquals(1, this.impl.getNamespaces().size());
+		assertSame(GOMNamespace.OPENSEARCH_NAMESPACE, this.impl.getNamespaces()
+				.get(0));
+
+		// detect defaul ns
+		this.impl.addNamespace(new GOMNamespace(GOMNamespace.ATOM_NS_URI, ""));
+		assertEquals(1, this.impl.getNamespaces().size());
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMEntryImpl.getChildParser(QName)'
+	 */
+	public void testGetChildParser() {
+		{
+			// atomAuthor*
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.ATOM_NS_URI, "author"));
+			assertNotNull(parser);
+			assertTrue(parser instanceof GOMAuthor);
+			assertEquals(1, this.impl.getAuthors().size());
+			this.impl.getChildParser(new QName(GOMNamespace.ATOM_NS_URI,
+					"author"));
+			assertEquals(2, this.impl.getAuthors().size());
+		}
+
+		{
+			// atomCategory*
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.ATOM_NS_URI, "category"));
+			assertNotNull(parser);
+			assertTrue(parser instanceof GOMCategory);
+			assertEquals(1, this.impl.getCategories().size());
+			this.impl.getChildParser(new QName(GOMNamespace.ATOM_NS_URI,
+					"category"));
+			assertEquals(2, this.impl.getCategories().size());
+		}
+
+		{
+			// atomContributor*
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.ATOM_NS_URI, "contributor"));
+			assertNotNull(parser);
+			assertTrue(parser instanceof GOMContributor);
+			assertEquals(1, this.impl.getContributor().size());
+			this.impl.getChildParser(new QName(GOMNamespace.ATOM_NS_URI,
+					"contributor"));
+			assertEquals(2, this.impl.getContributor().size());
+		}
+
+		{
+			// atomId
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.ATOM_NS_URI, "id"));
+			assertNotNull(parser);
+			assertTrue(parser instanceof GOMId);
+			assertSame(parser, this.impl.getId());
+			try {
+				this.impl.getChildParser(new QName(GOMNamespace.ATOM_NS_URI,
+						"id"));
+				fail("exactly one time ");
+			} catch (GDataParseException e) {
+				// 
+			}
+
+		}
+
+		{
+			// atomLink*
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.ATOM_NS_URI, "link"));
+			assertNotNull(parser);
+			assertTrue(parser instanceof GOMLink);
+			assertEquals(1, this.impl.getLinks().size());
+			this.impl
+					.getChildParser(new QName(GOMNamespace.ATOM_NS_URI, "link"));
+			assertEquals(2, this.impl.getLinks().size());
+
+		}
+
+		{
+			// atomRights?
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.ATOM_NS_URI, "rights"));
+			assertNotNull(parser);
+			assertTrue(parser instanceof GOMRights);
+			assertSame(parser, this.impl.getRights());
+			try {
+				this.impl.getChildParser(new QName(GOMNamespace.ATOM_NS_URI,
+						"rights"));
+				fail("zero or one");
+			} catch (GDataParseException e) {
+				// 
+			}
+
+		}
+
+		{
+			// atomTitle
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.ATOM_NS_URI, "title"));
+			assertNotNull(parser);
+			assertTrue(parser instanceof GOMTitle);
+			assertSame(parser, this.impl.getTitle());
+			try {
+				this.impl.getChildParser(new QName(GOMNamespace.ATOM_NS_URI,
+						"title"));
+				fail("exactly one time ");
+			} catch (GDataParseException e) {
+				// 
+			}
+
+		}
+
+		{
+			// atomUpdated
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.ATOM_NS_URI, "updated"));
+			assertNotNull(parser);
+			assertTrue(parser instanceof GOMUpdated);
+			assertSame(parser, this.impl.getUpdated());
+			try {
+				this.impl.getChildParser(new QName(GOMNamespace.ATOM_NS_URI,
+						"updated"));
+				fail("exactly one time ");
+			} catch (GDataParseException e) {
+				// 
+			}
+
+		}
+
+		{
+			// atomSource?
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.ATOM_NS_URI, "source"));
+			assertNotNull(parser);
+			assertTrue(parser instanceof GOMSource);
+			assertEquals(parser, this.impl.getSource());
+			try {
+				this.impl.getChildParser(new QName(GOMNamespace.ATOM_NS_URI,
+						"source"));
+				fail("duplicated element");
+			} catch (GDataParseException e) {
+				//
+			}
+
+		}
+
+		{
+			// atomSummary?
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.ATOM_NS_URI, "summary"));
+			assertNotNull(parser);
+			assertTrue(parser instanceof GOMSummary);
+			assertEquals(parser, this.impl.getSummary());
+			try {
+				this.impl.getChildParser(new QName(GOMNamespace.ATOM_NS_URI,
+						"summary"));
+				fail("duplicated element");
+			} catch (GDataParseException e) {
+				//
+			}
+
+		}
+
+		{
+			// atomContent?
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.ATOM_NS_URI, "content"));
+			assertNotNull(parser);
+			assertTrue(parser instanceof GOMContent);
+			assertEquals(parser, this.impl.getContent());
+			try {
+				this.impl.getChildParser(new QName(GOMNamespace.ATOM_NS_URI,
+						"content"));
+				fail("duplicated element");
+			} catch (GDataParseException e) {
+				//
+			}
+
+		}
+
+		{
+			// atomContent?
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.ATOM_NS_URI, "published"));
+			assertNotNull(parser);
+			assertTrue(parser instanceof GOMPublished);
+			assertEquals(parser, this.impl.getPublished());
+			try {
+				this.impl.getChildParser(new QName(GOMNamespace.ATOM_NS_URI,
+						"published"));
+				fail("duplicated element");
+			} catch (GDataParseException e) {
+				//
+			}
+
+		}
+
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMEntryImpl.processEndElement()'
+	 */
+	public void testProcessEndElement() {
+		try {
+			this.impl.processEndElement();
+			fail("missing elements");
+		} catch (GDataParseException e) {
+			// 
+		}
+
+		// atom:entry elements MUST contain exactly one atom:id element.
+		this.impl.setId(new GOMIdImpl());
+		/*
+		 * atom:entry elements that contain no child atom:content element MUST
+		 * contain at least one atom:link element with a rel attribute value of
+		 * "alternate".
+		 */
+		GOMLink link = new GOMLinkImpl();
+		link.setRel("alternate");
+		this.impl.addLink(link);
+		/*
+		 * atom:entry elements MUST contain exactly one atom:title element.
+		 */
+		this.impl.setTitle(new GOMTitleImpl());
+		/*
+		 * atom:entry elements MUST contain exactly one atom:updated element.
+		 */
+		this.impl.setUpdated(new GOMUpdatedImpl());
+
+		{
+			this.impl.setId(null);
+			try {
+				this.impl.processEndElement();
+				fail("id is missing");
+			} catch (GDataParseException e) {
+				// 
+			}
+			this.impl.setId(new GOMIdImpl());
+		}
+
+		{
+			this.impl.getLinks().clear();
+			try {
+				this.impl.processEndElement();
+				fail("link alternate is missing");
+			} catch (GDataParseException e) {
+				// 
+			}
+			this.impl.setContent(new GOMContentImpl());
+			this.impl.processEndElement();
+			this.impl.setContent(null);
+			this.impl.addLink(link);
+		}
+
+		{
+			this.impl.setTitle(null);
+			try {
+				this.impl.processEndElement();
+				fail("title is missing");
+			} catch (GDataParseException e) {
+				// 
+			}
+			this.impl.setTitle(new GOMTitleImpl());
+		}
+		{
+			this.impl.setUpdated(null);
+			try {
+				this.impl.processEndElement();
+				fail("Updated is missing");
+			} catch (GDataParseException e) {
+				// 
+			}
+			this.impl.setUpdated(new GOMUpdatedImpl());
+		}
+
+		/*
+		 * atom:entry elements MUST NOT contain more than one atom:link element
+		 * with a rel attribute value of "alternate" that has the same
+		 * combination of type and hreflang attribute values.
+		 */
+		link.setType("test");
+		link.setHrefLang("http://www.apache.org");
+		this.impl.addLink(link);
+		try {
+			this.impl.processEndElement();
+			fail("doulbe alternate link with same type and hreflang");
+
+		} catch (GDataParseException e) {
+			// 
+		}
+		this.impl.getLinks().remove(0);
+		/*
+		 * # atom:entry elements MUST contain an atom:summary element in either
+		 * of the following cases:
+		 * 
+		 * the atom:entry contains an atom:content that has a "src" attribute
+		 * (and is thus empty). the atom:entry contains content that is encoded
+		 * in Base64; i.e., the "type" attribute of atom:content is a MIME media
+		 * type [MIMEREG], but is not an XML media type [RFC3023], does not
+		 * begin with "text/", and does not end with "/xml" or "+xml".
+		 * 
+		 * 
+		 */
+		GOMContent c = new GOMContentImpl();
+		c.setSrc("");
+		this.impl.setContent(c);
+		try {
+			this.impl.processEndElement();
+			fail("no summary");
+		} catch (GDataParseException e) {
+			// 
+		}
+		c.setSrc(null);
+		c.setAtomMediaType(AtomMediaType.BINARY);
+		try {
+			this.impl.processEndElement();
+			fail("no summary");
+		} catch (GDataParseException e) {
+			// 
+		}
+
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMEntryImpl.GOMEntryImpl()'
+	 */
+	public void testGOMEntryImpl() {
+		GOMEntryImpl impl2 = new GOMEntryImpl();
+		assertNotNull(impl2.getQname());
+		assertEquals(GOMEntry.LOCALNAME, impl.getQname().getLocalPart());
+		assertEquals(GOMEntry.LOCALNAME, this.impl.getLocalName());
+		assertEquals(GOMNamespace.ATOM_NS_URI, impl.getQname()
+				.getNamespaceURI());
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMEntryImpl.writeAtomOutput(GOMOutputWriter)'
+	 */
+	public void testWriteAtomOutput() throws XMLStreamException,
+			FactoryConfigurationError {
+		// write a whole feed and check if all elements are written
+		this.impl.addAuthor(new GOMAuthorImpl());
+		this.impl.addCategory(new GOMCategoryImpl());
+		this.impl.addContributor(new GOMContributorImpl());
+		this.impl.addLink(new GOMLinkImpl());
+		this.impl.setContent(new GOMContentImpl());
+		this.impl.setId(new GOMIdImpl());
+		this.impl.setRights(new GOMRightsImpl());
+		this.impl.setSummary(new GOMSummaryImpl());
+		this.impl.setTitle(new GOMTitleImpl());
+		this.impl.setUpdated(new GOMUpdatedImpl());
+		this.impl.setSource(new GOMSourceImpl());
+		this.impl.setPublished(new GOMPublishedImpl());
+		this.impl.extensions.add(new GOMFeedImplTest.TestExtension());
+		StringWriter stW = new StringWriter();
+		GOMOutputWriter writer = new GOMStaxWriter(stW);
+		this.impl.writeAtomOutput(writer);
+		String string = stW.toString();
+		assertTrue(string.contains("xmlns=\"http://www.w3.org/2005/Atom\""));
+		assertTrue(string.startsWith("<" + GOMEntry.LOCALNAME));
+		assertTrue(string.contains("<" + GOMAuthor.LOCALNAME));
+		assertTrue(string.contains("<" + GOMCategory.LOCALNAME));
+		assertTrue(string.contains("<" + GOMContributor.LOCALNAME));
+		assertTrue(string.contains("<" + GOMLink.LOCALNAME));
+		assertTrue(string.contains("<" + GOMId.LOCALNAME));
+		assertTrue(string.contains("<" + GOMRights.LOCALNAME));
+		assertTrue(string.contains("<" + GOMSummary.LOCALNAME));
+		assertTrue(string.contains("<" + GOMContent.LOCALNAME));
+		assertTrue(string.contains("<" + GOMTitle.LOCALNAME));
+		assertTrue(string.contains("<" + GOMUpdated.LOCALNAME));
+		assertTrue(string.contains("<" + GOMSource.LOCALNAME));
+		assertTrue(string.contains("<" + GOMPublished.LOCALNAME));
+		assertTrue(string.contains("<test"));
+		assertTrue(string.endsWith("</entry>"));
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMEntryImpl.writeRssOutput(GOMOutputWriter)'
+	 */
+	public void testWriteRssOutputGOMOutputWriter() throws XMLStreamException,
+			FactoryConfigurationError {
+		// write a whole feed and check if all elements are written
+		this.impl.addAuthor(new GOMAuthorImpl());
+		this.impl.addCategory(new GOMCategoryImpl());
+		this.impl.addContributor(new GOMContributorImpl());
+		GOMLink link = new GOMLinkImpl();
+		link.setRel("enclosure");
+		link.setHref("test");
+		link.setType("testType");
+		this.impl.addLink(link);
+		this.impl.setContent(new GOMContentImpl());
+		this.impl.setId(new GOMIdImpl());
+		this.impl.setRights(new GOMRightsImpl());
+		GOMSummaryImpl summ = new GOMSummaryImpl();
+		summ.xmlLang = "de";
+		this.impl.setSummary(summ);
+		this.impl.setTitle(new GOMTitleImpl());
+		this.impl.setUpdated(new GOMUpdatedImpl());
+		this.impl.setSource(new GOMSourceImpl());
+		this.impl.setPublished(new GOMPublishedImpl());
+		this.impl.extensions.add(new GOMFeedImplTest.TestExtension());
+		StringWriter stW = new StringWriter();
+		GOMOutputWriter writer = new GOMStaxWriter(stW);
+		this.impl.writeRssOutput(writer);
+		String string = stW.toString();
+		assertTrue(string
+				.contains("xmlns:atom=\"http://www.w3.org/2005/Atom\""));
+		assertTrue(string.startsWith("<" + GOMEntry.LOCALNAME_RSS));
+		assertTrue(string.contains("<" + GOMId.LOCALNAME_RSS));
+		assertTrue(string.contains("<pubDate"));
+		assertTrue(string.contains("<atom:" + GOMUpdated.LOCALNAME));
+		assertTrue(string.contains("<" + GOMId.LOCALNAME_RSS));
+		assertTrue(string.contains("<language"));
+		assertTrue(string.contains("<category domain=\""));
+		assertTrue(string.contains("<title"));
+		assertTrue(string.contains("<atom:summary"));
+		assertTrue(string.contains("<description"));
+		// a link element
+		assertTrue(string.contains("<enclosure"));
+		assertTrue(string.contains("<author"));
+		assertTrue(string.contains("<atom:test"));
+		assertTrue(string.endsWith("</item>"));
+
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMEntryImpl.getExtensions()'
+	 */
+	public void testGetExtensions() {
+
+		{
+			List<GOMExtension> extensions = this.impl.getExtensions();
+			assertNotNull(extensions);
+			assertEquals(0, extensions.size());
+		}
+		QName name = new QName(TEST_LOCAL_NAME);
+		this.impl.setExtensionFactory(new TestExtendsionFactory());
+
+		AtomParser childParser = this.impl.getChildParser(name);
+		assertTrue(childParser instanceof TestExtension);
+		List<GOMExtension> extensions = this.impl.getExtensions();
+		assertNotNull(extensions);
+		assertEquals(1, extensions.size());
+		assertSame(childParser, extensions.get(0));
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMEntryImpl.setExtensionFactory(GOMExtensionFactory)'
+	 */
+	public void testSetExtensionFactory() {
+		QName name = new QName(TEST_LOCAL_NAME);
+		try {
+			this.impl.getChildParser(name);
+			fail("no child hander for this qname");
+		} catch (GDataParseException e) {
+			// 
+		}
+
+		this.impl.setExtensionFactory(new TestExtendsionFactory());
+
+		AtomParser childParser = this.impl.getChildParser(name);
+		assertTrue(childParser instanceof TestExtension);
+
+	}
+
+}

Added: lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMFeedImplTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMFeedImplTest.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMFeedImplTest.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMFeedImplTest.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,688 @@
+package org.apache.lucene.gdata.gom.core;
+
+import java.io.StringWriter;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.lucene.gdata.gom.GOMAuthor;
+import org.apache.lucene.gdata.gom.GOMCategory;
+import org.apache.lucene.gdata.gom.GOMContributor;
+import org.apache.lucene.gdata.gom.GOMElement;
+import org.apache.lucene.gdata.gom.GOMEntry;
+import org.apache.lucene.gdata.gom.GOMExtension;
+import org.apache.lucene.gdata.gom.GOMFeed;
+import org.apache.lucene.gdata.gom.GOMGenerator;
+import org.apache.lucene.gdata.gom.GOMIcon;
+import org.apache.lucene.gdata.gom.GOMId;
+import org.apache.lucene.gdata.gom.GOMLink;
+import org.apache.lucene.gdata.gom.GOMLogo;
+import org.apache.lucene.gdata.gom.GOMNamespace;
+import org.apache.lucene.gdata.gom.GOMRights;
+import org.apache.lucene.gdata.gom.GOMSubtitle;
+import org.apache.lucene.gdata.gom.GOMTitle;
+import org.apache.lucene.gdata.gom.GOMUpdated;
+import org.apache.lucene.gdata.gom.core.extension.GOMExtensionFactory;
+import org.apache.lucene.gdata.gom.writer.GOMStaxWriter;
+import org.apache.lucene.gdata.gom.writer.GOMOutputWriter;
+
+import junit.framework.TestCase;
+
+public class GOMFeedImplTest extends TestCase {
+	static final String TEST_LOCAL_NAME = "testelement";
+
+	GOMFeedImpl impl;
+
+	protected void setUp() throws Exception {
+		this.impl = new GOMFeedImpl();
+	}
+
+	public void testSetNamespace() {
+		assertEquals(0, this.impl.getNamespaces().size());
+		assertNotNull(this.impl.getDefaultNamespace());
+		this.impl.addNamespace(GOMNamespace.ATOM_NAMESPACE);
+		assertSame(GOMNamespace.ATOM_NAMESPACE, this.impl.getDefaultNamespace());
+		this.impl.addNamespace(GOMNamespace.OPENSEARCH_NAMESPACE);
+		assertEquals(1, this.impl.getNamespaces().size());
+		assertSame(GOMNamespace.OPENSEARCH_NAMESPACE, this.impl.getNamespaces()
+				.get(0));
+
+		// detect defaul ns
+		this.impl.addNamespace(new GOMNamespace(GOMNamespace.ATOM_NS_URI, ""));
+		assertEquals(1, this.impl.getNamespaces().size());
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMFeedImpl.getChildParser(QName)'
+	 */
+	public void testGetChildParser() {
+
+		{
+			// atomAuthor*
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.ATOM_NS_URI, "author"));
+			assertNotNull(parser);
+			assertTrue(parser instanceof GOMAuthor);
+			assertEquals(1, this.impl.getAuthors().size());
+			this.impl.getChildParser(new QName(GOMNamespace.ATOM_NS_URI,
+					"author"));
+			assertEquals(2, this.impl.getAuthors().size());
+		}
+
+		{
+			// atomCategory*
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.ATOM_NS_URI, "category"));
+			assertNotNull(parser);
+			assertTrue(parser instanceof GOMCategory);
+			assertEquals(1, this.impl.getCategories().size());
+			this.impl.getChildParser(new QName(GOMNamespace.ATOM_NS_URI,
+					"category"));
+			assertEquals(2, this.impl.getCategories().size());
+		}
+
+		{
+			// atomContributor*
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.ATOM_NS_URI, "contributor"));
+			assertNotNull(parser);
+			assertTrue(parser instanceof GOMContributor);
+			assertEquals(1, this.impl.getContributor().size());
+			this.impl.getChildParser(new QName(GOMNamespace.ATOM_NS_URI,
+					"contributor"));
+			assertEquals(2, this.impl.getContributor().size());
+		}
+		{
+			// atomGenerator?
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.ATOM_NS_URI, "generator"));
+			assertNotNull(parser);
+			assertTrue(parser instanceof GOMGenerator);
+			assertSame(parser, this.impl.getGenerator());
+			try {
+				this.impl.getChildParser(new QName(GOMNamespace.ATOM_NS_URI,
+						"generator"));
+				fail("one or zero");
+			} catch (GDataParseException e) {
+				// 
+			}
+		}
+
+		{
+			// atomIcon?
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.ATOM_NS_URI, "icon"));
+			assertNotNull(parser);
+			assertTrue(parser instanceof GOMIcon);
+			assertSame(parser, this.impl.getIcon());
+			try {
+				this.impl.getChildParser(new QName(GOMNamespace.ATOM_NS_URI,
+						"icon"));
+				fail("one or zero");
+			} catch (GDataParseException e) {
+				// 
+			}
+
+		}
+
+		{
+			// atomId
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.ATOM_NS_URI, "id"));
+			assertNotNull(parser);
+			assertTrue(parser instanceof GOMId);
+			assertSame(parser, this.impl.getId());
+			try {
+				this.impl.getChildParser(new QName(GOMNamespace.ATOM_NS_URI,
+						"id"));
+				fail("exactly one time ");
+			} catch (GDataParseException e) {
+				// 
+			}
+
+		}
+
+		{
+			// atomLink*
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.ATOM_NS_URI, "link"));
+			assertNotNull(parser);
+			assertTrue(parser instanceof GOMLink);
+			assertEquals(1, this.impl.getLinks().size());
+			this.impl
+					.getChildParser(new QName(GOMNamespace.ATOM_NS_URI, "link"));
+			assertEquals(2, this.impl.getLinks().size());
+
+		}
+
+		{
+			// atomLogo?
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.ATOM_NS_URI, "logo"));
+			assertNotNull(parser);
+			assertTrue(parser instanceof GOMLogo);
+			assertSame(parser, this.impl.getLogo());
+			try {
+				this.impl.getChildParser(new QName(GOMNamespace.ATOM_NS_URI,
+						"logo"));
+				fail("zero or one");
+			} catch (GDataParseException e) {
+				// 
+			}
+
+		}
+
+		{
+			// atomRights?
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.ATOM_NS_URI, "rights"));
+			assertNotNull(parser);
+			assertTrue(parser instanceof GOMRights);
+			assertSame(parser, this.impl.getRights());
+			try {
+				this.impl.getChildParser(new QName(GOMNamespace.ATOM_NS_URI,
+						"rights"));
+				fail("zero or one");
+			} catch (GDataParseException e) {
+				// 
+			}
+
+		}
+
+		{
+			// atomSubtitle?
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.ATOM_NS_URI, "subtitle"));
+			assertNotNull(parser);
+			assertTrue(parser instanceof GOMSubtitle);
+			assertSame(parser, this.impl.getSubtitle());
+			try {
+				this.impl.getChildParser(new QName(GOMNamespace.ATOM_NS_URI,
+						"subtitle"));
+				fail("zero or one");
+			} catch (GDataParseException e) {
+				// 
+			}
+
+		}
+
+		{
+			// atomTitle
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.ATOM_NS_URI, "title"));
+			assertNotNull(parser);
+			assertTrue(parser instanceof GOMTitle);
+			assertSame(parser, this.impl.getTitle());
+			try {
+				this.impl.getChildParser(new QName(GOMNamespace.ATOM_NS_URI,
+						"title"));
+				fail("exactly one time ");
+			} catch (GDataParseException e) {
+				// 
+			}
+
+		}
+
+		{
+			// atomUpdated
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.ATOM_NS_URI, "updated"));
+			assertNotNull(parser);
+			assertTrue(parser instanceof GOMUpdated);
+			assertSame(parser, this.impl.getUpdated());
+			try {
+				this.impl.getChildParser(new QName(GOMNamespace.ATOM_NS_URI,
+						"updated"));
+				fail("exactly one time ");
+			} catch (GDataParseException e) {
+				// 
+			}
+
+		}
+
+		{
+			// atomEntry*
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.ATOM_NS_URI, "entry"));
+			assertNotNull(parser);
+			assertTrue(parser instanceof GOMEntry);
+			assertEquals(1, this.impl.getEntries().size());
+			this.impl.getChildParser(new QName(GOMNamespace.ATOM_NS_URI,
+					"entry"));
+			assertEquals(2, this.impl.getEntries().size());
+
+		}
+
+		// openSearch
+		{
+			// startIndex
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.OPENSEARCH_NS_URI, "startIndex"));
+			assertNotNull(parser);
+
+		}
+		{
+			// startIndex
+			AtomParser parser = this.impl.getChildParser(new QName(
+					GOMNamespace.OPENSEARCH_NS_URI, "itemsPerPage"));
+			assertNotNull(parser);
+
+		}
+
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMFeedImpl.processElementValue(String)'
+	 */
+	public void testProcessElementValue() {
+		try {
+			this.impl.processElementValue("some");
+			fail("no element text");
+		} catch (GDataParseException e) {
+			//
+		}
+
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMFeedImpl.processEndElement()'
+	 * 
+	 * atomFeed = element atom:feed { atomCommonAttributes, (atomAuthor* &
+	 * atomCategory* & atomContributor* & atomGenerator? & atomIcon? & atomId &
+	 * atomLink* & atomLogo? & atomRights? & atomSubtitle? & atomTitle &
+	 * atomUpdated & extensionElement*), atomEntry* }
+	 */
+	public void testProcessEndElement() {
+		this.impl.addAuthor(new GOMAuthorImpl());
+		this.impl.setId(new GOMIdImpl());
+		this.impl.setUpdated(new GOMUpdatedImpl());
+		this.impl.setTitle(new GOMTitleImpl());
+
+		this.impl.processEndElement();
+		{
+			// author missing
+			this.impl.getAuthors().clear();
+			try {
+				this.impl.processEndElement();
+				fail("missing elements");
+			} catch (GDataParseException e) {
+				// 
+			}
+			this.impl.addAuthor(new GOMAuthorImpl());
+		}
+
+		{
+			// id missing
+			this.impl.setId(null);
+			try {
+				this.impl.processEndElement();
+				fail("missing elements");
+			} catch (GDataParseException e) {
+				// 
+			}
+			this.impl.setId(new GOMIdImpl());
+		}
+
+		{
+			// title missing
+			this.impl.setTitle(null);
+			try {
+				this.impl.processEndElement();
+				fail("missing elements");
+			} catch (GDataParseException e) {
+				// 
+			}
+			this.impl.setTitle(new GOMTitleImpl());
+		}
+		{
+			// updated missing
+			this.impl.setUpdated(null);
+			try {
+				this.impl.processEndElement();
+				fail("missing elements");
+			} catch (GDataParseException e) {
+				// 
+			}
+			this.impl.setUpdated(new GOMUpdatedImpl());
+		}
+
+		/*
+		 * atom:feed elements MUST NOT contain more than one atom:link element
+		 * with a rel attribute value of "alternate" that has the same
+		 * combination of type and hreflang attribute values.
+		 */
+
+		{
+			// two identical alternate links missing
+			GOMLink link = new GOMLinkImpl();
+			link.setRel("alternate");
+			link.setHrefLang("http://www.apache.org");
+			link.setType("text/html");
+			this.impl.addLink(link);
+			// one is allowed
+			this.impl.processEndElement();
+			// add a second link
+			link = new GOMLinkImpl();
+			this.impl.addLink(link);
+			link.setRel("next");
+			link.setHrefLang("http://www.apache.org");
+			link.setType("text/html");
+			// one is alternate the other is next
+			this.impl.processEndElement();
+
+			// a second "identical" alternate link
+			link = new GOMLinkImpl();
+			this.impl.addLink(link);
+			link.setRel("alternate");
+			link.setHrefLang("http://www.apache.org");
+			link.setType("text/html");
+			try {
+				this.impl.processEndElement();
+				fail("missing elements");
+			} catch (GDataParseException e) {
+				// 
+			}
+			this.impl.setUpdated(new GOMUpdatedImpl());
+		}
+
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMFeedImpl.GOMFeedImpl()'
+	 */
+	public void testGOMFeedImpl() {
+		GOMFeedImpl impl2 = new GOMFeedImpl();
+		assertEquals(GOMFeed.LOCALNAME, impl2.getLocalName());
+		assertEquals(GOMFeed.LOCALNAME, impl2.getQname().getLocalPart());
+		assertEquals(GOMNamespace.ATOM_NS_URI, impl2.getQname()
+				.getNamespaceURI());
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMFeedImpl.getStartIndex()' and
+	 * 'org.apache.lucene.gdata.gom.core.GOMFeedImpl.setStartIndex(int)'
+	 */
+	public void testGetSetStartIndex() {
+		assertEquals(GOMFeedImpl.DEFAULT_START_INDEX, this.impl.getStartIndex());
+		this.impl.setStartIndex(5);
+		assertEquals(5, this.impl.getStartIndex());
+		this.impl.setStartIndex(-5);
+		assertEquals(5, this.impl.getStartIndex());
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMFeedImpl.setItemsPerPage(int)' and
+	 * 'org.apache.lucene.gdata.gom.core.GOMFeedImpl.getNamespaces()'
+	 */
+	public void testGetSetItemsPerPage() {
+		assertEquals(GOMFeedImpl.DEFAULT_ITEMS_PER_PAGE, this.impl
+				.getItemsPerPage());
+		this.impl.setItemsPerPage(5);
+		assertEquals(5, this.impl.getItemsPerPage());
+		this.impl.setItemsPerPage(-5);
+		assertEquals(5, this.impl.getItemsPerPage());
+
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMFeedImpl.writeAtomOutput(GOMWriter)'
+	 */
+	public void testWriteAtomOutput() throws XMLStreamException,
+			FactoryConfigurationError {
+		// write a whole feed and check if all elements are written
+		this.impl.addAuthor(new GOMAuthorImpl());
+		this.impl.addCategory(new GOMCategoryImpl());
+		this.impl.addContributor(new GOMContributorImpl());
+		this.impl.addLink(new GOMLinkImpl());
+		this.impl.addNamespace(GOMNamespace.OPENSEARCH_NAMESPACE);
+		this.impl.setGenerator(new GOMGeneratorImpl());
+		this.impl.setIcon(new GOMIconImpl());
+		this.impl.setId(new GOMIdImpl());
+		this.impl.setLogo(new GOMLogoImpl());
+		this.impl.setRights(new GOMRightsImpl());
+		this.impl.setSubtitle(new GOMSubtitleImpl());
+		this.impl.setTitle(new GOMTitleImpl());
+		this.impl.setUpdated(new GOMUpdatedImpl());
+		this.impl.extensions.add(new TestExtension());
+		this.impl.addNamespace(GOMNamespace.OPENSEARCH_NAMESPACE);
+		StringWriter stW = new StringWriter();
+		GOMOutputWriter writer = new GOMStaxWriter(stW);
+		this.impl.writeAtomOutput(writer);
+		String string = stW.toString();
+		assertTrue(string.contains("xmlns:openSearch"));
+		assertTrue(string.contains("xmlns=\"http://www.w3.org/2005/Atom\""));
+		assertTrue(string.contains("<" + GOMAuthor.LOCALNAME));
+		assertTrue(string.contains("<" + GOMCategory.LOCALNAME));
+		assertTrue(string.contains("<" + GOMContributor.LOCALNAME));
+		assertTrue(string.contains("<" + GOMLink.LOCALNAME));
+		assertTrue(string.contains("<" + GOMGenerator.LOCALNAME));
+		assertTrue(string.contains("<" + GOMIcon.LOCALNAME));
+		assertTrue(string.contains("<" + GOMId.LOCALNAME));
+		assertTrue(string.contains("<" + GOMLogo.LOCALNAME));
+		assertTrue(string.contains("<" + GOMRights.LOCALNAME));
+		assertTrue(string.contains("<" + GOMSubtitle.LOCALNAME));
+		assertTrue(string.contains("<" + GOMTitle.LOCALNAME));
+		assertTrue(string.contains("<" + GOMUpdated.LOCALNAME));
+		assertTrue(string.contains("<openSearch:itemsPerPage>"));
+		assertTrue(string.contains("<openSearch:startIndex>"));
+		assertTrue(string.contains("<test"));
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMFeedImpl.writeRssOutput(GOMWriter)'
+	 */
+	public void testWriteRssOutput() throws XMLStreamException,
+			FactoryConfigurationError {
+		// write a whole feed and check if all elements are written
+		this.impl.addAuthor(new GOMAuthorImpl());
+		this.impl.addCategory(new GOMCategoryImpl());
+		this.impl.addContributor(new GOMContributorImpl());
+		GOMLinkImpl impl2 = new GOMLinkImpl();
+		impl2.setHref("test");
+		impl2.setRel("alternate");
+		this.impl.addLink(impl2);
+		this.impl.addNamespace(GOMNamespace.OPENSEARCH_NAMESPACE);
+		this.impl.setGenerator(new GOMGeneratorImpl());
+		this.impl.setIcon(new GOMIconImpl());
+		this.impl.setId(new GOMIdImpl());
+		this.impl.setLogo(new GOMLogoImpl());
+		this.impl.setRights(new GOMRightsImpl());
+		this.impl.setSubtitle(new GOMSubtitleImpl());
+		this.impl.setTitle(new GOMTitleImpl());
+		this.impl.setUpdated(new GOMUpdatedImpl());
+		this.impl.addNamespace(GOMNamespace.ATOM_NAMESPACE);
+		this.impl.addNamespace(GOMNamespace.OPENSEARCH_NAMESPACE);
+		this.impl.extensions.add(new TestExtension());
+		StringWriter stW = new StringWriter();
+		GOMOutputWriter writer = new GOMStaxWriter(stW);
+		this.impl.writeRssOutput(writer);
+
+		String string = stW.toString();
+		assertTrue(string.contains("xmlns:openSearch"));
+		assertTrue(string.contains("xmlns:atom"));
+		// TODO
+		// assertTrue(string.contains("<language"));
+		assertTrue(string.contains("<" + GOMCategory.LOCALNAME));
+		// author
+		assertTrue(string.contains("<managingEditor"));
+		assertTrue(string.contains("<" + GOMLink.LOCALNAME));
+		assertTrue(string.contains("<" + GOMGenerator.LOCALNAME));
+		assertTrue(string.contains("<image><url"));
+		assertTrue(string.contains("<atom:" + GOMId.LOCALNAME));
+
+		assertTrue(string.contains("<copyright"));
+		assertTrue(string.contains("<" + GOMTitle.LOCALNAME));
+		assertTrue(string.contains("<lastBuildDate"));
+		assertTrue(string.contains("<openSearch:itemsPerPage>"));
+		assertTrue(string.contains("<openSearch:startIndex>"));
+		assertTrue(string.contains("<atom:test"));
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMFeedImpl.getExtensions()'
+	 */
+	public void testGetExtensions() {
+
+		{
+			List<GOMExtension> extensions = this.impl.getExtensions();
+			assertNotNull(extensions);
+			assertEquals(0, extensions.size());
+		}
+		QName name = new QName(TEST_LOCAL_NAME);
+		this.impl.setExtensionFactory(new TestExtendsionFactory());
+
+		AtomParser childParser = this.impl.getChildParser(name);
+		assertTrue(childParser instanceof TestExtension);
+		List<GOMExtension> extensions = this.impl.getExtensions();
+		assertNotNull(extensions);
+		assertEquals(1, extensions.size());
+		assertSame(childParser, extensions.get(0));
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMFeedImpl.setExtensionFactory(GOMExtensionFactory)'
+	 */
+	public void testSetExtensionFactory() {
+		QName name = new QName(TEST_LOCAL_NAME);
+		try {
+			this.impl.getChildParser(name);
+			fail("no child hander for this qname");
+		} catch (GDataParseException e) {
+			// 
+		}
+
+		this.impl.setExtensionFactory(new TestExtendsionFactory());
+
+		AtomParser childParser = this.impl.getChildParser(name);
+		assertTrue(childParser instanceof TestExtension);
+
+	}
+
+	static class TestExtendsionFactory implements GOMExtensionFactory {
+
+		public GOMExtension canHandleExtensionElement(QName aName) {
+			if (aName.getLocalPart().equals(TEST_LOCAL_NAME))
+				return new TestExtension();
+			return null;
+		}
+
+		public List<GOMNamespace> getNamespaces() {
+			LinkedList<GOMNamespace> name = new LinkedList<GOMNamespace>();
+			name.add(GOMNamespace.ATOM_NAMESPACE);
+			return name;
+		}
+
+	}
+
+	static class TestExtension implements GOMExtension {
+
+		public QName getQname() {
+			// TODO Auto-generated method stub
+			return null;
+		}
+
+		public void setNamespaceUri(String aString) {
+			// TODO Auto-generated method stub
+
+		}
+
+		public void setNamespacePrefix(String aString) {
+			// TODO Auto-generated method stub
+
+		}
+
+		public void setLocalName(String aLocalName) {
+			// TODO Auto-generated method stub
+
+		}
+
+		public String getLocalName() {
+			// TODO Auto-generated method stub
+			return null;
+		}
+
+		public String getTextValue() {
+			// TODO Auto-generated method stub
+			return null;
+		}
+
+		public void setTextValue(String aTextValue) {
+			// TODO Auto-generated method stub
+
+		}
+
+		public void addChild(GOMElement aElement) {
+			// TODO Auto-generated method stub
+
+		}
+
+		public GOMElement getParent() {
+			// TODO Auto-generated method stub
+			return null;
+		}
+
+		public void writeAtomOutput(GOMOutputWriter aStreamWriter)
+				throws XMLStreamException {
+			aStreamWriter.writeSimpleXMLElement("test", null, "helloworld");
+
+		}
+
+		public void writeRssOutput(GOMOutputWriter aStreamWriter)
+				throws XMLStreamException {
+			aStreamWriter.writeSimpleXMLElement(new QName(
+					GOMNamespace.ATOM_NS_URI, "test",
+					GOMNamespace.ATOM_NS_PREFIX), null, "helloworld");
+
+		}
+
+		public void processElementValue(String aValue) {
+			// TODO Auto-generated method stub
+
+		}
+
+		public void processAttribute(QName aQName, String aValue) {
+			// TODO Auto-generated method stub
+
+		}
+
+		public void processEndElement() {
+			// TODO Auto-generated method stub
+
+		}
+
+		public AtomParser getChildParser(QName aName) {
+			// TODO Auto-generated method stub
+			return null;
+		}
+
+		public void writeRssOutput(GOMOutputWriter aStreamWriter,
+				String aRssName) throws XMLStreamException {
+
+		}
+
+		public String getXmlBase() {
+			// TODO Auto-generated method stub
+			return null;
+		}
+
+		public String getXmlLang() {
+			// TODO Auto-generated method stub
+			return null;
+		}
+
+	}
+
+}

Added: lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMGenereatorImplTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMGenereatorImplTest.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMGenereatorImplTest.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMGenereatorImplTest.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,204 @@
+package org.apache.lucene.gdata.gom.core;
+
+import java.io.StringWriter;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.lucene.gdata.gom.GOMGenerator;
+import org.apache.lucene.gdata.gom.GOMNamespace;
+import org.apache.lucene.gdata.gom.writer.GOMStaxWriter;
+import org.apache.lucene.gdata.gom.writer.GOMOutputWriter;
+
+import junit.framework.TestCase;
+
+public class GOMGenereatorImplTest extends TestCase {
+	private GOMGeneratorImpl impl;
+
+	protected void setUp() throws Exception {
+		this.impl = new GOMGeneratorImpl();
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMGeneratorImpl.processAttribute(QName,
+	 * String)'
+	 */
+	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) {
+			// 
+		}
+
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMGeneratorImpl.processElementValue(String)'
+	 */
+	public void testProcessElementValue() {
+		this.impl.processElementValue("myGenerator");
+		assertEquals("myGenerator", this.impl.getTextValue());
+
+		try {
+			this.impl.processElementValue("testme");
+			fail("duplicated");
+
+		} catch (GDataParseException e) {
+			//
+		}
+
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMGeneratorImpl.processEndElement()'
+	 */
+	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();
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMGeneratorImpl.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());
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMGeneratorImpl.writeAtomOutput(GOMWriter)'
+	 */
+	public void testWriteAtomOutput() throws XMLStreamException {
+		{
+			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());
+		}
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMGeneratorImpl.writeRssOutput(GOMWriter)'
+	 */
+	public void testWriteRssOutput() throws XMLStreamException,
+			FactoryConfigurationError {
+		{
+			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());
+		}
+	}
+
+}

Added: lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMIdImplTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMIdImplTest.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMIdImplTest.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMIdImplTest.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,115 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.gdata.gom.core;
+
+import java.io.StringWriter;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.lucene.gdata.gom.writer.GOMOutputWriter;
+import org.apache.lucene.gdata.gom.writer.GOMStaxWriter;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Simon Willnauer
+ * 
+ */
+public class GOMIdImplTest extends TestCase {
+	GOMIdImpl impl;
+
+	protected void setUp() throws Exception {
+		this.impl = new GOMIdImpl();
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMIdImpl.writeAtomOutput(GOMOutputWriter)'
+	 */
+	public void testWriteAtomOutput() throws XMLStreamException {
+		{
+			StringWriter stW = new StringWriter();
+			GOMOutputWriter writer = new GOMStaxWriter(stW);
+			this.impl.writeAtomOutput(writer);
+
+			assertEquals("<id/>", stW.toString());
+		}
+
+		{
+			this.impl.setTextValue("testme");
+			StringWriter stW = new StringWriter();
+			GOMOutputWriter writer = new GOMStaxWriter(stW);
+			this.impl.writeAtomOutput(writer);
+
+			assertEquals("<id>testme</id>", stW.toString());
+
+		}
+
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMIdImpl.writeRssOutput(GOMOutputWriter)'
+	 */
+	public void testWriteRssOutputGOMOutputWriter() throws XMLStreamException {
+		{
+			StringWriter stW = new StringWriter();
+			GOMOutputWriter writer = new GOMStaxWriter(stW);
+			this.impl.writeRssOutput(writer);
+
+			assertEquals("<atom:id/>", stW.toString());
+		}
+
+		{
+			this.impl.setTextValue("testme");
+			StringWriter stW = new StringWriter();
+			GOMOutputWriter writer = new GOMStaxWriter(stW);
+			this.impl.writeRssOutput(writer);
+
+			assertEquals("<atom:id>testme</atom:id>", stW.toString());
+
+		}
+
+		{
+			this.impl.setTextValue("testme");
+			StringWriter stW = new StringWriter();
+			GOMOutputWriter writer = new GOMStaxWriter(stW);
+			this.impl.writeRssOutput(writer, "guid");
+
+			assertEquals("<guid>testme</guid>", stW.toString());
+
+		}
+
+	}
+
+	public void testProcessElementValue() {
+		this.impl.processElementValue("test");
+		assertEquals("test", this.impl.getTextValue());
+	}
+
+	public void testProcessEndElement() {
+		try {
+			this.impl.processEndElement();
+			fail("not set");
+		} catch (GDataParseException e) {
+			// 
+		}
+		this.impl.setTextValue("testme");
+		this.impl.processEndElement();
+
+	}
+}

Added: lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMLinkImplTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMLinkImplTest.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMLinkImplTest.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/test/org/apache/lucene/gdata/gom/core/GOMLinkImplTest.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,239 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.gdata.gom.core;
+
+import java.io.StringWriter;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.lucene.gdata.gom.GOMLink;
+import org.apache.lucene.gdata.gom.writer.GOMStaxWriter;
+import org.apache.lucene.gdata.gom.writer.GOMOutputWriter;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Simon Willnauer
+ * 
+ */
+public class GOMLinkImplTest extends TestCase {
+
+	private GOMLinkImpl impl;
+
+	/**
+	 * @see junit.framework.TestCase#setUp()
+	 */
+	@Override
+	protected void setUp() throws Exception {
+		impl = new GOMLinkImpl();
+	}
+
+	public void testCommonFields() {
+		assertNotNull(this.impl.getQname());
+		QName qname = this.impl.getQname();
+		assertEquals(qname, new QName(GOMLink.LOCALNAME));
+		assertEquals(qname.getLocalPart(), this.impl.getLocalName());
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMLinkImpl.processAttribute(QName,
+	 * String)'
+	 */
+	public void testProcessAttribute() {
+		// title
+		this.impl.processAttribute(new QName("title"), "title");
+		assertEquals("title", this.impl.getTitle());
+		try {
+			this.impl.processAttribute(new QName("title"), "title");
+			fail("duplicated attribute");
+		} catch (GDataParseException e) {
+			// 
+		}
+
+		// hreflang
+		this.impl.processAttribute(new QName("hreflang"), "hreflang");
+		assertEquals("hreflang", this.impl.getHrefLang());
+		try {
+			this.impl.processAttribute(new QName("hreflang"), "hreflang");
+			fail("duplicated attribute");
+		} catch (GDataParseException e) {
+			// 
+		}
+
+		// href
+		this.impl.processAttribute(new QName("href"), "href");
+		assertEquals("href", this.impl.getHref());
+		try {
+			this.impl.processAttribute(new QName("href"), "href");
+			fail("duplicated attribute");
+		} catch (GDataParseException e) {
+			// 
+		}
+		// type
+		this.impl.processAttribute(new QName("type"), "type");
+		assertEquals("type", this.impl.getType());
+		try {
+			this.impl.processAttribute(new QName("type"), "type");
+			fail("duplicated attribute");
+		} catch (GDataParseException e) {
+			// 
+		}
+
+		// lenght
+		try {
+			this.impl.processAttribute(new QName("length"), "noint");
+			fail("must be an integer");
+		} catch (GDataParseException e) {
+			// 
+		}
+
+		this.impl.processAttribute(new QName("length"), "1");
+		assertEquals(new Integer(1), this.impl.getLength());
+		try {
+			this.impl.processAttribute(new QName("length"), "1");
+			fail("duplicated attribute");
+		} catch (GDataParseException e) {
+			// 
+		}
+
+		// 
+		// rel
+		this.impl.processAttribute(new QName("rel"), "relation");
+		assertEquals("relation", this.impl.getRel());
+		try {
+			this.impl.processAttribute(new QName("rel"), "relation");
+			fail("duplicated attribute");
+		} catch (GDataParseException e) {
+			// 
+		}
+
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMLinkImpl.processEndElement()'
+	 */
+	public void testProcessEndElement() {
+		try {
+			this.impl.processEndElement();
+			fail("href is requiered but not set");
+		} catch (GDataParseException e) {
+			// 
+		}
+
+		this.impl.setHref("/helloworld");
+		try {
+			this.impl.processEndElement();
+			fail("href is not an absolute url");
+		} catch (GDataParseException e) {
+			// 
+		}
+		this.impl.xmlBase = "http://url";
+		this.impl.processEndElement();
+		this.impl.xmlBase = null;
+		this.impl.setHref("http://www.apache.org");
+		this.impl.processEndElement();
+
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMLinkImpl.writeAtomOutput(GOMWriter)'
+	 */
+	public void testWriteAtomOutput() throws XMLStreamException {
+		{
+			StringWriter strWriter = new StringWriter();
+			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
+			this.impl.writeAtomOutput(writer);
+			assertEquals("<link href=\"\"/>", strWriter.toString());
+		}
+		{
+			StringWriter strWriter = new StringWriter();
+			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
+			this.impl.setHref("test");
+			this.impl.setHrefLang("test1");
+			this.impl.setLength(2);
+			this.impl.setRel("NEXT");
+			this.impl.setTitle("myTitle");
+			this.impl.setType("myType");
+			this.impl.writeAtomOutput(writer);
+			assertTrue(strWriter.toString().contains("href=\"test\""));
+			assertTrue(strWriter.toString().contains("title=\"myTitle\""));
+			assertTrue(strWriter.toString().contains("hreflang=\"test1\""));
+			assertTrue(strWriter.toString().contains("type=\"myType\""));
+			assertTrue(strWriter.toString().contains("rel=\"NEXT\""));
+			assertTrue(strWriter.toString().contains("length=\"2\""));
+		}
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.GOMLinkImpl.writeRssOutput(GOMWriter)'
+	 */
+	public void testWriteRssOutput() throws XMLStreamException {
+		{
+			StringWriter strWriter = new StringWriter();
+			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
+			this.impl.writeRssOutput(writer);
+			assertEquals("", strWriter.toString());
+		}
+
+		{
+			this.impl.setHref("test");
+			this.impl.setType("testType");
+			this.impl.setRel("enclosure");
+			StringWriter strWriter = new StringWriter();
+			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
+			this.impl.writeRssOutput(writer);
+			assertEquals("<enclosure type=\"testType\" href=\"test\"/>",
+					strWriter.toString());
+		}
+
+		{
+			this.impl.setRel("comments");
+			StringWriter strWriter = new StringWriter();
+			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
+			this.impl.writeRssOutput(writer);
+			assertEquals("<comments>test</comments>", strWriter.toString());
+		}
+
+		{
+			this.impl.setRel("alternate");
+			StringWriter strWriter = new StringWriter();
+			GOMOutputWriter writer = new GOMStaxWriter(strWriter);
+			this.impl.writeRssOutput(writer);
+			assertEquals("<link>test</link>", strWriter.toString());
+		}
+
+	}
+
+	/*
+	 * Test method for
+	 * 'org.apache.lucene.gdata.gom.core.AbstractGOMElement.processElementValue(String)'
+	 */
+	public void testProcessElementValue() {
+		try {
+			this.impl.processElementValue("hello world");
+			fail("no content");
+		} catch (GDataParseException e) {
+			// TODO: handle exception
+		}
+	}
+
+}