TraxLiaisonTest. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271796 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -131,7 +131,7 @@ | |||||
| unless="jdk1.2+" /> | unless="jdk1.2+" /> | ||||
| <!-- uses the context classloader --> | <!-- uses the context classloader --> | ||||
| <exclude name="${optional.package}/junit/JUnitClassLoaderTest.java" | <exclude name="${optional.package}/junit/JUnitClassLoaderTest.java" | ||||
| /> | |||||
| unless="jdk1.2+" /> | |||||
| </patternset> | </patternset> | ||||
| <patternset id="needs.jdk1.3+"> | <patternset id="needs.jdk1.3+"> | ||||
| <exclude name="${ant.package}/taskdefs/TestProcess.java" | <exclude name="${ant.package}/taskdefs/TestProcess.java" | ||||
| @@ -402,7 +402,12 @@ public class AntClassLoader extends ClassLoader implements BuildListener { | |||||
| try { | try { | ||||
| savedContextLoader | savedContextLoader | ||||
| = (ClassLoader)getContextClassLoader.invoke(Thread.currentThread(), new Object[0]); | = (ClassLoader)getContextClassLoader.invoke(Thread.currentThread(), new Object[0]); | ||||
| Object[] args = new Object[] {this}; | |||||
| Object[] args = null; | |||||
| if ("only".equals(project.getProperty("build.sysclasspath"))) { | |||||
| args = new Object[] {this.getClass().getClassLoader()}; | |||||
| } else { | |||||
| args = new Object[] {this}; | |||||
| } | |||||
| setContextClassLoader.invoke(Thread.currentThread(), args); | setContextClassLoader.invoke(Thread.currentThread(), args); | ||||
| isContextLoaderSaved = true; | isContextLoaderSaved = true; | ||||
| } | } | ||||
| @@ -226,6 +226,10 @@ public class TraXLiaison implements XSLTLiaison, ErrorListener, XSLTLoggerAware | |||||
| } | } | ||||
| private void logError(TransformerException e, String type) { | private void logError(TransformerException e, String type) { | ||||
| if (logger == null) { | |||||
| return; | |||||
| } | |||||
| StringBuffer msg = new StringBuffer(); | StringBuffer msg = new StringBuffer(); | ||||
| if(e.getLocator() != null) { | if(e.getLocator() != null) { | ||||
| if(e.getLocator().getSystemId() != null) { | if(e.getLocator().getSystemId() != null) { | ||||
| @@ -642,7 +642,7 @@ public class JUnitTask extends Task { | |||||
| cl.addSystemPackageRoot("junit"); | cl.addSystemPackageRoot("junit"); | ||||
| // will cause trouble in JDK 1.1 if omitted | // will cause trouble in JDK 1.1 if omitted | ||||
| cl.addSystemPackageRoot("org.apache.tools.ant"); | cl.addSystemPackageRoot("org.apache.tools.ant"); | ||||
| //cl.setThreadContextLoader(); | |||||
| cl.setThreadContextLoader(); | |||||
| } | } | ||||
| runner = new JUnitTestRunner(test, test.getHaltonerror(), test.getFiltertrace(), test.getHaltonfailure(), cl); | runner = new JUnitTestRunner(test, test.getHaltonerror(), test.getFiltertrace(), test.getHaltonfailure(), cl); | ||||
| if (summary) { | if (summary) { | ||||
| @@ -673,7 +673,7 @@ public class JUnitTask extends Task { | |||||
| if (sysProperties != null) { | if (sysProperties != null) { | ||||
| sysProperties.restoreSystem(); | sysProperties.restoreSystem(); | ||||
| } | } | ||||
| //cl.resetThreadContextLoader(); | |||||
| cl.resetThreadContextLoader(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,11 +1,14 @@ | |||||
| package org.apache.tools.ant.taskdefs.optional; | package org.apache.tools.ant.taskdefs.optional; | ||||
| import org.apache.tools.ant.taskdefs.XSLTLiaison; | import org.apache.tools.ant.taskdefs.XSLTLiaison; | ||||
| import org.apache.tools.ant.taskdefs.XSLTLogger; | |||||
| import org.apache.tools.ant.taskdefs.condition.Os; | import org.apache.tools.ant.taskdefs.condition.Os; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import java.io.File; | import java.io.File; | ||||
| import junit.framework.AssertionFailedError; | |||||
| /* | /* | ||||
| * The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
| * | * | ||||
| @@ -65,7 +68,9 @@ import java.io.File; | |||||
| * TraX XSLTLiaison testcase | * TraX XSLTLiaison testcase | ||||
| * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a> | * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a> | ||||
| */ | */ | ||||
| public class TraXLiaisonTest extends AbstractXSLTLiaisonTest { | |||||
| public class TraXLiaisonTest extends AbstractXSLTLiaisonTest | |||||
| implements XSLTLogger { | |||||
| public TraXLiaisonTest(String name){ | public TraXLiaisonTest(String name){ | ||||
| super(name); | super(name); | ||||
| } | } | ||||
| @@ -78,7 +83,9 @@ public class TraXLiaisonTest extends AbstractXSLTLiaisonTest { | |||||
| } | } | ||||
| public XSLTLiaison createLiaison() throws Exception { | public XSLTLiaison createLiaison() throws Exception { | ||||
| return new TraXLiaison(); | |||||
| TraXLiaison l = new TraXLiaison(); | |||||
| l.setLogger(this); | |||||
| return l; | |||||
| } | } | ||||
| public void testXalan2Redirect() throws Exception { | public void testXalan2Redirect() throws Exception { | ||||
| @@ -124,4 +131,8 @@ public class TraXLiaisonTest extends AbstractXSLTLiaisonTest { | |||||
| assertTrue("SystemIDs should not start with file:////", !systemid.startsWith("file:////")); | assertTrue("SystemIDs should not start with file:////", !systemid.startsWith("file:////")); | ||||
| } | } | ||||
| public void log(String message) { | |||||
| throw new AssertionFailedError("Liaison sent message: "+message); | |||||
| } | |||||
| } | } | ||||