Add support for https testng DTD namespace
*/
package hudson.tasks.junit;
+import org.apache.commons.lang.StringUtils;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -46,7 +47,8 @@ import java.util.logging.Logger;
*/
public class XMLEntityResolver implements EntityResolver {
- private static final String TESTNG_NAMESPACE = "http://testng.org/";
+ private static final String TESTNG_HTTP_NAMESPACE = "http://testng.org/";
+ private static final String TESTNG_HTTPS_NAMESPACE = "https://testng.org/";
/**
* Intercepts the lookup of publicId, systemId
@@ -57,9 +59,9 @@ public class XMLEntityResolver implements EntityResolver {
LOGGER.fine("Will try to resolve systemId [" + systemId + "]");
}
// TestNG system-ids
- if (systemId.startsWith(TESTNG_NAMESPACE)) {
+ if (systemId.startsWith(TESTNG_HTTP_NAMESPACE) || systemId.startsWith(TESTNG_HTTPS_NAMESPACE)) {
LOGGER.fine("It's a TestNG document, will try to lookup DTD in classpath");
- String dtdFileName = systemId.substring(TESTNG_NAMESPACE.length());
+ String dtdFileName = StringUtils.substringAfterLast(systemId, "/");
URL url = getClass().getClassLoader().getResource(dtdFileName);
if (url != null)
