com.splunk.modularinput
Class ModularInputTestCase

java.lang.Object
  extended by com.splunk.modularinput.ModularInputTestCase
Direct Known Subclasses:
EventTest, InputDefinitionTest, SchemeTest, ScriptTest, ValidationDefinitionTest

public class ModularInputTestCase
extends java.lang.Object


Constructor Summary
ModularInputTestCase()
           
 
Method Summary
 void assertXmlEqual(org.w3c.dom.Document expected, org.w3c.dom.Document found)
          Assert whether two org.w3c.dom.Document objects contain identical XML, ignoring whitespace.
 void assertXmlEqual(org.w3c.dom.Node expected, org.w3c.dom.Node found)
          Assert whether two org.w3c.dom.Node objects contain identical XML, ignoring whitespace.
 java.lang.String nodeToXml(org.w3c.dom.Node node)
          Transform the given org.w3c.dom.Node object into a String containing the corresponding XML.
static void removeBlankTextNodes(org.w3c.dom.Element node)
          XML parsing may introduce text nodes containing only white space between elements.
 org.w3c.dom.Document resourceToXmlDocument(java.lang.String path)
          Open a resource from the Splunk SDK for Java project and parse it into an org.w3c.dom.Document object.
 org.w3c.dom.Document stringToXmlDocument(java.lang.String xml)
          Parse XML in a string into an org.w3c.dom.Document object.
 void testCoercionMethods()
          Test the methods on SingleValueParameter to coerce its value to a boolean or various kinds of numbers.
 void testNormalizeBoolean()
          Tries the known cases supported by XmlUtil.normalizeBoolean, and asserts that it throws an error when passed an unknown case.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModularInputTestCase

public ModularInputTestCase()
Method Detail

removeBlankTextNodes

public static void removeBlankTextNodes(org.w3c.dom.Element node)
XML parsing may introduce text nodes containing only white space between elements. These are purely formatting in our case, so we want to eliminate them.

Parameters:
node - a org.w3c.dom.Node object containing XML.

assertXmlEqual

public void assertXmlEqual(org.w3c.dom.Node expected,
                           org.w3c.dom.Node found)
                    throws javax.xml.transform.TransformerException,
                           javax.xml.parsers.ParserConfigurationException
Assert whether two org.w3c.dom.Node objects contain identical XML, ignoring whitespace. If they do not match, assertXmlEqual will recursively descend through the element tree to find where they do not match.

Parameters:
expected - an org.w3c.dom.Node object containing the expected XML document.
found - an org.w3c.dom.Node object containing the XML document actually produced.
Throws:
javax.xml.transform.TransformerException
javax.xml.parsers.ParserConfigurationException

assertXmlEqual

public void assertXmlEqual(org.w3c.dom.Document expected,
                           org.w3c.dom.Document found)
                    throws javax.xml.transform.TransformerException,
                           javax.xml.parsers.ParserConfigurationException
Assert whether two org.w3c.dom.Document objects contain identical XML, ignoring whitespace. If they do not match, assertXmlEqual will recursively descend through the element tree to find where they do not match.

Parameters:
expected - an org.w3c.dom.Document object containing the expected XML document.
found - an org.w3c.dom.Document object containing the XML document actually produced.
Throws:
javax.xml.transform.TransformerException
javax.xml.parsers.ParserConfigurationException

resourceToXmlDocument

public org.w3c.dom.Document resourceToXmlDocument(java.lang.String path)
Open a resource from the Splunk SDK for Java project and parse it into an org.w3c.dom.Document object.

Parameters:
path - a path relative to the test directory of the SDK.
Returns:
an org.w3c.dom.Document object containing the parsed XML.

stringToXmlDocument

public org.w3c.dom.Document stringToXmlDocument(java.lang.String xml)
Parse XML in a string into an org.w3c.dom.Document object.

Parameters:
xml - a String containing XML.
Returns:
an org.w3c.dom.Document object.

nodeToXml

public java.lang.String nodeToXml(org.w3c.dom.Node node)
                           throws javax.xml.transform.TransformerException,
                                  javax.xml.parsers.ParserConfigurationException
Transform the given org.w3c.dom.Node object into a String containing the corresponding XML. This function is primarily for showing sensible error messages.

Parameters:
node - the org.w3c.dom.Node object to serialize.
Returns:
a String containing generated XML.
Throws:
javax.xml.transform.TransformerException
javax.xml.parsers.ParserConfigurationException

testNormalizeBoolean

public void testNormalizeBoolean()
                          throws MalformedDataException
Tries the known cases supported by XmlUtil.normalizeBoolean, and asserts that it throws an error when passed an unknown case.

Throws:
MalformedDataException

testCoercionMethods

public void testCoercionMethods()
                         throws MalformedDataException
Test the methods on SingleValueParameter to coerce its value to a boolean or various kinds of numbers.

Throws:
MalformedDataException