You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wookie.apache.org by sc...@apache.org on 2011/05/20 10:46:32 UTC

svn commit: r1125279 - in /incubator/wookie/trunk/parser/java/src-test/org/apache/wookie/w3c/test: UpdateDescriptionDocumentTest.java UpdateDescriptionTest.java WidgetOutputterTest.java

Author: scottbw
Date: Fri May 20 08:46:32 2011
New Revision: 1125279

URL: http://svn.apache.org/viewvc?rev=1125279&view=rev
Log:
Fixed a minor test bug and added some more tests to improve test coverage

Modified:
    incubator/wookie/trunk/parser/java/src-test/org/apache/wookie/w3c/test/UpdateDescriptionDocumentTest.java
    incubator/wookie/trunk/parser/java/src-test/org/apache/wookie/w3c/test/UpdateDescriptionTest.java
    incubator/wookie/trunk/parser/java/src-test/org/apache/wookie/w3c/test/WidgetOutputterTest.java

Modified: incubator/wookie/trunk/parser/java/src-test/org/apache/wookie/w3c/test/UpdateDescriptionDocumentTest.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src-test/org/apache/wookie/w3c/test/UpdateDescriptionDocumentTest.java?rev=1125279&r1=1125278&r2=1125279&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src-test/org/apache/wookie/w3c/test/UpdateDescriptionDocumentTest.java (original)
+++ incubator/wookie/trunk/parser/java/src-test/org/apache/wookie/w3c/test/UpdateDescriptionDocumentTest.java Fri May 20 08:46:32 2011
@@ -115,13 +115,28 @@ public class UpdateDescriptionDocumentTe
 		assertEquals("test", udd.getDetails("en"));
 	}
 	
-	@Test
-	public void validRemoteDocument() throws InvalidUDDException, IOException{
-		UpdateDescriptionDocument udd = new UpdateDescriptionDocument("http://svn.apache.org/repos/asf/incubator/wookie/trunk/parser/java/src-test/update.xml");
-		assertEquals("1.0", udd.getVersionTag());
-		assertEquals("http://incubator.apache.org/wookie/test.wgt", udd.getUpdateSource().toString());
-		assertEquals("test", udd.getDetails("en"));
-	}
+  @Test
+  public void exportDocument() throws InvalidUDDException{
+    // Create document
+    UpdateDescriptionDocument udd = new UpdateDescriptionDocument(null, null, null);
+    Document doc = new Document();
+    Element el = new Element("update-info", IW3CXMLConfiguration.MANIFEST_NAMESPACE);
+    el.setAttribute("version","1.0");
+    el.setAttribute("src","http://incubator.apache.org/wookie/test.wgt");
+    Element details = new Element("details", IW3CXMLConfiguration.MANIFEST_NAMESPACE);
+    details.setText("test");
+    el.addContent(details);
+    doc.setRootElement(el);
+    udd.fromXML(doc);
+    // Export to XML
+    doc = new Document();
+    doc.setRootElement(udd.toXml());
+    // Read in again - should be a valid UDD
+    udd.fromXML(doc);
+    assertEquals("1.0", udd.getVersionTag());
+    assertEquals("http://incubator.apache.org/wookie/test.wgt", udd.getUpdateSource().toString());
+    assertEquals("test", udd.getDetails("en"));
+  }
 	
 	@Test (expected = InvalidUDDException.class)
 	public void missingRemoteDocument() throws InvalidUDDException, IOException{

Modified: incubator/wookie/trunk/parser/java/src-test/org/apache/wookie/w3c/test/UpdateDescriptionTest.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src-test/org/apache/wookie/w3c/test/UpdateDescriptionTest.java?rev=1125279&r1=1125278&r2=1125279&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src-test/org/apache/wookie/w3c/test/UpdateDescriptionTest.java (original)
+++ incubator/wookie/trunk/parser/java/src-test/org/apache/wookie/w3c/test/UpdateDescriptionTest.java Fri May 20 08:46:32 2011
@@ -32,8 +32,8 @@ public class UpdateDescriptionTest {
 	@Test
 	public void create(){
 		UpdateDescription desc = new UpdateDescription();
-		Element update = new Element("update-description", Namespace.getNamespace(IW3CXMLConfiguration.MANIFEST_NAMESPACE));
-		update.setAttribute("href", "http://localhost");
+		Element update = new Element(IW3CXMLConfiguration.UPDATE_ELEMENT, Namespace.getNamespace(IW3CXMLConfiguration.MANIFEST_NAMESPACE));
+		update.setAttribute(IW3CXMLConfiguration.HREF_ATTRIBUTE, "http://localhost");
 		try {
 			desc.fromXML(update);
 		} catch (BadManifestException e) {
@@ -45,8 +45,8 @@ public class UpdateDescriptionTest {
 	@Test
 	public void createInvalidURL(){
 		UpdateDescription desc = new UpdateDescription();
-		Element update = new Element("update-description", Namespace.getNamespace(IW3CXMLConfiguration.MANIFEST_NAMESPACE));
-		update.setAttribute("href", "notavalidurl!");
+		Element update = new Element(IW3CXMLConfiguration.UPDATE_ELEMENT, Namespace.getNamespace(IW3CXMLConfiguration.MANIFEST_NAMESPACE));
+		update.setAttribute(IW3CXMLConfiguration.HREF_ATTRIBUTE, "notavalidurl!");
 		try {
 			desc.fromXML(update);
 		} catch (BadManifestException e) {
@@ -55,4 +55,11 @@ public class UpdateDescriptionTest {
 		assertNull(desc.getHref());
 	}
 
+	@Test
+	public void export(){
+	   UpdateDescription desc = new UpdateDescription("http://localhost");
+	   Element el = desc.toXML();
+	   assertEquals("http://localhost", el.getAttributeValue(IW3CXMLConfiguration.HREF_ATTRIBUTE));
+	   
+	}
 }

Modified: incubator/wookie/trunk/parser/java/src-test/org/apache/wookie/w3c/test/WidgetOutputterTest.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src-test/org/apache/wookie/w3c/test/WidgetOutputterTest.java?rev=1125279&r1=1125278&r2=1125279&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src-test/org/apache/wookie/w3c/test/WidgetOutputterTest.java (original)
+++ incubator/wookie/trunk/parser/java/src-test/org/apache/wookie/w3c/test/WidgetOutputterTest.java Fri May 20 08:46:32 2011
@@ -64,7 +64,7 @@ public class WidgetOutputterTest extends
 		outputter.setWidgetFolder("/widgets");
 		String manifest = outputter.outputXMLString(widget);
 		assertTrue(manifest.contains("id=\"http://www.getwookie.org/widgets/weather\""));
-		assertTrue(manifest.contains("origin=\"http://feeds.bbc.co.uk"));
+		assertTrue(manifest.contains("origin=\"http://newsrss.bbc.co.uk"));
 	}
 	@Test
 	public void outputString4() throws Exception{