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 2009/12/01 23:56:24 UTC

svn commit: r885993 - in /incubator/wookie/trunk: src-tests/org/apache/wookie/tests/conformance/ src/org/apache/wookie/manifestmodel/impl/

Author: scottbw
Date: Tue Dec  1 22:56:23 2009
New Revision: 885993

URL: http://svn.apache.org/viewvc?rev=885993&view=rev
Log:
Corrected problems with processing <feature> elements (see WOOKIE-62) and completed the conformance tests for features. These currently require manual enabling and checking, as its not possible (nor desirable) to expose this information via API. All W3C tests for Feature elements now pass.

Modified:
    incubator/wookie/trunk/src-tests/org/apache/wookie/tests/conformance/PackagingAndConfiguration.java
    incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/FeatureEntity.java
    incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/ParamEntity.java
    incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/WidgetManifestModel.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=885993&r1=885992&r2=885993&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 Tue Dec  1 22:56:23 2009
@@ -31,6 +31,8 @@
  * You need to be online to run these tests as they download test widgets hosted externally.
  * For more information see http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/index.html
  * 
+ * Note that in order to run the Feature tests, a ServerFeature named "feature:a9bb79c1" must be set up in the DB
+ * 
  * @author scott
  *
  */
@@ -831,33 +833,27 @@
 		assertEquals("index.htm",start);
 	}
 
-	// 33 TODO Start File Text Encoding
+	// 33 Start File Text Encoding
 	@Test
-	@Ignore
 	public void e4(){
-		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-CEGwkNQcWo/000/e2.wgt");
+		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-dPOgiLQKNK/000/e4.wgt");
 		assertEquals("UTF-8",getStartFileEncoding(widget));
 	}
 	@Test
-	@Ignore
 	public void e5(){
-		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-CEGwkNQcWo/001/e3.wgt");
+		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-dPOgiLQKNK/001/e5.wgt");
 		assertEquals("ISO-8859-1",getStartFileEncoding(widget));
 	}
 	@Test
-	@Ignore
 	public void e6(){
-		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-CEGwkNQcWo/002/e4.wgt");
+		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-dPOgiLQKNK/002/e6.wgt");
 		assertEquals("ISO-8859-1",getStartFileEncoding(widget));
 	}
 	@Test
-	@Ignore
 	public void e7(){
-		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-CEGwkNQcWo/003/e5.wgt");
+		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-dPOgiLQKNK/003/e7.wgt");
 		assertEquals("UTF-8",getStartFileEncoding(widget));
 	}
-
-	
 	
 	//34
 	@Test
@@ -887,20 +883,21 @@
 
 	//36
 	@Test
-	@Ignore
 	public void e1(){
-		// TODO needs to test features
+		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-KNiLPOKdgQ/000/e1.wgt");
+		System.out.println("Manual test:"+widget.getAttributeValue("identifier")+":the feature feature:a9bb79c1 must not have any params associated with it.");
 	}
 	//37
 	@Test
-	@Ignore
 	public void df(){
-		// TODO needs to test features
+		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-rZdcMBExBX/000/df.wgt");
+		System.out.println("Manual test:"+widget.getAttributeValue("identifier")+":To pass, the feature list must remain empty. ");
+
 	}
 	@Test
-	@Ignore
 	public void dr(){
-		// TODO needs to test features
+		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-rZdcMBExBX/001/dr.wgt");
+		System.out.println("Manual test:"+widget.getAttributeValue("identifier")+":the feature list must contain one feature named 'feature:a9bb79c1' whose required value is false.");
 	}
 
 	//38
@@ -917,38 +914,38 @@
 	}	
 	//40
 	@Test
-	@Ignore
 	public void d5(){
-		// TODO needs to test features
+		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-luyKMFABLX/000/d5.wgt");
+		System.out.println("Manual test:"+widget.getAttributeValue("identifier")+":the user agent must not contain any values in the feature list (i.e., the unknown feature is skipped).");
 	}
 	//41
 	@Test
