Package de.latlon.ets.core.assertion
Class ETSAssert
java.lang.Object
de.latlon.ets.core.assertion.ETSAssert
Provides a set of custom assertion methods.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertContentType(jakarta.ws.rs.core.MultivaluedMap<String, Object> headers, String expectedContentType) Asserts that the actual content type matches the expected content type.static voidassertDescendantElementCount(Document xmlEntity, QName elementName, int expectedCount) Asserts that the given XML entity contains the expected number of descendant elements having the specified name.static voidassertQualifiedName(Node node, QName qName) Asserts that the qualified name of a DOM Node matches the expected value.static voidassertSchematronValid(URL schemaRef, Source xmlSource) Asserts that an XML resource satisfies all applicable constraints specified in a Schematron (ISO 19757-3) schema.static voidassertSchemaValid(Schema schema, Document document) Asserts that an XML resource is schema-valid.static voidassertSchemaValid(Validator validator, Source source) Asserts that an XML resource is schema-valid.static voidassertStatusCode(int actualCode, int... expectedCodes) Asserts that the actual HTTP status code matches one of the expected status codes.static voidAsserts that the url is resolvable (status code is 200).static voidAsserts that the string is a valid url.static voidassertXPath(String expr, Node context, NamespaceBindings nsBindings) Asserts that an XPath 1.0 expression holds true for the given evaluation context.static BooleancheckXPath(String expr, Node context, NamespaceBindings nsBindings) Checks whether an XPath 1.0 expression holds true for the given evaluation context.static voidverifyXPath(String expr, Node context, NamespaceBindings nsBindings, String skipMessage) Verify that an XPath 1.0 expression holds true for the given evaluation context.Throws anSkipExceptionif the xpath results infalse.
-
Method Details
-
assertQualifiedName
Asserts that the qualified name of a DOM Node matches the expected value.- Parameters:
node- The Node to check.qName- A QName object containing a namespace name (URI) and a local part.
-
assertXPath
Asserts that an XPath 1.0 expression holds true for the given evaluation context. The method arguments will be logged at level FINE or lower.- Parameters:
expr- A valid XPath 1.0 expression.context- The context node.nsBindings- A collection of namespace bindings for the XPath expression, where each entry maps a namespace URI (key) to a prefix (value). Nevernull.
-
verifyXPath
public static void verifyXPath(String expr, Node context, NamespaceBindings nsBindings, String skipMessage) Verify that an XPath 1.0 expression holds true for the given evaluation context.Throws anSkipExceptionif the xpath results infalse. The method arguments will be logged at level FINE or lower.- Parameters:
expr- A valid XPath 1.0 expression.context- The context node.nsBindings- A collection of namespace bindings for the XPath expression, where each entry maps a namespace URI (key) to a prefix (value). Nevernull.skipMessage- message to pass in theSkipExceptionif the xpath results infalse
-
assertSchemaValid
Asserts that an XML resource is schema-valid.- Parameters:
schema- to validate against, nevernull.document- to validate, nevernull
-
assertSchemaValid
Asserts that an XML resource is schema-valid.- Parameters:
validator- The Validator to use.source- The XML Source to be validated.
-
assertSchematronValid
Asserts that an XML resource satisfies all applicable constraints specified in a Schematron (ISO 19757-3) schema. The "xslt2" query language binding is supported. All patterns are checked.- Parameters:
schemaRef- A URL that denotes the location of a Schematron schema.xmlSource- The XML Source to be validated.
-
assertDescendantElementCount
public static void assertDescendantElementCount(Document xmlEntity, QName elementName, int expectedCount) Asserts that the given XML entity contains the expected number of descendant elements having the specified name.- Parameters:
xmlEntity- A Document representing an XML entity.elementName- The qualified name of the element.expectedCount- The expected number of occurrences.
-
assertStatusCode
public static void assertStatusCode(int actualCode, int... expectedCodes) Asserts that the actual HTTP status code matches one of the expected status codes.- Parameters:
actualCode- The actual status code.expectedCodes- An int[] array containing the expected status codes.
-
assertContentType
public static void assertContentType(jakarta.ws.rs.core.MultivaluedMap<String, Object> headers, String expectedContentType) Asserts that the actual content type matches the expected content type.- Parameters:
headers- The header of the response.expectedContentType- The expected content type, nevernull.
-
assertUrl
Asserts that the string is a valid url.- Parameters:
url- The url to check.
-
assertUriIsResolvable
Asserts that the url is resolvable (status code is 200).- Parameters:
url- The url to check.
-
checkXPath
public static Boolean checkXPath(String expr, Node context, NamespaceBindings nsBindings) throws AssertionError Checks whether an XPath 1.0 expression holds true for the given evaluation context. The method arguments will be logged at level FINE or lower.- Parameters:
expr- A valid XPath 1.0 expression.context- The context node.nsBindings- A collection of namespace bindings for the XPath expression, where each entry maps a namespace URI (key) to a prefix (value). Nevernull.- Returns:
- true if XPath 1.0 expression holds true for the given evaluation context, false otherwise.
- Throws:
AssertionError
-