mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-27 01:19:02 +00:00
Merge branch '5.3.x'
This commit is contained in:
+32
-5
@@ -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;
|
||||
@@ -23,6 +24,7 @@ import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.util.xml.XmlValidationModeDetector.VALIDATION_DTD;
|
||||
import static org.springframework.util.xml.XmlValidationModeDetector.VALIDATION_XSD;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link XmlValidationModeDetector}.
|
||||
@@ -36,11 +38,36 @@ class XmlValidationModeDetectorTests {
|
||||
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = { "dtdWithTrailingComment.xml", "dtdWithLeadingComment.xml", "dtdWithCommentOnNextLine.xml",
|
||||
"dtdWithMultipleComments.xml" })
|
||||
@ValueSource(strings = {
|
||||
"dtdWithNoComments.xml",
|
||||
"dtdWithLeadingComment.xml",
|
||||
"dtdWithTrailingComment.xml",
|
||||
"dtdWithTrailingCommentAcrossMultipleLines.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);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {
|
||||
"xsdWithNoComments.xml",
|
||||
"xsdWithMultipleComments.xml",
|
||||
"xsdWithDoctypeInComment.xml",
|
||||
"xsdWithDoctypeInOpenCommentWithAdditionalCommentOnSameLine.xml"
|
||||
})
|
||||
void xsdDetection(String fileName) throws Exception {
|
||||
assertValidationMode(fileName, VALIDATION_XSD);
|
||||
}
|
||||
|
||||
|
||||
private void assertValidationMode(String fileName, int expectedValidationMode) throws IOException {
|
||||
try (InputStream inputStream = getClass().getResourceAsStream(fileName)) {
|
||||
assertThat(xmlValidationModeDetector.detectValidationMode(inputStream))
|
||||
.as("Validation Mode")
|
||||
.isEqualTo(expectedValidationMode);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user