-	@Ignore
 	public void dt(){
-		// TODO needs to test features
+		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-EGkPfzCBOz/000/dt.wgt");
+		System.out.println("Manual test:"+widget.getAttributeValue("identifier")+":the feature list must contain one feature named 'feature:a9bb79c1' with no associated parameters. ");
 	}
 	@Test
-	@Ignore
 	public void dg(){
-		// TODO needs to test features
+		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-EGkPfzCBOz/001/dg.wgt");
+		System.out.println("Manual test:"+widget.getAttributeValue("identifier")+":the feature list must contain one feature named 'feature:a9bb79c1' with one associated parameter whose name is 'PASS' and whose value is 'PASS'. ");
 	}	
 	//42
 	@Test
-	@Ignore
 	public void d6(){
-		// TODO needs to test features
+		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-xlgUWUVzCY/000/d6.wgt");
+		System.out.println("Manual test:"+widget.getAttributeValue("identifier")+":feature 'feature:a9bb79c1' must not have any associated parameters.");
 	}
 
 	// 43 Feature
 	@Test
-	@Ignore
 	public void e2(){
-		// TODO needs to test features
+		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-CEGwkNQcWo/000/e2.wgt");
+		System.out.println("Manual test:"+widget.getAttributeValue("identifier")+":the feature feature:a9bb79c1 must not have any associated params. ");
 	}
 	@Test
-	@Ignore
 	public void e3(){
-		// TODO needs to test features
+		Element widget = processWidgetNoErrors("http://samaxes.svn.beanstalkapp.com/widgets_compatibility_matrix/trunk/test-cases/ta-CEGwkNQcWo/001/e3.wgt");
+		System.out.println("Manual test:"+widget.getAttributeValue("identifier")+":the feature feature:a9bb79c1 must not have any associated params. ");
 	}
 	
 	//44

Modified: incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/FeatureEntity.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/FeatureEntity.java?rev=885993&r1=885992&r2=885993&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/FeatureEntity.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/FeatureEntity.java Tue Dec  1 22:56:23 2009
@@ -17,6 +17,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.wookie.beans.ServerFeature;
 import org.apache.wookie.exceptions.BadManifestException;
 import org.apache.wookie.manifestmodel.IFeatureEntity;
 import org.apache.wookie.manifestmodel.IParamEntity;
