- From: Jean-Guilhem Rouel via cvs-syncmail <cvsmail@w3.org>
- Date: Fri, 12 Sep 2008 18:01:53 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/org/w3c/unicorn
In directory hutz:/tmp/cvs-serv11277/org/w3c/unicorn
Modified Files:
Framework.java UnicornCall.java
Log Message:
first version that works with Jigsaw + fixed a bug in cond handling + removed parse(InputStream)
Index: Framework.java
===================================================================
RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/Framework.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- Framework.java 8 Sep 2008 13:43:47 -0000 1.15
+++ Framework.java 12 Sep 2008 18:01:51 -0000 1.16
@@ -134,6 +134,7 @@
try {
// Add all observer contract
final BufferedReader aBufferedReader;
+
aBufferedReader = new BufferedReader(new FileReader(Property
.get("OBSERVER_LIST_FILE")));
@@ -209,7 +210,6 @@
}
try {
// parse all the task files
-
final File[] tFileXML = ListFiles.listFiles(Property
.get("PATH_TO_TASKLIST"), "\\.xml");
Index: UnicornCall.java
===================================================================
RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/UnicornCall.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- UnicornCall.java 9 Sep 2008 10:16:16 -0000 1.20
+++ UnicornCall.java 12 Sep 2008 18:01:51 -0000 1.21
@@ -5,14 +5,18 @@
package org.w3c.unicorn;
import java.io.IOException;
+import java.io.InputStreamReader;
+
import java.net.MalformedURLException;
import java.net.URL;
+
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.activation.MimeType;
+
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
@@ -22,7 +26,9 @@
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.logging.Log;
+
import org.w3c.dom.Document;
+
import org.w3c.unicorn.contract.CallParameter;
import org.w3c.unicorn.contract.EnumInputMethod;
import org.w3c.unicorn.contract.InputMethod;
@@ -762,46 +768,42 @@
UnicornCall.logger.trace(cond);
UnicornCall.logger.trace("condId : " + cond.getId());
UnicornCall.logger.trace("condType : " + cond.getType());
- UnicornCall.logger.trace("condObserver : " + cond.getObserver().getID());
UnicornCall.logger.trace("condValue : " + cond.getValue());
- boolean passed = false;
- Response res = mapOfResponse.get(cond.getObserver().getID());
-
- // Testing if there is a matching response in the map
- // and if it is passed
- if (res != null && res.isPassed()) {
- if (cond.getType().equals(EnumCondType.MIMETYPE)) {
+ boolean passed = false;
+
+ if (cond.getType().equals(EnumCondType.MIMETYPE)) {
passed = cond.getValue().equals(getMimeType().toString());
- }
-
- else if (cond.getType().equals(EnumCondType.XPATH)) {
-
- String xmlStr = res.getXml().toString();
-
- DocumentBuilderFactory xmlFact = DocumentBuilderFactory
- .newInstance();
-
- // namespace awareness is escaped since we don't use it
- // for the moment
- xmlFact.setNamespaceAware(false);
-
- DocumentBuilder builder = xmlFact.newDocumentBuilder();
-
- Document doc = builder.parse(new java.io.ByteArrayInputStream(
- xmlStr.getBytes()));
-
- String xpathStr = cond.getValue();
-
- XPathFactory xpathFact = new XPathFactoryImpl();
-
- XPath xpath = xpathFact.newXPath();
- XPathExpression xpe = xpath.compile(xpathStr);
- passed = (Boolean) xpe.evaluate(doc, XPathConstants.BOOLEAN);
-
- }
-
- }
+ }
+ else if (cond.getType().equals(EnumCondType.XPATH)) {
+ UnicornCall.logger.trace("condObserver : " + cond.getObserver().getID());
+ Response res = mapOfResponse.get(cond.getObserver().getID());
+ // Testing if there is a matching response in the map
+ // and if it is passed
+ if (res != null) {
+ String xmlStr = res.getXml().toString();
+
+ DocumentBuilderFactory xmlFact = DocumentBuilderFactory
+ .newInstance();
+
+ // namespace awareness is escaped since we don't use it
+ // for the moment
+ xmlFact.setNamespaceAware(false);
+
+ DocumentBuilder builder = xmlFact.newDocumentBuilder();
+
+ Document doc = builder.parse(new java.io.ByteArrayInputStream(
+ xmlStr.getBytes()));
+
+ String xpathStr = cond.getValue();
+
+ XPathFactory xpathFact = new XPathFactoryImpl();
+
+ XPath xpath = xpathFact.newXPath();
+ XPathExpression xpe = xpath.compile(xpathStr);
+ passed = (Boolean) xpe.evaluate(doc, XPathConstants.BOOLEAN);
+ }
+ }
cond.setResult(passed);
UnicornCall.logger.trace("cond result : " + passed);
@@ -937,10 +939,20 @@
RequestThread.logger.error("Exception : " + e.getMessage(), e);
e.printStackTrace();
try {
- aResponse = ResponseParserFactory.parse((new URL("file:"
- + Property.get("PATH_TO_ERROR_TEMPLATES")
- + "en_io_error.vm")).openConnection().getInputStream(),
- aRequest.getResponseType());
+ StringBuilder builder = new StringBuilder();
+ // TODO should be first processed as a template
+ InputStreamReader isr = new InputStreamReader(new URL("file:"
+ + Property.get("PATH_TO_ERROR_TEMPLATES")
+ + "en_io_error.vm").openConnection().getInputStream());
+ char[] chararray = new char[8192];
+ int readLength = 0;
+ while((readLength = isr.read(chararray, 0, 8192)) > -1) {
+ builder.append(chararray, 0, readLength);
+ }
+
+ aResponse = ResponseParserFactory.parse(builder.toString(),
+ this.aRequest.getResponseType());
+ aResponse.setXml(builder);
} catch (MalformedURLException e1) {
e1.printStackTrace();
} catch (IOException e1) {
Received on Friday, 12 September 2008 18:03:13 UTC