Skip to content

Commit

Permalink
Add support for https testng DTD namespace (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
pgilad authored Mar 12, 2021
1 parent 2f9a2d2 commit 19d9123
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/main/java/hudson/tasks/junit/XMLEntityResolver.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/*
* The MIT License
*
*
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Jorg Heymans
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -23,6 +23,7 @@
*/
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;
Expand All @@ -46,7 +47,8 @@
*/
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
Expand All @@ -57,9 +59,9 @@ public InputSource resolveEntity(String publicId, String systemId) throws SAXExc
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)
Expand Down

0 comments on commit 19d9123

Please sign in to comment.