@@ -91,20 +92,21 @@
 	
 	public void fromXML(Element element) throws BadManifestException {
 		fName = UnicodeUtils.normalizeSpaces(element.getAttributeValue(IW3CXMLConfiguration.NAME_ATTRIBUTE));
-		if(fName == null || fName.equals("")){
-			throw new BadManifestException("A Feature is defined in the manifest, but its name attribute is empty.");
-		}
+		fRequired = true;
 		String isRequired = UnicodeUtils.normalizeSpaces(element.getAttributeValue(IW3CXMLConfiguration.REQUIRED_ATTRIBUTE));
-		if(isRequired.equals("")){
-			fRequired = true;
-		}
-		else{
-			try {
-				fRequired = Boolean.valueOf(isRequired);
-			} 
-			catch (Exception e) {
-				fRequired = true;
-			}
+		if(isRequired.equals("false")) fRequired = false;
+		
+		if(fName.equals("")){
+			fName = null;
+		} else {
+			// Not supported?
+			if (ServerFeature.findByName(fName)==null){
+				if (fRequired){
+					throw new BadManifestException();
+				} else {
+					fName = null;
+				}
+			}	
 		}
 		
 		// parse the children (look for <param> elements)
@@ -116,7 +118,7 @@
 			if(tag.equals(IW3CXMLConfiguration.PARAM_ELEMENT)) {	
 				IParamEntity aParam = new ParamEntity();
 				aParam.fromXML(child);
-				fParams.add(aParam);
+				if (aParam.getName()!=null && aParam.getValue()!=null) fParams.add(aParam);
 			}
 		}
 		

Modified: incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/ParamEntity.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/ParamEntity.java?rev=885993&r1=885992&r2=885993&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/ParamEntity.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/ParamEntity.java Tue Dec  1 22:56:23 2009
@@ -29,8 +29,8 @@
 	private String fValue;
 	
 	public ParamEntity(){
-		fName = "";
-		fValue = "";
+		fName = null;
+		fValue = null;
 	}
 	
 	public ParamEntity(String name, String value) {
@@ -61,7 +61,9 @@
 	
 	public void fromXML(Element element) throws BadManifestException {
 		fName = UnicodeUtils.normalizeSpaces(element.getAttributeValue(IW3CXMLConfiguration.NAME_ATTRIBUTE));
+		if (fName.equals("")) fName = null;
 		fValue = UnicodeUtils.normalizeSpaces(element.getAttributeValue(IW3CXMLConfiguration.VALUE_ATTRIBUTE));
+		if (fValue.equals("")) fValue = null;
 	}	
 
 }

Modified: incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/WidgetManifestModel.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/WidgetManifestModel.java?rev=885993&r1=885992&r2=885993&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/WidgetManifestModel.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/WidgetManifestModel.java Tue Dec  1 22:56:23 2009
@@ -22,6 +22,7 @@
 import org.apache.commons.compress.archivers.zip.ZipFile;
 import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
+import org.apache.wookie.beans.ServerFeature;
 import org.apache.wookie.exceptions.BadManifestException;
 import org.apache.wookie.manifestmodel.IAccessEntity;
 import org.apache.wookie.manifestmodel.IAuthorEntity;
@@ -33,6 +34,7 @@
 import org.apache.wookie.manifestmodel.ILocalizedEntity;
 import org.apache.wookie.manifestmodel.IManifestModel;
 import org.apache.wookie.manifestmodel.INameEntity;
+import org.apache.wookie.manifestmodel.IParamEntity;
 import org.apache.wookie.manifestmodel.IPreferenceEntity;
 import org.apache.wookie.manifestmodel.IW3CXMLConfiguration;
 import org.apache.wookie.util.NumberUtils;
@@ -87,8 +89,8 @@
 	 * @throws IOException
 	 * @throws BadManifestException
 	 */
-	public WidgetManifestModel (String xmlText, String[] locales, ZipFile zip) throws JDOMException, IOException, BadManifestException {
-		super();
+	public WidgetManifestModel (String xmlText, String[] locales, ZipFile zip) throws JDOMException, IOException, BadManifestException {		
+		super();		
 		this.zip = zip;
 		fNamesList = new ArrayList<INameEntity>();
 		fDescriptionsList = new ArrayList<IDescriptionEntity>();
@@ -112,6 +114,25 @@
 				if (!exists) fIconsList.add(new IconEntity(iconpath,null,null));	
 			}
 		}
+		//Uncomment this when performing conformance testing
+		//outputFeatureList();
+	}
+	
+	/**
+	 * Used to check output during conformance testing
+	 */
+	private void outputFeatureList(){
+		if (fFeaturesList.size()==0) return;
+		String out = "";
+		out+=("id:"+this.fIdentifier+":"+this.getLocalName("en"));
+		for (IFeatureEntity feature: fFeaturesList){
+			String params = "";
+			for (IParamEntity param:feature.getParams()){
+				params+="["+param.getName()+":"+param.getValue()+"]";
+			}
+			out+=("feature:"+feature.getName()+"required="+feature.isRequired()+"{"+params+"}");
+		}
+		System.out.println(out);
 	}
 	
 	public String getViewModes() {
@@ -387,7 +408,7 @@
 			if(tag.equals(IW3CXMLConfiguration.FEATURE_ELEMENT)) {
 				IFeatureEntity feature = new FeatureEntity();
 				feature.fromXML(child);
-				fFeaturesList.add(feature);
+				if (feature.getName()!=null) fFeaturesList.add(feature);
 			}
 			
 			// PREFERENCE IS OPTIONAL - can be many