Skip to content

Fix spring-javaformat-checkstyle tests #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -71,13 +72,16 @@ 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 {
processAndCheckResults(rootModule);
}
finally {
rootModule.destroy();
Locale.setDefault(previousLocale);
}
}

Expand All @@ -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());
}
Expand All @@ -127,7 +131,7 @@ private static class Parameter {

private final File sourceFile;

private final AssertionsAuditListener assersionsListener;
private final AssertionsAuditListener assertionsListener;

private final File configFile;

Expand All @@ -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<String> readChecks(String name) {
Expand All @@ -156,8 +160,8 @@ public File getConfigFile() {
return this.configFile;
}

public AssertionsAuditListener getAssersionsListener() {
return this.assersionsListener;
public AssertionsAuditListener getAssertionsListener() {
return this.assertionsListener;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
+The name of the outer type and the file do not match
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
+0 errors
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
* limitations under the License.
*/

public class MissingNewLine {
public class NewlineAtEndOfFile {

}
Original file line number Diff line number Diff line change
@@ -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 {

}
Original file line number Diff line number Diff line change
@@ -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 {

}