Convert XmlValidationModeDetectorTests to JUnit Jupiter and AssertJ

See gh-23605
This commit is contained in:
Sam Brannen
2019-09-09 16:29:00 +02:00
parent 22c88d7126
commit 333711fd36

View File

@@ -18,9 +18,10 @@ package org.springframework.util.xml;
import java.io.InputStream;
import org.junit.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import static org.junit.Assert.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.util.xml.XmlValidationModeDetector.VALIDATION_DTD;
/**
@@ -29,34 +30,17 @@ import static org.springframework.util.xml.XmlValidationModeDetector.VALIDATION_
* @author Sam Brannen
* @since 5.1.10
*/
public class XmlValidationModeDetectorTests {
class XmlValidationModeDetectorTests {
private final XmlValidationModeDetector xmlValidationModeDetector = new XmlValidationModeDetector();
@Test
public void dtdWithTrailingComment() throws Exception {
dtdDetection("dtdWithTrailingComment.xml");
}
@Test
public void dtdWithLeadingComment() throws Exception {
dtdDetection("dtdWithLeadingComment.xml");
}
@Test
public void dtdWithCommentOnNextLine() throws Exception {
dtdDetection("dtdWithCommentOnNextLine.xml");
}
@Test
public void dtdWithMultipleComments() throws Exception {
dtdDetection("dtdWithMultipleComments.xml");
}
private void dtdDetection(String fileName) throws Exception {
@ParameterizedTest
@ValueSource(strings = { "dtdWithTrailingComment.xml", "dtdWithLeadingComment.xml", "dtdWithCommentOnNextLine.xml",
"dtdWithMultipleComments.xml" })
void dtdDetection(String fileName) throws Exception {
InputStream inputStream = getClass().getResourceAsStream(fileName);
assertEquals(VALIDATION_DTD, xmlValidationModeDetector.detectValidationMode(inputStream));
assertThat(xmlValidationModeDetector.detectValidationMode(inputStream)).isEqualTo(VALIDATION_DTD);
}
}