Merge branch '5.1.x'
This commit is contained in:
@@ -143,7 +143,7 @@ configure(allprojects) { project ->
|
||||
}
|
||||
|
||||
checkstyle {
|
||||
toolVersion = "8.16"
|
||||
toolVersion = "8.17"
|
||||
configDir = rootProject.file("src/checkstyle")
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ configure(allprojects) { project ->
|
||||
testCompile("junit:junit:4.12") {
|
||||
exclude group: "org.hamcrest", module: "hamcrest-core"
|
||||
}
|
||||
testCompile("org.mockito:mockito-core:2.23.4") {
|
||||
testCompile("org.mockito:mockito-core:2.24.0") {
|
||||
exclude group: "org.hamcrest", module: "hamcrest-core"
|
||||
}
|
||||
testCompile("io.mockk:mockk:1.9")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -73,7 +73,6 @@ public class SocketUtils {
|
||||
* <bean id="bean2" ... p:port="#{socketUtils.findAvailableTcpPort(30000)}" /></code></pre>
|
||||
*/
|
||||
public SocketUtils() {
|
||||
/* no-op */
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -76,7 +76,6 @@ public class ResourceDatabasePopulator implements DatabasePopulator {
|
||||
* @since 4.0.3
|
||||
*/
|
||||
public ResourceDatabasePopulator() {
|
||||
/* no-op */
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,7 +86,6 @@ public class ResourceDatabasePopulator implements DatabasePopulator {
|
||||
* @since 4.0.3
|
||||
*/
|
||||
public ResourceDatabasePopulator(Resource... scripts) {
|
||||
this();
|
||||
setScripts(scripts);
|
||||
}
|
||||
|
||||
@@ -97,8 +95,8 @@ public class ResourceDatabasePopulator implements DatabasePopulator {
|
||||
* logged but not cause a failure
|
||||
* @param ignoreFailedDrops flag to indicate that a failed SQL {@code DROP}
|
||||
* statement can be ignored
|
||||
* @param sqlScriptEncoding the encoding for the supplied SQL scripts; may
|
||||
* be {@code null} or <em>empty</em> to indicate platform encoding
|
||||
* @param sqlScriptEncoding the encoding for the supplied SQL scripts
|
||||
* (may be {@code null} or <em>empty</em> to indicate platform encoding)
|
||||
* @param scripts the scripts to execute to initialize or clean up the database
|
||||
* (never {@code null})
|
||||
* @since 4.0.3
|
||||
@@ -106,10 +104,10 @@ public class ResourceDatabasePopulator implements DatabasePopulator {
|
||||
public ResourceDatabasePopulator(boolean continueOnError, boolean ignoreFailedDrops,
|
||||
@Nullable String sqlScriptEncoding, Resource... scripts) {
|
||||
|
||||
this(scripts);
|
||||
this.continueOnError = continueOnError;
|
||||
this.ignoreFailedDrops = ignoreFailedDrops;
|
||||
setSqlScriptEncoding(sqlScriptEncoding);
|
||||
setScripts(scripts);
|
||||
}
|
||||
|
||||
|
||||
@@ -148,10 +146,10 @@ public class ResourceDatabasePopulator implements DatabasePopulator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the encoding for the configured SQL scripts, if different from the
|
||||
* platform encoding.
|
||||
* @param sqlScriptEncoding the encoding used in scripts; may be {@code null}
|
||||
* or empty to indicate platform encoding
|
||||
* Specify the encoding for the configured SQL scripts,
|
||||
* if different from the platform encoding.
|
||||
* @param sqlScriptEncoding the encoding used in scripts
|
||||
* (may be {@code null} or empty to indicate platform encoding)
|
||||
* @see #addScript(Resource)
|
||||
*/
|
||||
public void setSqlScriptEncoding(@Nullable String sqlScriptEncoding) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -107,7 +107,7 @@ public abstract class ScriptUtils {
|
||||
* in a block comment will be omitted from the output. In addition, multiple
|
||||
* adjacent whitespace characters will be collapsed into a single space.
|
||||
* @param script the SQL script
|
||||
* @param separator character separating each statement — typically a ';'
|
||||
* @param separator character separating each statement (typically a ';')
|
||||
* @param statements the list that will contain the individual statements
|
||||
* @throws ScriptException if an error occurred while splitting the SQL script
|
||||
* @see #splitSqlScript(String, String, List)
|
||||
@@ -130,7 +130,8 @@ public abstract class ScriptUtils {
|
||||
* in a block comment will be omitted from the output. In addition, multiple
|
||||
* adjacent whitespace characters will be collapsed into a single space.
|
||||
* @param script the SQL script
|
||||
* @param separator text separating each statement — typically a ';' or newline character
|
||||
* @param separator text separating each statement
|
||||
* (typically a ';' or newline character)
|
||||
* @param statements the list that will contain the individual statements
|
||||
* @throws ScriptException if an error occurred while splitting the SQL script
|
||||
* @see #splitSqlScript(String, char, List)
|
||||
@@ -153,11 +154,11 @@ public abstract class ScriptUtils {
|
||||
* omitted from the output. In addition, multiple adjacent whitespace characters
|
||||
* will be collapsed into a single space.
|
||||
* @param resource the resource from which the script was read
|
||||
* @param script the SQL script; never {@code null} or empty
|
||||
* @param separator text separating each statement — typically a ';' or
|
||||
* newline character; never {@code null}
|
||||
* @param commentPrefix the prefix that identifies SQL line comments —
|
||||
* typically "--"; never {@code null} or empty
|
||||
* @param script the SQL script
|
||||
* @param separator text separating each statement
|
||||
* (typically a ';' or newline character)
|
||||
* @param commentPrefix the prefix that identifies SQL line comments
|
||||
* (typically "--")
|
||||
* @param blockCommentStartDelimiter the <em>start</em> block comment delimiter;
|
||||
* never {@code null} or empty
|
||||
* @param blockCommentEndDelimiter the <em>end</em> block comment delimiter;
|
||||
@@ -259,7 +260,7 @@ public abstract class ScriptUtils {
|
||||
* @throws IOException in case of I/O errors
|
||||
*/
|
||||
static String readScript(EncodedResource resource) throws IOException {
|
||||
return readScript(resource, DEFAULT_COMMENT_PREFIX, DEFAULT_STATEMENT_SEPARATOR);
|
||||
return readScript(resource, DEFAULT_COMMENT_PREFIX, DEFAULT_STATEMENT_SEPARATOR, DEFAULT_BLOCK_COMMENT_END_DELIMITER);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -270,18 +271,19 @@ public abstract class ScriptUtils {
|
||||
* a statement — will be included in the results.
|
||||
* @param resource the {@code EncodedResource} containing the script
|
||||
* to be processed
|
||||
* @param commentPrefix the prefix that identifies comments in the SQL script —
|
||||
* typically "--"
|
||||
* @param separator the statement separator in the SQL script — typically ";"
|
||||
* @param commentPrefix the prefix that identifies comments in the SQL script
|
||||
* (typically "--")
|
||||
* @param separator the statement separator in the SQL script (typically ";")
|
||||
* @param blockCommentEndDelimiter the <em>end</em> block comment delimiter
|
||||
* @return a {@code String} containing the script lines
|
||||
* @throws IOException in case of I/O errors
|
||||
*/
|
||||
private static String readScript(EncodedResource resource, @Nullable String commentPrefix,
|
||||
@Nullable String separator) throws IOException {
|
||||
@Nullable String separator, @Nullable String blockCommentEndDelimiter) throws IOException {
|
||||
|
||||
LineNumberReader lnr = new LineNumberReader(resource.getReader());
|
||||
try {
|
||||
return readScript(lnr, commentPrefix, separator);
|
||||
return readScript(lnr, commentPrefix, separator, blockCommentEndDelimiter);
|
||||
}
|
||||
finally {
|
||||
lnr.close();
|
||||
@@ -297,19 +299,21 @@ public abstract class ScriptUtils {
|
||||
* a statement — will be included in the results.
|
||||
* @param lineNumberReader the {@code LineNumberReader} containing the script
|
||||
* to be processed
|
||||
* @param commentPrefix the prefix that identifies comments in the SQL script —
|
||||
* typically "--"
|
||||
* @param separator the statement separator in the SQL script — typically ";"
|
||||
* @param lineCommentPrefix the prefix that identifies comments in the SQL script
|
||||
* (typically "--")
|
||||
* @param separator the statement separator in the SQL script (typically ";")
|
||||
* @param blockCommentEndDelimiter the <em>end</em> block comment delimiter
|
||||
* @return a {@code String} containing the script lines
|
||||
* @throws IOException in case of I/O errors
|
||||
*/
|
||||
public static String readScript(LineNumberReader lineNumberReader, @Nullable String commentPrefix,
|
||||
@Nullable String separator) throws IOException {
|
||||
public static String readScript(LineNumberReader lineNumberReader, @Nullable String lineCommentPrefix,
|
||||
@Nullable String separator, @Nullable String blockCommentEndDelimiter) throws IOException {
|
||||
|
||||
String currentStatement = lineNumberReader.readLine();
|
||||
StringBuilder scriptBuilder = new StringBuilder();
|
||||
while (currentStatement != null) {
|
||||
if (commentPrefix != null && !currentStatement.startsWith(commentPrefix)) {
|
||||
if ((blockCommentEndDelimiter != null && currentStatement.contains(blockCommentEndDelimiter)) ||
|
||||
(lineCommentPrefix != null && !currentStatement.startsWith(lineCommentPrefix))) {
|
||||
if (scriptBuilder.length() > 0) {
|
||||
scriptBuilder.append('\n');
|
||||
}
|
||||
@@ -431,16 +435,14 @@ public abstract class ScriptUtils {
|
||||
* @param ignoreFailedDrops whether or not to continue in the event of specifically
|
||||
* an error on a {@code DROP} statement
|
||||
* @param commentPrefix the prefix that identifies single-line comments in the
|
||||
* SQL script — typically "--"
|
||||
* SQL script (typically "--")
|
||||
* @param separator the script statement separator; defaults to
|
||||
* {@value #DEFAULT_STATEMENT_SEPARATOR} if not specified and falls back to
|
||||
* {@value #FALLBACK_STATEMENT_SEPARATOR} as a last resort; may be set to
|
||||
* {@value #EOF_STATEMENT_SEPARATOR} to signal that the script contains a
|
||||
* single statement without a separator
|
||||
* @param blockCommentStartDelimiter the <em>start</em> block comment delimiter; never
|
||||
* {@code null} or empty
|
||||
* @param blockCommentEndDelimiter the <em>end</em> block comment delimiter; never
|
||||
* {@code null} or empty
|
||||
* @param blockCommentStartDelimiter the <em>start</em> block comment delimiter
|
||||
* @param blockCommentEndDelimiter the <em>end</em> block comment delimiter
|
||||
* @throws ScriptException if an error occurred while executing the SQL script
|
||||
* @see #DEFAULT_STATEMENT_SEPARATOR
|
||||
* @see #FALLBACK_STATEMENT_SEPARATOR
|
||||
@@ -460,7 +462,7 @@ public abstract class ScriptUtils {
|
||||
|
||||
String script;
|
||||
try {
|
||||
script = readScript(resource, commentPrefix, separator);
|
||||
script = readScript(resource, commentPrefix, separator, blockCommentEndDelimiter);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new CannotReadScriptException(resource, ex);
|
||||
|
||||
@@ -162,6 +162,20 @@ public class ScriptUtilsUnitTests {
|
||||
assertEquals("statement 2 not split correctly", statement2, statements.get(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readAndSplitScriptContainingMultiLineNestedComments() throws Exception {
|
||||
String script = readScript("test-data-with-multi-line-nested-comments.sql");
|
||||
List<String> statements = new ArrayList<>();
|
||||
splitSqlScript(script, ';', statements);
|
||||
|
||||
String statement1 = "INSERT INTO users(first_name, last_name) VALUES('Juergen', 'Hoeller')";
|
||||
String statement2 = "INSERT INTO users(first_name, last_name) VALUES( 'Sam' , 'Brannen' )";
|
||||
|
||||
assertEquals("wrong number of statements", 2, statements.size());
|
||||
assertEquals("statement 1 not split correctly", statement1, statements.get(0));
|
||||
assertEquals("statement 2 not split correctly", statement2, statements.get(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void containsDelimiters() {
|
||||
assertFalse(containsSqlScriptDelimiters("select 1\n select ';'", ";"));
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/* This is a multi line comment
|
||||
* The next comment line has no text
|
||||
|
||||
* The next comment line starts with a space.
|
||||
* x, y, z...
|
||||
*/
|
||||
|
||||
INSERT INTO users(first_name, last_name) VALUES('Juergen', 'Hoeller');
|
||||
-- This is also a comment.
|
||||
/*-------------------------------------------
|
||||
-- A fancy multi-line comments that puts
|
||||
-- single line comments inside of a multi-line
|
||||
-- comment block.
|
||||
Moreover, the block commend end delimiter
|
||||
appears on a line that can potentially also
|
||||
be a single-line comment if we weren't
|
||||
already inside a multi-line comment run.
|
||||
-------------------------------------------*/
|
||||
INSERT INTO
|
||||
users(first_name, last_name) -- This is a single line comment containing the block-end-comment sequence here */ but it's still a single-line comment
|
||||
VALUES( 'Sam' -- first_name
|
||||
, 'Brannen' -- last_name
|
||||
);--
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -78,7 +78,6 @@ public interface TestExecutionListener {
|
||||
* @since 3.0
|
||||
*/
|
||||
default void beforeTestClass(TestContext testContext) throws Exception {
|
||||
/* no-op */
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,7 +91,6 @@ public interface TestExecutionListener {
|
||||
* @throws Exception allows any exception to propagate
|
||||
*/
|
||||
default void prepareTestInstance(TestContext testContext) throws Exception {
|
||||
/* no-op */
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,7 +114,6 @@ public interface TestExecutionListener {
|
||||
* @see #afterTestExecution
|
||||
*/
|
||||
default void beforeTestMethod(TestContext testContext) throws Exception {
|
||||
/* no-op */
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,7 +134,6 @@ public interface TestExecutionListener {
|
||||
* @see #afterTestExecution
|
||||
*/
|
||||
default void beforeTestExecution(TestContext testContext) throws Exception {
|
||||
/* no-op */
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,7 +154,6 @@ public interface TestExecutionListener {
|
||||
* @see #beforeTestExecution
|
||||
*/
|
||||
default void afterTestExecution(TestContext testContext) throws Exception {
|
||||
/* no-op */
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,7 +177,6 @@ public interface TestExecutionListener {
|
||||
* @see #afterTestExecution
|
||||
*/
|
||||
default void afterTestMethod(TestContext testContext) throws Exception {
|
||||
/* no-op */
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -197,7 +191,6 @@ public interface TestExecutionListener {
|
||||
* @since 3.0
|
||||
*/
|
||||
default void afterTestClass(TestContext testContext) throws Exception {
|
||||
/* no-op */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -141,7 +141,7 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader
|
||||
* @since 4.0.4
|
||||
*/
|
||||
protected void validateMergedContextConfiguration(MergedContextConfiguration mergedConfig) {
|
||||
/* no-op */
|
||||
// no-op
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -142,7 +142,7 @@ public abstract class AbstractGenericWebContextLoader extends AbstractContextLoa
|
||||
* @since 4.0.4
|
||||
*/
|
||||
protected void validateMergedContextConfiguration(WebMergedContextConfiguration mergedConfig) {
|
||||
/* no-op */
|
||||
// no-op
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -78,7 +78,7 @@ public class EncodedResourceResolverTests {
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
public void setup() {
|
||||
this.cache = new ConcurrentMapCache("resourceCache");
|
||||
|
||||
VersionResourceResolver versionResolver = new VersionResourceResolver();
|
||||
@@ -127,9 +127,7 @@ public class EncodedResourceResolverTests {
|
||||
|
||||
@Test
|
||||
public void resolveFromCacheWithEncodingVariants() {
|
||||
|
||||
// 1. Resolve, and cache .gz variant
|
||||
|
||||
String file = "js/foo.js";
|
||||
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/js/foo.js");
|
||||
request.addHeader("Accept-Encoding", "gzip");
|
||||
@@ -140,7 +138,6 @@ public class EncodedResourceResolverTests {
|
||||
assertTrue(resolved instanceof HttpResource);
|
||||
|
||||
// 2. Resolve unencoded resource
|
||||
|
||||
request = new MockHttpServletRequest("GET", "/js/foo.js");
|
||||
resolved = this.resolver.resolveResource(request, file, this.locations);
|
||||
|
||||
@@ -149,7 +146,7 @@ public class EncodedResourceResolverTests {
|
||||
assertFalse(resolved instanceof HttpResource);
|
||||
}
|
||||
|
||||
@Test // SPR-13149
|
||||
@Test // SPR-13149
|
||||
public void resolveWithNullRequest() {
|
||||
String file = "js/foo.js";
|
||||
Resource resolved = this.resolver.resolveResource(null, file, this.locations);
|
||||
|
||||
Reference in New Issue
Block a user