diff --git a/core/pom.xml b/core/pom.xml index 2672c8f07..159bc9a0e 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -16,7 +16,7 @@ limitations under the License. --> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 commons-jelly @@ -67,31 +67,6 @@ commons-lang 2.0 - - commons-discovery - commons-discovery - 20030211.213356 - - - forehead - forehead - 1.0-beta-5 - - - javax.servlet - jstl - 1.0.6 - - - junit - junit - 3.8.1 - - - dom4j - dom4j - 1.6.1 - commons-beanutils commons-beanutils @@ -107,15 +82,5 @@ commons-jexl 1.1 - - jaxen - jaxen - 1.1.6 - - - xerces - xercesImpl - 2.12.2 - diff --git a/core/src/main/java/org/apache/commons/jelly/Jelly.java b/core/src/main/java/org/apache/commons/jelly/Jelly.java index 2ccd43676..2c9648e00 100644 --- a/core/src/main/java/org/apache/commons/jelly/Jelly.java +++ b/core/src/main/java/org/apache/commons/jelly/Jelly.java @@ -186,7 +186,7 @@ public JellyContext getJellyContext() throws MalformedURLException { */ public URL getRootContext() throws MalformedURLException { if (rootContext == null) { - rootContext = new File(SystemProperties.getUserDir()).toURL(); + rootContext = new File(SystemProperties.getUserDir()).toURI().toURL(); } return rootContext; } @@ -249,7 +249,7 @@ protected void loadProperties(final InputStream is) throws IOException { final JellyContext theContext = getJellyContext(); final Properties props = new Properties(); props.load(is); - final Enumeration propsEnum = props.propertyNames(); + final Enumeration propsEnum = props.propertyNames(); while (propsEnum.hasMoreElements()) { final String key = (String) propsEnum.nextElement(); final String value = props.getProperty(key); @@ -272,7 +272,7 @@ protected URL resolveURL(final String name) throws MalformedURLException { } final File file = new File(name); if (file.exists()) { - return file.toURL(); + return file.toURI().toURL(); } return new URL(name); } diff --git a/core/src/main/java/org/apache/commons/jelly/JellyContext.java b/core/src/main/java/org/apache/commons/jelly/JellyContext.java index c8c574fc7..fafb8484c 100644 --- a/core/src/main/java/org/apache/commons/jelly/JellyContext.java +++ b/core/src/main/java/org/apache/commons/jelly/JellyContext.java @@ -268,7 +268,7 @@ protected URL createRelativeURL(final URL rootURL, final String relativeURI) URL url = rootURL; if (url == null) { final File file = new File(System.getProperty("user.dir")); - url = file.toURL(); + url = file.toURI().toURL(); } final String urlText = url.toString() + relativeURI; if ( log.isDebugEnabled() ) { @@ -735,7 +735,7 @@ public void removeVariable(final String name, final String scopeName) { */ public JellyContext runScript(final File file, final XMLOutput output) throws JellyException { try { - return runScript(file.toURL(), output, JellyContext.DEFAULT_EXPORT, + return runScript(file.toURI().toURL(), output, JellyContext.DEFAULT_EXPORT, JellyContext.DEFAULT_INHERIT); } catch (final MalformedURLException e) { throw new JellyException(e.toString()); @@ -750,7 +750,7 @@ public JellyContext runScript(final File file, final XMLOutput output) throws Je public JellyContext runScript(final File file, final XMLOutput output, final boolean export, final boolean inherit) throws JellyException { try { - return runScript(file.toURL(), output, export, inherit); + return runScript(file.toURI().toURL(), output, export, inherit); } catch (final MalformedURLException e) { throw new JellyException(e.toString()); } @@ -1020,8 +1020,8 @@ public void setVariable(final String name, final String scopeName, final Object public void setVariables(final Map variables) { // I have seen this fail when the passed Map contains a key, value // pair where the value is null - for (final Iterator iter = variables.entrySet().iterator(); iter.hasNext();) { - final Map.Entry element = (Map.Entry) iter.next(); + for (Object o : variables.entrySet()) { + final Map.Entry element = (Map.Entry) o; if (element.getValue() != null) { this.variables.put(element.getKey(), element.getValue()); } diff --git a/core/src/main/java/org/apache/commons/jelly/expression/jexl/JexlExpression.java b/core/src/main/java/org/apache/commons/jelly/expression/jexl/JexlExpression.java index 13383deb7..7c9e06e4b 100644 --- a/core/src/main/java/org/apache/commons/jelly/expression/jexl/JexlExpression.java +++ b/core/src/main/java/org/apache/commons/jelly/expression/jexl/JexlExpression.java @@ -138,7 +138,7 @@ public JexlExpression(final Expression expression) { @Override public Object evaluate(final JellyContext context) { try { - final JexlContext jexlContext = new JellyJexlContext( context ); + final JexlContext jexlContext = new JellyJexlContext(context); if (log.isDebugEnabled()) { log.debug("Evaluating EL: " + expression.getExpression()); } @@ -149,19 +149,11 @@ public Object evaluate(final JellyContext context) { } return value; - } - catch (final Exception e) { - if (context.isSuppressExpressionExceptions()) { - log.warn("Caught exception evaluating: " + expression + ". Reason: " + e, e); - return null; - } + } catch (final Exception e) { if (e instanceof RuntimeException) { - throw (RuntimeException)e; - } - if (e instanceof IllegalStateException) { - throw (IllegalStateException )e; + throw (RuntimeException) e; } - throw (IllegalStateException)new IllegalStateException (e.getMessage(), e); + throw new IllegalStateException (e.getMessage(), e); } } diff --git a/core/src/main/java/org/apache/commons/jelly/expression/xpath/XPathExpression.java b/core/src/main/java/org/apache/commons/jelly/expression/xpath/XPathExpression.java index 0440a6113..8bba90978 100644 --- a/core/src/main/java/org/apache/commons/jelly/expression/xpath/XPathExpression.java +++ b/core/src/main/java/org/apache/commons/jelly/expression/xpath/XPathExpression.java @@ -95,13 +95,8 @@ public Object evaluate(final JellyContext context) { } catch (final JaxenException e) { - if (!context.isSuppressExpressionExceptions()) { - throw (IllegalStateException)new IllegalStateException (e.getMessage(), e); - } - log.error("Error constructing xpath", e); + throw new IllegalStateException (e.getMessage(), e); } - - return null; } // Expression interface diff --git a/core/src/main/java/org/apache/commons/jelly/impl/Embedded.java b/core/src/main/java/org/apache/commons/jelly/impl/Embedded.java index 00d28e43d..8e85db69a 100644 --- a/core/src/main/java/org/apache/commons/jelly/impl/Embedded.java +++ b/core/src/main/java/org/apache/commons/jelly/impl/Embedded.java @@ -69,7 +69,7 @@ public class Embedded { private OutputStream outputStream; /** Output(default System.out) */ private XMLOutput output = - XMLOutput.createXMLOutput(new OutputStreamWriter(System.out)); + XMLOutput.createXMLOutput(new OutputStreamWriter(System.out)); /** Exception thrown during compilation of script*/ Exception scriptCompilationException; /** Boolean value indicating whether the script has been successfully compiled or NOT */ @@ -185,7 +185,7 @@ public void registerTagLibrary(final String namespaceURI, final TagLibrary tagli private URL resolveURL(final String name) throws MalformedURLException { final File file = new File(name); if (file.exists()) { - return file.toURL(); + return file.toURI().toURL(); } return new URL(name); } diff --git a/core/src/main/java/org/apache/commons/jelly/parser/XMLParser.java b/core/src/main/java/org/apache/commons/jelly/parser/XMLParser.java index 4027e1c67..8e35458f8 100644 --- a/core/src/main/java/org/apache/commons/jelly/parser/XMLParser.java +++ b/core/src/main/java/org/apache/commons/jelly/parser/XMLParser.java @@ -236,9 +236,8 @@ protected void addExpressionScript(final ScriptBlock script, final Expression ex final CompositeExpression compositeExpression = (CompositeExpression) expression; - final Iterator iter = compositeExpression.getExpressions().iterator(); - while (iter.hasNext()) { - addExpressionScript( newBlock, (Expression) iter.next() ); + for (Object o : compositeExpression.getExpressions()) { + addExpressionScript(newBlock, (Expression) o); } } else { @@ -942,7 +941,7 @@ public void notationDecl(final String name, final String publicId, final String * @throws SAXException if a parsing exception occurs */ public Script parse(final File file) throws IOException, SAXException { - return parse(file.toURL()); + return parse(file.toURI().toURL()); } /** diff --git a/core/src/main/java/org/apache/commons/jelly/util/CommandLineParser.java b/core/src/main/java/org/apache/commons/jelly/util/CommandLineParser.java index a7b586f39..2b16cdc8c 100644 --- a/core/src/main/java/org/apache/commons/jelly/util/CommandLineParser.java +++ b/core/src/main/java/org/apache/commons/jelly/util/CommandLineParser.java @@ -29,7 +29,7 @@ import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; -import org.apache.commons.cli.Parser; +import org.apache.commons.cli.DefaultParser; import org.apache.commons.jelly.Jelly; import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.JellyException; @@ -199,7 +199,7 @@ public CommandLine parseCommandLineOptions(final String[] args) throws ParseExce filteredArgList.toArray(filterArgs); // parse the command line - final Parser parser = new org.apache.commons.cli.GnuParser(); + final DefaultParser parser = new DefaultParser(); return parser.parse(cmdLineOptions, filterArgs); } diff --git a/core/src/main/java/org/apache/commons/jelly/xpath/XPathComparator.java b/core/src/main/java/org/apache/commons/jelly/xpath/XPathComparator.java index 4759476df..b7eb96989 100644 --- a/core/src/main/java/org/apache/commons/jelly/xpath/XPathComparator.java +++ b/core/src/main/java/org/apache/commons/jelly/xpath/XPathComparator.java @@ -19,7 +19,6 @@ import java.util.Comparator; import java.util.List; -import org.apache.commons.jelly.util.NestedRuntimeException; import org.dom4j.Node; import org.jaxen.JaxenException; import org.jaxen.XPath; @@ -34,7 +33,7 @@ public class XPathComparator implements Comparator { /** * My own runtime exception in case something goes wrong with sort. */ - public static class XPathSortException extends NestedRuntimeException { + public static class XPathSortException extends RuntimeException { public XPathSortException(final String message, final Throwable cause) { super(message, cause); } diff --git a/jelly-tags/ant/src/main/java/org/apache/commons/jelly/task/JellyTask.java b/jelly-tags/ant/src/main/java/org/apache/commons/jelly/task/JellyTask.java index 5e1306ee9..1a7b1ad32 100644 --- a/jelly-tags/ant/src/main/java/org/apache/commons/jelly/task/JellyTask.java +++ b/jelly-tags/ant/src/main/java/org/apache/commons/jelly/task/JellyTask.java @@ -135,7 +135,7 @@ public JellyContext getJellyContext() throws MalformedURLException { */ public URL getRootContext() throws MalformedURLException { if (rootContext == null) { - rootContext = new File(SystemProperties.getUserDir()).toURL(); + rootContext = new File(SystemProperties.getUserDir()).toURI().toURL(); } return rootContext; } @@ -157,7 +157,7 @@ public XMLOutput getXMLOutput() throws IOException { protected URL resolveURL(final String name) throws MalformedURLException { final File file = getProject().resolveFile(name); if (file.exists()) { - return file.toURL(); + return file.toURI().toURL(); } return new URL(name); } @@ -166,7 +166,7 @@ protected URL resolveURL(final String name) throws MalformedURLException { * Sets the script file to use */ public void setFile(final File file) throws MalformedURLException { - setUrl( file.toURL() ); + setUrl( file.toURI().toURL() ); } /** diff --git a/jelly-tags/avalon/src/main/java/org/apache/commons/jelly/avalon/JellyServiceImpl.java b/jelly-tags/avalon/src/main/java/org/apache/commons/jelly/avalon/JellyServiceImpl.java index 46d51dddd..a50b91b49 100644 --- a/jelly-tags/avalon/src/main/java/org/apache/commons/jelly/avalon/JellyServiceImpl.java +++ b/jelly-tags/avalon/src/main/java/org/apache/commons/jelly/avalon/JellyServiceImpl.java @@ -95,7 +95,7 @@ public void configure( final Configuration config ) throws ConfigurationExceptio URL url = null; final File file = new File( scriptName ); if ( file.exists() ) { - url = file.toURL(); + url = file.toURI().toURL(); } else { try { diff --git a/jelly-tags/betwixt/src/main/java/org/apache/commons/jelly/tags/betwixt/IntrospectorTag.java b/jelly-tags/betwixt/src/main/java/org/apache/commons/jelly/tags/betwixt/IntrospectorTag.java index cb2667667..654762351 100644 --- a/jelly-tags/betwixt/src/main/java/org/apache/commons/jelly/tags/betwixt/IntrospectorTag.java +++ b/jelly-tags/betwixt/src/main/java/org/apache/commons/jelly/tags/betwixt/IntrospectorTag.java @@ -159,7 +159,7 @@ public XMLIntrospector getIntrospector() { * as aliases to the common name mapping strategies or specify a class name String. */ public void setAttributeNameMapper(final NameMapper nameMapper) { - getIntrospector().setAttributeNameMapper(nameMapper); + getIntrospector().getConfiguration().setAttributeNameMapper(nameMapper); } /** @@ -167,7 +167,7 @@ public void setAttributeNameMapper(final NameMapper nameMapper) { * The default is false. */ public void setAttributesForPrimitives(final boolean attributesForPrimitives) { - getIntrospector().setAttributesForPrimitives(attributesForPrimitives); + getIntrospector().getConfiguration().setAttributesForPrimitives(attributesForPrimitives); } // Implementation methods @@ -179,7 +179,7 @@ public void setAttributesForPrimitives(final boolean attributesForPrimitives) { * as aliases to the common name mapping strategies or specify a class name String. */ public void setElementNameMapper(final NameMapper nameMapper) { - getIntrospector().setElementNameMapper(nameMapper); + getIntrospector().getConfiguration().setElementNameMapper(nameMapper); } /** diff --git a/jelly-tags/http/src/main/java/org/apache/commons/jelly/tags/http/BodyTag.java b/jelly-tags/http/src/main/java/org/apache/commons/jelly/tags/http/BodyTag.java index 6446449ec..312a4352f 100644 --- a/jelly-tags/http/src/main/java/org/apache/commons/jelly/tags/http/BodyTag.java +++ b/jelly-tags/http/src/main/java/org/apache/commons/jelly/tags/http/BodyTag.java @@ -22,6 +22,7 @@ import org.apache.commons.httpclient.HttpMethod; import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.httpclient.methods.PutMethod; +import org.apache.commons.httpclient.methods.StringRequestEntity; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; @@ -58,10 +59,10 @@ public void doTag(final XMLOutput xmlOutput) throws JellyTagException { final String bodyText = getBodyText(); if (httpMethod instanceof PostMethod) { final PostMethod postMethod = (PostMethod) httpMethod; - postMethod.setRequestBody(bodyText); + postMethod.setRequestEntity(new StringRequestEntity(bodyText)); } else if (httpMethod instanceof PutMethod) { final PutMethod putMethod = (PutMethod) httpMethod; - putMethod.setRequestBody(bodyText); + putMethod.setRequestEntity(new StringRequestEntity(bodyText)); } else { throw new IllegalStateException("Http method from parent was " + "not post or put"); diff --git a/jelly-tags/http/src/main/java/org/apache/commons/jelly/tags/http/HttpTagSupport.java b/jelly-tags/http/src/main/java/org/apache/commons/jelly/tags/http/HttpTagSupport.java index 7260156d5..645a7f6fe 100644 --- a/jelly-tags/http/src/main/java/org/apache/commons/jelly/tags/http/HttpTagSupport.java +++ b/jelly-tags/http/src/main/java/org/apache/commons/jelly/tags/http/HttpTagSupport.java @@ -25,6 +25,7 @@ import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpMethod; import org.apache.commons.httpclient.NameValuePair; +import org.apache.commons.httpclient.params.*; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; @@ -164,13 +165,26 @@ private HttpClient getHttpClient() { HttpClient client = null; if (session != null) { client = session.getHttpClient(); - client.setStrictMode(session.isStrictMode()); + client.setParams(getClientParams()); } else { client = new HttpClient(); } return client; } + /** + * Get the default parameters for the HttpClient to make it behave + * similar to Strict-Mode + * + * @return a HttpClientParams object with the strict parameters set + */ + private HttpClientParams getClientParams() { + HttpClientParams clientParams = new HttpClientParams(); + clientParams.setParameters(new String[]{HttpClientParams.REJECT_RELATIVE_REDIRECT, HttpClientParams.ALLOW_CIRCULAR_REDIRECTS, HttpMethodParams.UNAMBIGUOUS_STATUS_LINE, HttpMethodParams.SINGLE_COOKIE_HEADER, HttpMethodParams.STRICT_TRANSFER_ENCODING, HttpMethodParams.REJECT_HEAD_BODY, HttpMethodParams.WARN_EXTRA_INPUT}, Boolean.TRUE); + clientParams.setIntParameter(HttpMethodParams.STATUS_LINE_GARBAGE_LIMIT, 0); + return clientParams; + } + /** * A method that must be implemented by subclasses to provide the * {@link HttpMethod url method} implementation diff --git a/jelly-tags/http/src/main/java/org/apache/commons/jelly/tags/http/MultipartPostTag.java b/jelly-tags/http/src/main/java/org/apache/commons/jelly/tags/http/MultipartPostTag.java index 81dfac5d5..e32458c66 100644 --- a/jelly-tags/http/src/main/java/org/apache/commons/jelly/tags/http/MultipartPostTag.java +++ b/jelly-tags/http/src/main/java/org/apache/commons/jelly/tags/http/MultipartPostTag.java @@ -22,7 +22,8 @@ import java.util.List; import org.apache.commons.httpclient.HttpMethod; -import org.apache.commons.httpclient.methods.MultipartPostMethod; +import org.apache.commons.httpclient.methods.PostMethod; +import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity; import org.apache.commons.httpclient.methods.multipart.Part; /** @@ -42,15 +43,12 @@ */ public class MultipartPostTag extends PostTag { - /** The post method */ - private MultipartPostMethod _postMethod; - /** List of parts as name value pairs */ - private final List _parts; + private final List _parts; /** Creates a new instance of MppostTag */ public MultipartPostTag() { - _parts = new ArrayList(); + _parts = new ArrayList<>(); } /** @@ -71,10 +69,7 @@ public void addPart(final Part part) { */ @Override protected HttpMethod getHttpMethod() throws MalformedURLException { - if (_postMethod == null) { - _postMethod = new MultipartPostMethod(getResolvedUrl()); - } - return _postMethod; + return super.getHttpMethod(); } /** @@ -86,8 +81,21 @@ protected HttpMethod getHttpMethod() throws MalformedURLException { */ @Override protected void setParameters(final HttpMethod method) { - for (final Object _part : _parts) { - ((MultipartPostMethod) method).addPart( (Part) _part ); + try { + ((PostMethod)getHttpMethod()).setRequestEntity(getMultipartRequestEntity(method)); + } catch (MalformedURLException e){ + throw new RuntimeException("Invalid url.", e); } } + + /** + * Gets the multipart request entity. + * + * @return the multipart request entity + */ + private MultipartRequestEntity getMultipartRequestEntity(final HttpMethod method) { + return new MultipartRequestEntity(_parts.toArray(new Part[0]), method.getParams()); + } + } + diff --git a/jelly-tags/jsl/src/main/java/org/apache/commons/jelly/tags/jsl/ApplyTemplatesTag.java b/jelly-tags/jsl/src/main/java/org/apache/commons/jelly/tags/jsl/ApplyTemplatesTag.java index 929bd7666..3b9684a47 100644 --- a/jelly-tags/jsl/src/main/java/org/apache/commons/jelly/tags/jsl/ApplyTemplatesTag.java +++ b/jelly-tags/jsl/src/main/java/org/apache/commons/jelly/tags/jsl/ApplyTemplatesTag.java @@ -22,7 +22,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dom4j.rule.Stylesheet; -import org.jaxen.XPath; +import org.dom4j.XPath; /** * Implements the apply templates function in the stylesheet, similar to the XSLT equivalent. diff --git a/jelly-tags/swing/src/test/java/org/apache/commons/jelly/demos/HomepageBuilder.java b/jelly-tags/swing/src/test/java/org/apache/commons/jelly/demos/HomepageBuilder.java index 5592e17c2..68d65e23c 100644 --- a/jelly-tags/swing/src/test/java/org/apache/commons/jelly/demos/HomepageBuilder.java +++ b/jelly-tags/swing/src/test/java/org/apache/commons/jelly/demos/HomepageBuilder.java @@ -183,7 +183,7 @@ public void buildPage(final String template, final JellyContext ctx) { protected URL resolveURL(final String name) throws MalformedURLException { final File file = new File(name); if (file.exists()) { - return file.toURL(); + return file.toURI().toURL(); } return new URL(name); } diff --git a/jelly-tags/threads/src/main/java/org/apache/commons/jelly/tags/threads/ThreadTag.java b/jelly-tags/threads/src/main/java/org/apache/commons/jelly/tags/threads/ThreadTag.java index 95bdeb93b..58c3287ec 100644 --- a/jelly-tags/threads/src/main/java/org/apache/commons/jelly/tags/threads/ThreadTag.java +++ b/jelly-tags/threads/src/main/java/org/apache/commons/jelly/tags/threads/ThreadTag.java @@ -24,7 +24,6 @@ import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; -import org.apache.commons.jelly.util.NestedRuntimeException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -106,16 +105,11 @@ public void doTag(final XMLOutput output) throws JellyTagException { log.error(e); // wrap the exception with a RuntimeException - throw new NestedRuntimeException(e); + throw new RuntimeException(e); } catch (final Exception e) { log.error(e); - - // wrap the exception with a RuntimeException - if (e instanceof RuntimeException) { - throw (RuntimeException) e; - } - throw new NestedRuntimeException(e); + throw new RuntimeException(e); } }); diff --git a/jelly-tags/xml/src/main/java/org/apache/commons/jelly/tags/xml/TransformTag.java b/jelly-tags/xml/src/main/java/org/apache/commons/jelly/tags/xml/TransformTag.java index 990692d26..8c984f067 100644 --- a/jelly-tags/xml/src/main/java/org/apache/commons/jelly/tags/xml/TransformTag.java +++ b/jelly-tags/xml/src/main/java/org/apache/commons/jelly/tags/xml/TransformTag.java @@ -595,7 +595,7 @@ else if (sourceObj instanceof URL) { } else if (sourceObj instanceof File) { try { - final String uri = ((File) sourceObj).toURL().toString(); + final String uri = ((File) sourceObj).toURI().toURL().toString(); xmlInputSource = new InputSource(context.getResourceAsStream(uri)); } catch (final MalformedURLException e) { diff --git a/jelly-tags/xml/src/test/java/org/apache/commons/jelly/tags/xml/TestXMLTags.java b/jelly-tags/xml/src/test/java/org/apache/commons/jelly/tags/xml/TestXMLTags.java index e404a2db0..a56e02937 100644 --- a/jelly-tags/xml/src/test/java/org/apache/commons/jelly/tags/xml/TestXMLTags.java +++ b/jelly-tags/xml/src/test/java/org/apache/commons/jelly/tags/xml/TestXMLTags.java @@ -145,7 +145,7 @@ protected String evaluateScriptAsText(final String fileName, final Map ctxVars) // allow scripts to refer to any resource inside this project // using an absolute URI like /src/test/org/apache/foo.xml - context.setRootURL(new File(".").toURL()); + context.setRootURL(new File(".").toURI().toURL()); // capture the output final StringWriter buffer = new StringWriter(); @@ -188,7 +188,7 @@ protected String evaluateScriptAsTextUsingSaxContentHandler(final String fileNam // allow scripts to refer to any resource inside this project // using an absolute URI like /src/test/org/apache/foo.xml - context.setRootURL(new File(".").toURL()); + context.setRootURL(new File(".").toURI().toURL()); output.startDocument(); context.runScript(new File(fileName), output); @@ -228,9 +228,9 @@ public void runUnitTest(final String name) throws Exception { final Document document = parseUnitTest(name); final List failures = document.selectNodes( "/*/fail" ); - for ( final Iterator iter = failures.iterator(); iter.hasNext(); ) { - final Node node = (Node) iter.next(); - fail( node.getStringValue() ); + for (Object failure : failures) { + final Node node = (Node) failure; + fail(node.getStringValue()); } }