Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TestNG XML not valid

Tags:

java

xml

dtd

testng

I have some generated TestNG XMLs that worked for a long time, but recently they are invalid when I run them through Java's SAXParser and through http://www.xmlvalidation.com/

Example generated XML:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite thread-count="1" verbose="2" name="TestNG Forum" parallel="tests">
  <test name="TestNG Test0" preserve-order="false">
    <parameter name="device" value="58f56054954b6b3e323a3405fc49023eb1569a98"/>
    <packages>
      <package name="output"/>
    </packages>
  </test> <!-- TestNG Test0 -->
</suite> <!-- TestNG Forum -->

Example XML from TestNG's site @ http://testng.org/doc/documentation-main.html

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="Suite1" verbose="1" >
  <test name="Nopackage" >
    <classes>
       <class name="NoPackageTest" />
    </classes>
  </test>

  <test name="Regression1">
    <classes>
      <class name="test.sample.ParameterSample"/>
      <class name="test.sample.ParameterTest"/>
    </classes>
  </test>
</suite>

Why did these XMLs suddenly stop being valid? Is it an error in the dtd hosted by testng? Did the dtd suddenly change?

EDIT: XML parsing error:

1:  3   The markup declarations contained or pointed to by the document type declaration must be well-formed.
like image 397
Bruce Tu Avatar asked Mar 22 '26 16:03

Bruce Tu


1 Answers

We investigated with the team and right now, our suspicion is that the XML parser is not honoring 301 redirects.

I just removed the redirection and restored the file at http://testng.org/testng-1.0.dtd, can you try again?

If this works, I'd be curious to find out why your application is fetching this DTD from the network instead of using the one shipped inside TestNG's jar file, but we can discuss that in a separate issue.

like image 197
Cedric Beust Avatar answered Mar 24 '26 05:03

Cedric Beust