public class PlaceholderDifferenceEvaluator extends Object implements DifferenceEvaluator
This class and the whole module are considered experimental and any API may change between releases of XMLUnit.
To use it, just add it with DiffBuilder
like below
Diff diff = DiffBuilder.compare(control).withTest(test).withDifferenceEvaluator(new PlaceholderDifferenceEvaluator()).build();
Supported scenarios are demonstrated in the unit tests (PlaceholderDifferenceEvaluatorTest).
Default delimiters for placeholder are ${
and
}
. Arguments to placeholders are by default enclosed
in (
and )
and separated by ,
- whitespace
is significant, arguments are not quoted.
To use custom delimiters (in regular expression), create
instance with the PlaceholderDifferenceEvaluator(String,
String)
or PlaceholderDifferenceEvaluator(String, String,
String, String, String)
constructors.
Modifier and Type | Field and Description |
---|---|
static String |
PLACEHOLDER_DEFAULT_ARGS_CLOSING_DELIMITER_REGEX |
static String |
PLACEHOLDER_DEFAULT_ARGS_OPENING_DELIMITER_REGEX |
static String |
PLACEHOLDER_DEFAULT_ARGS_SEPARATOR_REGEX |
static String |
PLACEHOLDER_DEFAULT_CLOSING_DELIMITER_REGEX |
static String |
PLACEHOLDER_DEFAULT_OPENING_DELIMITER_REGEX |
Constructor and Description |
---|
PlaceholderDifferenceEvaluator()
Creates a PlaceholderDifferenceEvaluator with default
delimiters
PLACEHOLDER_DEFAULT_OPENING_DELIMITER_REGEX
and PLACEHOLDER_DEFAULT_CLOSING_DELIMITER_REGEX . |
PlaceholderDifferenceEvaluator(String placeholderOpeningDelimiterRegex,
String placeholderClosingDelimiterRegex)
Creates a PlaceholderDifferenceEvaluator with custom delimiters.
|
PlaceholderDifferenceEvaluator(String placeholderOpeningDelimiterRegex,
String placeholderClosingDelimiterRegex,
String placeholderArgsOpeningDelimiterRegex,
String placeholderArgsClosingDelimiterRegex,
String placeholderArgsSeparatorRegex)
Creates a PlaceholderDifferenceEvaluator with custom delimiters.
|
Modifier and Type | Method and Description |
---|---|
ComparisonResult |
evaluate(Comparison comparison,
ComparisonResult outcome) |
public static final String PLACEHOLDER_DEFAULT_OPENING_DELIMITER_REGEX
public static final String PLACEHOLDER_DEFAULT_CLOSING_DELIMITER_REGEX
public static final String PLACEHOLDER_DEFAULT_ARGS_OPENING_DELIMITER_REGEX
public static final String PLACEHOLDER_DEFAULT_ARGS_CLOSING_DELIMITER_REGEX
public static final String PLACEHOLDER_DEFAULT_ARGS_SEPARATOR_REGEX
public PlaceholderDifferenceEvaluator()
PLACEHOLDER_DEFAULT_OPENING_DELIMITER_REGEX
and PLACEHOLDER_DEFAULT_CLOSING_DELIMITER_REGEX
.public PlaceholderDifferenceEvaluator(String placeholderOpeningDelimiterRegex, String placeholderClosingDelimiterRegex)
placeholderOpeningDelimiterRegex
- regular expression for
the opening delimiter of placeholder, defaults to PLACEHOLDER_DEFAULT_OPENING_DELIMITER_REGEX
if the parameter is null or blankplaceholderClosingDelimiterRegex
- regular expression for
the closing delimiter of placeholder, defaults to PLACEHOLDER_DEFAULT_CLOSING_DELIMITER_REGEX
if the parameter is null or blankpublic PlaceholderDifferenceEvaluator(String placeholderOpeningDelimiterRegex, String placeholderClosingDelimiterRegex, String placeholderArgsOpeningDelimiterRegex, String placeholderArgsClosingDelimiterRegex, String placeholderArgsSeparatorRegex)
placeholderOpeningDelimiterRegex
- regular expression for
the opening delimiter of placeholder, defaults to PLACEHOLDER_DEFAULT_OPENING_DELIMITER_REGEX
if the parameter is null or blankplaceholderClosingDelimiterRegex
- regular expression for
the closing delimiter of placeholder, defaults to PLACEHOLDER_DEFAULT_CLOSING_DELIMITER_REGEX
if the parameter is null or blankplaceholderArgsOpeningDelimiterRegex
- regular expression for
the opening delimiter of the placeholder's argument list, defaults to PLACEHOLDER_DEFAULT_ARGS_OPENING_DELIMITER_REGEX
if the parameter is null or blankplaceholderArgsClosingDelimiterRegex
- regular expression for
the closing delimiter of the placeholder's argument list, defaults to PLACEHOLDER_DEFAULT_ARGS_CLOSING_DELIMITER_REGEX
if the parameter is null or blankplaceholderArgsSeparatorRegex
- regular expression for the
delimiter between arguments inside of the placeholder's
argument list, defaults to PLACEHOLDER_DEFAULT_ARGS_SEPARATOR_REGEX
if the parameter is null or blankpublic ComparisonResult evaluate(Comparison comparison, ComparisonResult outcome)
evaluate
in interface DifferenceEvaluator
Copyright © 2001–2022 XMLUnit. All rights reserved.