public class DomAsserts extends Object
junit.framework.Assert
).
As with the standard JUnit assertions, there are two forms for each method: one that takes an explanatory message, and one that doesn't.
Constructor and Description |
---|
DomAsserts() |
Modifier and Type | Method and Description |
---|---|
static void |
assertCount(int expected,
Node node,
String xpath)
Asserts that the specified XPath selects a specified number of nodes.
|
static void |
assertCount(int expected,
Node node,
XPathWrapper xpath)
Asserts that the specified XPath selects a specified number of nodes.
|
static void |
assertCount(String message,
int expected,
Node node,
String xpath)
Asserts that the specified XPath selects a specified number of nodes.
|
static void |
assertCount(String message,
int expected,
Node node,
XPathWrapper xpath)
Asserts that the specified XPath selects a specified number of nodes.
|
static void |
assertEquals(String expected,
Node node,
String xpath)
Asserts that the specified XPath selects a particular String value.
|
static void |
assertEquals(String expected,
Node node,
XPathWrapper xpath)
Asserts that the specified XPath selects a particular String value.
|
static void |
assertEquals(String message,
String expected,
Node node,
String xpath)
Asserts that the specified XPath selects a particular String value.
|
static void |
assertEquals(String message,
String expected,
Node node,
XPathWrapper xpath)
Asserts that the specified XPath selects a particular String value.
|
static void |
assertExists(Node node,
String xpath)
Asserts that the specified XPath selects at least one node.
|
static void |
assertExists(Node node,
XPathWrapper xpath)
Asserts that the specified XPath selects at least one node.
|
static void |
assertExists(String message,
Node node,
String xpath)
Asserts that the specified XPath selects at least one node, using
the specified message if the assertion fails.
|
static void |
assertExists(String message,
Node node,
XPathWrapper xpath)
Asserts that the specified XPath selects at least one node.
|
static void |
assertName(String expected,
Element elem)
Asserts that an element has the given localname.
|
static void |
assertName(String message,
String expected,
Element elem)
Asserts that an element has the given localname.
|
static void |
assertNamespaceAndName(String expectedNSUri,
String expectedName,
Element elem)
Asserts that an element has the given local name and namespace URI.
|
static void |
assertNamespaceAndName(String message,
String expectedNSUri,
String expectedName,
Element elem)
Asserts that an element has the given local name and namespace URI.
|
static void |
assertNotExists(Node node,
String xpath)
Asserts that the specified XPath does not select any nodes.
|
static void |
assertNotExists(Node node,
XPathWrapper xpath)
Asserts that the specified XPath does not select any nodes.
|
static void |
assertNotExists(String message,
Node node,
String xpath)
Asserts that the specified XPath does not select any nodes, using
the specified message if the assertion fails.
|
static void |
assertNotExists(String message,
Node node,
XPathWrapper xpath)
Asserts that the specified XPath does not select any nodes.
|
public static void assertName(String expected, Element elem)
expected
- The expected name, sans prefix.elem
- The element on which to assert this name.public static void assertName(String message, String expected, Element elem)
message
- Message to display if assertion fails.expected
- The expected name, sans prefix.elem
- The element on which to assert this name.public static void assertNamespaceAndName(String expectedNSUri, String expectedName, Element elem)
If assertion fails, will display message indicating whether name or namespace was invalid.
expectedNSUri
- The expected namespace URI. May be null
to assert that the element does not
have a namespace.expectedName
- The expected name.elem
- The element on which to assert this name.public static void assertNamespaceAndName(String message, String expectedNSUri, String expectedName, Element elem)
message
- Message to display if assertion fails.expectedNSUri
- The expected namespace URI. May be null
to assert that the element does not
have a namespace.expectedName
- The expected name.elem
- The element on which to assert this name.public static void assertExists(Node node, String xpath)
node
- Initial context for expression evaluation.xpath
- Path expression to assert.public static void assertExists(String message, Node node, String xpath)
message
- Message to display if assertion fails.node
- Initial context for expression evaluation.xpath
- Path expression to assert.public static void assertExists(Node node, XPathWrapper xpath)
XPathWrapper
to allow complex
paths, including namespace bindings. Uses the path as a failed-
assertion message.node
- Initial context for expression evaluation.xpath
- Path expression to assert.public static void assertExists(String message, Node node, XPathWrapper xpath)
XPathWrapper
to allow complex
paths, including namespace bindings.message
- Message to display if assertion fails.node
- Initial context for expression evaluation.xpath
- Path expression to assert.public static void assertNotExists(Node node, String xpath)
node
- Initial context for expression evaluation.xpath
- Path expression to assert.public static void assertNotExists(String message, Node node, String xpath)
message
- Message to display if assertion fails.node
- Initial context for expression evaluation.xpath
- Path expression to assert.public static void assertNotExists(Node node, XPathWrapper xpath)
XPathWrapper
to allow complex
paths, including namespace bindings. Uses the path as a failed-
assertion message.node
- Initial context for expression evaluation.xpath
- Path expression to assert.public static void assertNotExists(String message, Node node, XPathWrapper xpath)
XPathWrapper
to allow complex
paths, including namespace bindings.message
- Message to display if assertion fails.node
- Initial context for expression evaluation.xpath
- Path expression to assert.public static void assertCount(int expected, Node node, String xpath)
expected
- The expected number of nodes selected.node
- Initial context for expression evaluation.xpath
- Path expression to assert.public static void assertCount(String message, int expected, Node node, String xpath)
message
- Message to display if assertion fails.expected
- The expected number of nodes selected.node
- Initial context for expression evaluation.xpath
- Path expression to assert.public static void assertCount(int expected, Node node, XPathWrapper xpath)
XPathWrapper
to allow complex
paths, including namespace bindings. Uses the path as a failed-assertion
message.expected
- The expected number of nodes selected.node
- Initial context for expression evaluation.xpath
- Path expression to assert.public static void assertCount(String message, int expected, Node node, XPathWrapper xpath)
XPathWrapper
to allow complex
paths, including namespace bindings.message
- Message to display if assertion fails.expected
- The expected number of nodes selected.node
- Initial context for expression evaluation.xpath
- Path expression to assert.public static void assertEquals(String expected, Node node, String xpath)
expected
- The expected value.node
- Initial context for expression evaluation.xpath
- Path expression to assert.public static void assertEquals(String message, String expected, Node node, String xpath)
message
- Message to display if assertion fails.expected
- The expected value.node
- Initial context for expression evaluation.xpath
- Path expression to assert.public static void assertEquals(String expected, Node node, XPathWrapper xpath)
XPathWrapper
to
allow complex paths, including namespace bindings. Uses the path as
a failed-assertion message.expected
- The expected value.node
- Initial context for expression evaluation.xpath
- Path expression to assert.public static void assertEquals(String message, String expected, Node node, XPathWrapper xpath)
XPathWrapper
to
allow complex paths, including namespace bindings.message
- Message to display if assertion fails.expected
- The expected value.node
- Initial context for expression evaluation.xpath
- Path expression to assert.