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/09/13 10:16:40 UTC
svn commit: r1170076 -
/incubator/wookie/trunk/parser/java/src-test/org/apache/wookie/w3c/test/ConformanceTest.java
Author: scottbw
Date: Tue Sep 13 08:16:40 2011
New Revision: 1170076
URL: http://svn.apache.org/viewvc?rev=1170076&view=rev
Log:
Added code comments
Modified:
incubator/wookie/trunk/parser/java/src-test/org/apache/wookie/w3c/test/ConformanceTest.java
Modified: incubator/wookie/trunk/parser/java/src-test/org/apache/wookie/w3c/test/ConformanceTest.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src-test/org/apache/wookie/w3c/test/ConformanceTest.java?rev=1170076&r1=1170075&r2=1170076&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src-test/org/apache/wookie/w3c/test/ConformanceTest.java (original)
+++ incubator/wookie/trunk/parser/java/src-test/org/apache/wookie/w3c/test/ConformanceTest.java Tue Sep 13 08:16:40 2011
@@ -35,22 +35,48 @@ public abstract class ConformanceTest {
static File download;
static File output;
+ /**
+ * Create temporary folders for widget downloads and for outputting results
+ * @throws IOException
+ */
@BeforeClass
public static void setup() throws IOException{
download = File.createTempFile("wookie-download", "wgt");
output = File.createTempFile("wookie-output", "tmp");
}
+ /**
+ * Delete temporary folders
+ */
@AfterClass
public static void tearDown(){
download.delete();
output.delete();
}
+ /**
+ * Download a widget from a URL and parse it
+ * @param url the URL to download the .wgt file from
+ * @return a W3C Widget object representing the manifest of the downloaded widget
+ * @throws InvalidContentTypeException
+ * @throws BadWidgetZipFileException
+ * @throws BadManifestException
+ * @throws Exception
+ */
private W3CWidget downloadWidget(String url) throws InvalidContentTypeException, BadWidgetZipFileException, BadManifestException, Exception{
return downloadWidget(url, true);
}
+ /**
+ * Download a widget from a URL and parse it
+ * @param url the URL to download the .wgt file from
+ * @param ignoreContentType set to true to ignore the content type of the request; otherwise the test will fail if the type is not application/widget
+ * @return a W3C Widget object representing the manifest of the downloaded widget
+ * @throws InvalidContentTypeException
+ * @throws BadWidgetZipFileException
+ * @throws BadManifestException
+ * @throws Exception
+ */
protected W3CWidget downloadWidget(String url, boolean ignoreContentType) throws InvalidContentTypeException, BadWidgetZipFileException, BadManifestException, Exception{
W3CWidgetFactory fac = new W3CWidgetFactory();
fac.setLocalPath("http:localhost/widgets");
@@ -63,6 +89,11 @@ public abstract class ConformanceTest {
return fac.parse(new URL(url),ignoreContentType);
}
+ /**
+ * Download a widget from a URL, and return the errors generated by attempting to parse it.
+ * @param url the URL to download the .wgt file from
+ * @return the error message generated when parsing the widget
+ */
public String processWidgetWithErrors(String url){
try {
downloadWidget(url);
@@ -78,6 +109,11 @@ public abstract class ConformanceTest {
return null;
}
+ /**
+ * Download a widget from a URL and parse it, returning the resulting W3C Widget object. Will fail if any errors occur in parsing.
+ * @param url the URL to download the .wgt file from
+ * @return a W3C Widget object representing the manifest of the downloaded widget
+ */
public W3CWidget processWidgetNoErrors(String url){
try {
return downloadWidget(url);