incubator-wookie-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scot...@apache.org
Subject svn commit: r882721 - in /incubator/wookie/trunk: src-tests/org/apache/wookie/tests/conformance/PackagingAndConfiguration.java src/org/apache/wookie/helpers/WidgetHelper.java
Date Fri, 20 Nov 2009 21:32:14 GMT
Author: scottbw
Date: Fri Nov 20 21:32:13 2009
New Revision: 882721

URL: http://svn.apache.org/viewvc?rev=882721&view=rev
Log:
Added <author> element to widget data exposed by wookie, and implemented more W3C conformance
tests

Modified:
    incubator/wookie/trunk/src-tests/org/apache/wookie/tests/conformance/PackagingAndConfiguration.java
    incubator/wookie/trunk/src/org/apache/wookie/helpers/WidgetHelper.java

Modified: incubator/wookie/trunk/src-tests/org/apache/wookie/tests/conformance/PackagingAndConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src-tests/org/apache/wookie/tests/conformance/PackagingAndConfiguration.java?rev=882721&r1=882720&r2=882721&view=diff
==============================================================================
--- incubator/wookie/trunk/src-tests/org/apache/wookie/tests/conformance/PackagingAndConfiguration.java
(original)
+++ incubator/wookie/trunk/src-tests/org/apache/wookie/tests/conformance/PackagingAndConfiguration.java
Fri Nov 20 21:32:13 2009
@@ -181,11 +181,9 @@
 		assertEquals("pass&.html",start);
 	}
 	@Test
-	@Ignore
 	public void bw(){
-		//Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-klLDaEgJeU/003/bw.wgt");
-		// TODO include author in metadata generated from REST API
-		// assertEquals("PASS", widget.getChild("author").getText());
+		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-klLDaEgJeU/003/bw.wgt");
+		assertEquals("PASS", widget.getChild("author").getText());
 	}
 	// 11 widget
 	@Test
@@ -528,36 +526,38 @@
 
 	// 29 Author
 	@Test
-	@Ignore
 	public void b7(){
-		// TODO can't test without author exposed in metadata
+		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-sdwhMozwIc/000/b7.wgt");
+		assertEquals("PASS", widget.getChild("author").getText());
 	}
 	@Test
-	@Ignore
 	public void b8(){
-		// TODO can't test without author exposed in metadata
+		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-sdwhMozwIc/001/b8.wgt");
+		assertEquals("", widget.getChild("author").getText());
+
 	}
 	@Test
-	@Ignore
 	public void b9(){
-		// TODO can't test without author exposed in metadata
+		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-sdwhMozwIc/002/b9.wgt");
+		assertEquals("PASS", widget.getChild("author").getText());
+
 	}
 
 	// 30 Author  
 	@Test
-	@Ignore
 	public void af(){
-		// TODO can't test without author exposed in metadata
+		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-argMozRiC/000/af.wgt");
+		assertEquals("PASS", widget.getChild("author").getText());
 	}
 	@Test
-	@Ignore
 	public void ag(){
-		// TODO can't test without author exposed in metadata
+		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-argMozRiC/001/ag.wgt");
+		assertEquals("P A S S", widget.getChild("author").getText());
 	}
 	@Test
-	@Ignore
 	public void ah(){
-		// TODO can't test without author exposed in metadata
+		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-argMozRiC/002/ah.wgt");
+		assertEquals("PASS", widget.getChild("author").getText());
 	}
 	@Test
 	@Ignore
@@ -749,11 +749,13 @@
 		assertEquals("index.htm",start);
 	}
 
-	//37
+	//38
 	@Test
-	@Ignore
 	public void dc(){
-		// TODO needs to test start file location
+		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-paIabGIIMC/000/dc.wgt");
+		String start = locateStartFile(widget);
+		assertEquals("index.php",start);
+		assertEquals("text/html",getStartFileContentType(widget));
 	}
 	@Test
 	public void dv(){
@@ -761,26 +763,30 @@
 		assertFalse(err == null||err.equals(""));
 	}	
 
-	// 38 Start File Encoding
+	// 37 TODO Start File Text Encoding
 	@Test
 	@Ignore
 	public void e4(){
-		// TODO needs to test start file encoding
+		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-CEGwkNQcWo/000/e2.wgt");
+		assertEquals("UTF-8",getStartFileEncoding(widget));
 	}
 	@Test
 	@Ignore
 	public void e5(){
-		// TODO needs to test start file encoding
+		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-CEGwkNQcWo/001/e3.wgt");
+		assertEquals("ISO-8859-1",getStartFileEncoding(widget));
 	}
 	@Test
 	@Ignore
 	public void e6(){
-		// TODO needs to test start file encoding
+		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-CEGwkNQcWo/002/e4.wgt");
+		assertEquals("ISO-8859-1",getStartFileEncoding(widget));
 	}
 	@Test
 	@Ignore
 	public void e7(){
-		// TODO needs to test start file encoding
+		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-CEGwkNQcWo/003/e5.wgt");
+		assertEquals("UTF-8",getStartFileEncoding(widget));
 	}
 
 	//39
@@ -1018,6 +1024,26 @@
 		return doc.getRootElement().getChild("url").getText();
 	}
 
+	private String getStartFileEncoding(Element widget){
+		String response = instantiateWidget(widget);
+		String startFile = getStartFile(response);
+		// Download and check text encoding
+		try {
+			HttpClient client = new HttpClient();
+			GetMethod get = new GetMethod(startFile);
+			client.executeMethod(get);
+			int code = get.getStatusCode();
+			assertEquals(200,code);
+			get.releaseConnection();
+			return get.getResponseCharSet();
+		}
+		catch (Exception e) {
+			e.printStackTrace();
+			fail("failed to get start file");
+		}
+		return null;	
+	}
+	
 	private String getStartFileContentType(Element widget){
 		String response = instantiateWidget(widget);
 		String startFile = getStartFile(response);
@@ -1049,7 +1075,8 @@
 		try {
 			url = new URL(start);
 		} catch (MalformedURLException e) {
-			return null;
+				System.out.println("start file URL was invalid");
+				return null;
 		}
 		String[] parts = url.getPath().split("/");
 		start = parts[parts.length-1];

Modified: incubator/wookie/trunk/src/org/apache/wookie/helpers/WidgetHelper.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/helpers/WidgetHelper.java?rev=882721&r1=882720&r2=882721&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/helpers/WidgetHelper.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/helpers/WidgetHelper.java Fri Nov 20 21:32:13
2009
@@ -102,10 +102,16 @@
 		for (WidgetType type:types){
 			out +="\t\t<category>"+type.getWidgetContext()+"</category>\n";
 		}
+		
+		// Do author
+		out += "\t\t<author>"+widget.getWidgetAuthor()+"</author>";
+		
+		// TODO license
+		
+		// TODO features
 
 		// Do preference defaults
-		PreferenceDefault[] prefs = PreferenceDefault.findByValue("widget",
-				widget);
+		PreferenceDefault[] prefs = PreferenceDefault.findByValue("widget",widget);
 		for (PreferenceDefault pref : prefs) {
 			out += "\t\t<preference name=\"" + pref.getPreference() + "\"  value=\""+pref.getValue()+"\"
 readonly=\"" + (pref.isReadOnly()? "true" : "false") + "\"/>";
 		}



Mime
View raw message