diff --git a/spring-javaformat/spring-javaformat-checkstyle/src/test/java/io/spring/javaformat/checkstyle/AssertionsAuditListener.java b/spring-javaformat/spring-javaformat-checkstyle/src/test/java/io/spring/javaformat/checkstyle/AssertionsAuditListener.java index 22ef790d..92105e06 100644 --- a/spring-javaformat/spring-javaformat-checkstyle/src/test/java/io/spring/javaformat/checkstyle/AssertionsAuditListener.java +++ b/spring-javaformat/spring-javaformat-checkstyle/src/test/java/io/spring/javaformat/checkstyle/AssertionsAuditListener.java @@ -75,10 +75,10 @@ public void auditFinished(AuditEvent event) { private void runCheck(String check) { String description = this.filenames.toString(); if (check.startsWith("+")) { - assertThat(this.message).as(description).contains(check.substring(1)); + assertThat(this.message.toString()).as(description).contains(check.substring(1)); } else if (check.startsWith("-")) { - assertThat(this.message).as(description).doesNotContain(check.substring(1)); + assertThat(this.message.toString()).as(description).doesNotContain(check.substring(1)); } } diff --git a/spring-javaformat/spring-javaformat-checkstyle/src/test/java/io/spring/javaformat/checkstyle/SpringChecksTests.java b/spring-javaformat/spring-javaformat-checkstyle/src/test/java/io/spring/javaformat/checkstyle/SpringChecksTests.java index 6e4b72be..692d2134 100644 --- a/spring-javaformat/spring-javaformat-checkstyle/src/test/java/io/spring/javaformat/checkstyle/SpringChecksTests.java +++ b/spring-javaformat/spring-javaformat-checkstyle/src/test/java/io/spring/javaformat/checkstyle/SpringChecksTests.java @@ -24,6 +24,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; +import java.util.Locale; import java.util.Properties; import java.util.stream.Collectors; @@ -71,6 +72,8 @@ public SpringChecksTests(Parameter parameter) throws Exception { @Test public void processHasExpectedResults() throws Exception { + Locale previousLocale = Locale.getDefault(); + Locale.setDefault(Locale.ENGLISH); Configuration configuration = loadConfiguration(); RootModule rootModule = createRootModule(configuration); try { @@ -78,6 +81,7 @@ public void processHasExpectedResults() throws Exception { } finally { rootModule.destroy(); + Locale.setDefault(previousLocale); } } @@ -100,7 +104,7 @@ private RootModule createRootModule(Configuration configuration) throws Checksty } private void processAndCheckResults(RootModule rootModule) throws CheckstyleException { - rootModule.addListener(this.parameter.getAssersionsListener()); + rootModule.addListener(this.parameter.getAssertionsListener()); if (!RUNNING_ON_WINDOWS) { printDebugInfo(this.parameter.getSourceFile()); } @@ -127,7 +131,7 @@ private static class Parameter { private final File sourceFile; - private final AssertionsAuditListener assersionsListener; + private final AssertionsAuditListener assertionsListener; private final File configFile; @@ -136,7 +140,7 @@ private static class Parameter { this.sourceFile = new File(SOURCES_DIR, sourceName); File configFile = new File(CONFIGS_DIR, this.name + ".xml"); this.configFile = (configFile.exists() ? configFile : DEFAULT_CONFIG); - this.assersionsListener = new AssertionsAuditListener(readChecks(this.name + ".txt")); + this.assertionsListener = new AssertionsAuditListener(readChecks(this.name + ".txt")); } private List readChecks(String name) { @@ -156,8 +160,8 @@ public File getConfigFile() { return this.configFile; } - public AssertionsAuditListener getAssersionsListener() { - return this.assersionsListener; + public AssertionsAuditListener getAssertionsListener() { + return this.assertionsListener; } @Override diff --git a/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/check/OuterTypeFilenameInvalid.txt b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/check/OuterTypeFilenameInvalid.txt new file mode 100644 index 00000000..c242222d --- /dev/null +++ b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/check/OuterTypeFilenameInvalid.txt @@ -0,0 +1 @@ ++The name of the outer type and the file do not match \ No newline at end of file diff --git a/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/check/OuterTypeFilenameValid.txt b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/check/OuterTypeFilenameValid.txt new file mode 100644 index 00000000..69174e4c --- /dev/null +++ b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/check/OuterTypeFilenameValid.txt @@ -0,0 +1 @@ ++0 errors \ No newline at end of file diff --git a/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/NewlineAtEndOfFile.java b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/NewlineAtEndOfFile.java index e4af2c7a..2e80c229 100644 --- a/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/NewlineAtEndOfFile.java +++ b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/NewlineAtEndOfFile.java @@ -14,6 +14,6 @@ * limitations under the License. */ -public class MissingNewLine { +public class NewlineAtEndOfFile { } \ No newline at end of file diff --git a/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/OuterTypeFilenameInvalid.java b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/OuterTypeFilenameInvalid.java new file mode 100644 index 00000000..0c2f80ad --- /dev/null +++ b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/OuterTypeFilenameInvalid.java @@ -0,0 +1,24 @@ +/* + * Copyright 2017-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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This is an example of a class name not matching its filename. + * + * @author Christoph Dreis + */ +public class NameNotMatching { + +} diff --git a/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/OuterTypeFilenameValid.java b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/OuterTypeFilenameValid.java new file mode 100644 index 00000000..c9ee62bc --- /dev/null +++ b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/OuterTypeFilenameValid.java @@ -0,0 +1,24 @@ +/* + * Copyright 2017-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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This is a valid example of a class name matching its filename. + * + * @author Christoph Dreis + */ +public class OuterTypeFilenameValid { + +}