Polishing

This commit is contained in:
Sam Brannen
2022-01-12 17:36:48 +01:00
parent 3631d2f36e
commit 9e8b6feb54
2 changed files with 30 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
package org.springframework.util.xml;
import java.io.IOException;
import java.io.InputStream;
import org.junit.jupiter.params.ParameterizedTest;
@@ -39,8 +40,16 @@ class XmlValidationModeDetectorTests {
@ValueSource(strings = { "dtdWithTrailingComment.xml", "dtdWithLeadingComment.xml", "dtdWithCommentOnNextLine.xml",
"dtdWithMultipleComments.xml" })
void dtdDetection(String fileName) throws Exception {
InputStream inputStream = getClass().getResourceAsStream(fileName);
assertThat(xmlValidationModeDetector.detectValidationMode(inputStream)).isEqualTo(VALIDATION_DTD);
assertValidationMode(fileName, VALIDATION_DTD);
}
private void assertValidationMode(String fileName, int expectedValidationMode) throws IOException {
try (InputStream inputStream = getClass().getResourceAsStream(fileName)) {
assertThat(xmlValidationModeDetector.detectValidationMode(inputStream))
.as("Validation Mode")
.isEqualTo(expectedValidationMode);
}
}
}