From 333711fd36f7774fd0ffeebf514e83899b90f6c7 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 9 Sep 2019 16:29:00 +0200 Subject: [PATCH] Convert XmlValidationModeDetectorTests to JUnit Jupiter and AssertJ See gh-23605 --- .../xml/XmlValidationModeDetectorTests.java | 34 +++++-------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/spring-core/src/test/java/org/springframework/util/xml/XmlValidationModeDetectorTests.java b/spring-core/src/test/java/org/springframework/util/xml/XmlValidationModeDetectorTests.java index 61b01af896..631a61d4f7 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/XmlValidationModeDetectorTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/XmlValidationModeDetectorTests.java @@ -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); } }