XML Assertions
XML matchers perform a structural XML comparison (element order is irrelevant) with optional exclusion of specific elements. An XPath variant lets you pinpoint specific values.
Structural XML match : Then expected record from file based on XMLโ
Fetches a record and compares its value as XML. Attribute order, whitespace, and element order are normalised before comparison.
Then expected record from file based on XML
| topicAlias | file | excludedElements | expectedRecordKey |
| orders-out | expected.xml | ns:CreationDateTime | |
| Column | Type | Required | Description |
|---|---|---|---|
topicAlias | string | โ | Alias of a declared output topic |
file | string | โ | Expected XML file path, relative to assets directory |
excludedElements | string | โ | Comma-separated list of XML element names or XPath expressions to ignore during comparison |
expectedRecordKey | string | โ | Filter: only accept records with this exact key |
consumerReadTimeout | integer | โ | Max seconds to wait for a record |
consumerDeltaTime | integer | โ | How far back (seconds) to seek |
Excluding elementsโ
The excludedElements column accepts comma-separated element names (with or without namespace prefix):
| excludedElements |
| CreationDateTime,MessageId,ns2:Checksum |
Elements listed here are removed from both the expected and actual XML before comparison.
XPath match : Then expected record based on XML should have fields matching from fileโ
Extracts one or more values from the record using XPath expressions and compares them against the corresponding expected file content line-by-line.
Then expected record based on XML should have fields matching from file
| topicAlias | file | xpathExpressions |
| orders-out | expected.xml | //Weight[@unit='KG']/text(),//Sender/ID/text() |
| Column | Type | Required | Description |
|---|---|---|---|
topicAlias | string | โ | Alias of a declared output topic |
file | string | โ | Expected values file โ one expected value per line matching the XPath order |
xpathExpressions | string | โ | Comma-separated XPath expressions |
Expected file format for XPathโ
When using multiple XPath expressions, the expected file contains one value per line, in the same order as the expressions:
42.5
SENDER-001
XML matchers are not available for Avro topics. Use Avro matchers โ for Avro-serialised records.