}
//check if header expression is variable or function
headerName = context.resolveDynamicValue(headerName);
if (!receivedHeaders.containsKey(headerName)) {
throw new ValidationException("Validation failed: Header element '" + headerName + "' is missing");
}
if (receivedHeaders.get(headerName) != null) {
actualValue = receivedHeaders.get(headerName).toString();
}
//check if value expression is variable or function
expectedValue = context.replaceDynamicContentInString(expectedValue);
try {
if (actualValue != null) {
if (ValidationMatcherUtils.isValidationMatcherExpression(expectedValue)) {
ValidationMatcherUtils.resolveValidationMatcher(headerName, actualValue,
expectedValue, context);
continue;
}
Assert.isTrue(expectedValue != null,
"Values not equal for header element '"
+ headerName + "', expected '"
+ null + "' but was '"
+ actualValue + "'");
Assert.isTrue(actualValue.equals(expectedValue),
"Values not equal for header element '"
+ headerName + "', expected '"
+ expectedValue + "' but was '"
+ actualValue + "'");
} else {
Assert.isTrue(expectedValue == null || expectedValue.length() == 0,
"Values not equal for header element '"
+ headerName + "', expected '"
+ expectedValue + "' but was '"
+ null + "'");
}
} catch (IllegalArgumentException e) {
throw new ValidationException("Validation failed:", e);
}
if (log.isDebugEnabled()) {
log.debug("Validating header element: " + headerName + "='" + expectedValue + "': OK.");
}