Package ghidra.util.xml
Class XmlTestHelper
- java.lang.Object
-
- ghidra.util.xml.XmlTestHelper
-
public class XmlTestHelper extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description XmlTestHelper(java.lang.String tmpDirPath)
XmlTestHelper(java.lang.String tmpDirPath, GhidraProject gp)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(java.lang.String xml)
static void
assertXMLFilesEquals(XmlPullParser expectedXMLParser, XmlPullParser testXMLParser)
Compares 2 xml files and fails if there is any difference between the two.static void
assertXMLFilesEquals(java.io.File expectedXMLFile, java.io.File testXMLFile)
void
clearXml()
void
compareXml(java.io.File file)
boolean
containsXml(java.lang.String line)
Return true if the given line is in the the xml list.void
dispose()
GhidraProject
getProject()
java.io.File
getTempFile(java.lang.String name)
XmlPullParser
getXmlParser(java.lang.String name)
Program
loadResourceProgram(java.lang.String programName)
void
loadXmlResource(java.lang.Package pkg, java.lang.String name)
Read an XML file as a resource.void
printExpectedLines()
-
-
-
Constructor Detail
-
XmlTestHelper
public XmlTestHelper(java.lang.String tmpDirPath, GhidraProject gp) throws java.lang.Exception
- Throws:
java.lang.Exception
-
XmlTestHelper
public XmlTestHelper(java.lang.String tmpDirPath) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-
Method Detail
-
dispose
public void dispose()
-
add
public void add(java.lang.String xml)
-
loadXmlResource
public void loadXmlResource(java.lang.Package pkg, java.lang.String name) throws java.io.IOException
Read an XML file as a resource.- Parameters:
package
- where resource residesname
- name of the resource that is in the given package- Throws:
java.io.IOException
-
getTempFile
public java.io.File getTempFile(java.lang.String name)
-
getProject
public GhidraProject getProject()
-
compareXml
public void compareXml(java.io.File file) throws java.lang.Exception
- Throws:
java.lang.Exception
-
containsXml
public boolean containsXml(java.lang.String line)
Return true if the given line is in the the xml list.
-
printExpectedLines
public void printExpectedLines()
-
getXmlParser
public XmlPullParser getXmlParser(java.lang.String name) throws java.io.IOException, org.xml.sax.SAXException
- Throws:
java.io.IOException
org.xml.sax.SAXException
-
clearXml
public void clearXml()
-
loadResourceProgram
public Program loadResourceProgram(java.lang.String programName) throws java.io.IOException, CancelledException, DuplicateNameException, InvalidNameException, VersionException
- Parameters:
string
-- Returns:
- Throws:
VersionException
InvalidNameException
DuplicateNameException
CancelledException
java.io.IOException
-
assertXMLFilesEquals
public static void assertXMLFilesEquals(java.io.File expectedXMLFile, java.io.File testXMLFile) throws org.xml.sax.SAXException, java.io.IOException
- Parameters:
expectedXMLFile
-testXMLFile
-- Throws:
org.xml.sax.SAXException
java.io.IOException
-
assertXMLFilesEquals
public static void assertXMLFilesEquals(XmlPullParser expectedXMLParser, XmlPullParser testXMLParser) throws org.xml.sax.SAXException, java.io.IOException
Compares 2 xml files and fails if there is any difference between the two.Elements must be ordered in the same order. Attribute values are not order sensitive.
Inter-node whitespace differences are ignored.
DTD definitions are ignored.
- Parameters:
expectedXMLParser
-testXMLParser
-- Throws:
org.xml.sax.SAXException
java.io.IOException
-
-