Fix language specific CLI problems (#2042)

Unit tests which deal with translated text need to be specific about
the language the test should use. Otherwise system default gets used
which may lead to problems. Also line endings may be a problem on
different OS.
This fixes two of the above issues.
This commit is contained in:
Matthias Thieroff
2022-05-20 10:58:21 +02:00
committed by GitHub
parent 303f8daaf9
commit 8981a98064
4 changed files with 29 additions and 15 deletions

View File

@@ -60,6 +60,9 @@ dependencies {
implementation libraries.shiroWeb
implementation libraries.shiroGuice
// tests
testImplementation libraries.junitPioneer
// jwt
implementation libraries.jjwtApi
implementation libraries.jjwtRuntime

View File

@@ -172,13 +172,22 @@ org.jboss.resteasy:resteasy-validator-provider:4.7.5.Final=compileClasspath,comp
org.jboss.spec.javax.annotation:jboss-annotations-api_1.3_spec:2.0.1.Final=compileClasspath,compileClasspathCopy,default,defaultCopy,runtimeClasspath,runtimeClasspathCopy,testCompileClasspath,testCompileClasspathCopy,testRuntimeClasspath,testRuntimeClasspathCopy
org.jboss.spec.javax.ws.rs:jboss-jaxrs-api_2.1_spec:2.0.1.Final=compileClasspath,compileClasspathCopy,default,defaultCopy,runtimeClasspath,runtimeClasspathCopy,testCompileClasspath,testCompileClasspathCopy,testRuntimeClasspath,testRuntimeClasspathCopy
org.jboss.spec.javax.xml.bind:jboss-jaxb-api_2.3_spec:2.0.0.Final=compileClasspath,compileClasspathCopy,default,defaultCopy,runtimeClasspath,runtimeClasspathCopy,testCompileClasspath,testCompileClasspathCopy,testRuntimeClasspath,testRuntimeClasspathCopy
org.junit.jupiter:junit-jupiter-api:5.7.0=testCompileClasspath,testCompileClasspathCopy,testRuntimeClasspath,testRuntimeClasspathCopy
org.junit.jupiter:junit-jupiter-engine:5.7.0=testCompileClasspath,testCompileClasspathCopy,testRuntimeClasspath,testRuntimeClasspathCopy
org.junit.jupiter:junit-jupiter-params:5.7.0=testCompileClasspath,testCompileClasspathCopy,testRuntimeClasspath,testRuntimeClasspathCopy
org.junit.platform:junit-platform-commons:1.7.0=testCompileClasspath,testCompileClasspathCopy,testRuntimeClasspath,testRuntimeClasspathCopy
org.junit.platform:junit-platform-engine:1.7.0=testCompileClasspath,testCompileClasspathCopy,testRuntimeClasspath,testRuntimeClasspathCopy
org.junit.vintage:junit-vintage-engine:5.7.0=testCompileClasspath,testCompileClasspathCopy,testRuntimeClasspath,testRuntimeClasspathCopy
org.junit:junit-bom:5.7.0=testCompileClasspath,testCompileClasspathCopy,testRuntimeClasspath,testRuntimeClasspathCopy
org.junit-pioneer:junit-pioneer:1.6.2=testCompileClasspath,testCompileClasspathCopy,testRuntimeClasspath,testRuntimeClasspathCopy
org.junit.jupiter:junit-jupiter-api:5.7.0=testCompileClasspath,testCompileClasspathCopy
org.junit.jupiter:junit-jupiter-api:5.7.2=testRuntimeClasspath,testRuntimeClasspathCopy
org.junit.jupiter:junit-jupiter-engine:5.7.0=testCompileClasspath,testCompileClasspathCopy
org.junit.jupiter:junit-jupiter-engine:5.7.2=testRuntimeClasspath,testRuntimeClasspathCopy
org.junit.jupiter:junit-jupiter-params:5.7.0=testCompileClasspath,testCompileClasspathCopy
org.junit.jupiter:junit-jupiter-params:5.7.2=testRuntimeClasspath,testRuntimeClasspathCopy
org.junit.platform:junit-platform-commons:1.7.0=testCompileClasspath,testCompileClasspathCopy
org.junit.platform:junit-platform-commons:1.7.2=testRuntimeClasspath,testRuntimeClasspathCopy
org.junit.platform:junit-platform-engine:1.7.0=testCompileClasspath,testCompileClasspathCopy
org.junit.platform:junit-platform-engine:1.7.2=testRuntimeClasspath,testRuntimeClasspathCopy
org.junit.platform:junit-platform-launcher:1.7.2=testRuntimeClasspath,testRuntimeClasspathCopy
org.junit.vintage:junit-vintage-engine:5.7.0=testCompileClasspath,testCompileClasspathCopy
org.junit.vintage:junit-vintage-engine:5.7.2=testRuntimeClasspath,testRuntimeClasspathCopy
org.junit:junit-bom:5.7.0=testCompileClasspath,testCompileClasspathCopy
org.junit:junit-bom:5.7.2=testRuntimeClasspath,testRuntimeClasspathCopy
org.kohsuke:akuma:1.10=compileClasspath,compileClasspathCopy,default,defaultCopy,runtimeClasspath,runtimeClasspathCopy,testCompileClasspath,testCompileClasspathCopy,testRuntimeClasspath,testRuntimeClasspathCopy
org.latencyutils:LatencyUtils:2.0.3=default,defaultCopy,runtimeClasspath,runtimeClasspathCopy,testRuntimeClasspath,testRuntimeClasspathCopy
org.mapstruct:mapstruct-jdk8:1.3.1.Final=annotationProcessor,annotationProcessorCopy,compileClasspath,compileClasspathCopy,default,defaultCopy,runtimeClasspath,runtimeClasspathCopy,testCompileClasspath,testCompileClasspathCopy,testRuntimeClasspath,testRuntimeClasspathCopy

View File

@@ -29,6 +29,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junitpioneer.jupiter.DefaultLocale;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import picocli.CommandLine;
@@ -46,7 +47,6 @@ import java.io.PrintWriter;
import java.util.Optional;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -92,6 +92,7 @@ class CliExceptionHandlerTest {
}
@Nested
@DefaultLocale("en")
class EnglishLanguageTest {
@BeforeEach
@@ -156,6 +157,7 @@ class CliExceptionHandlerTest {
}
@Nested
@DefaultLocale("de")
class GermanLanguageTest {
@BeforeEach

View File

@@ -39,9 +39,9 @@ import picocli.CommandLine;
import javax.annotation.Nonnull;
import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.Locale;
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -98,24 +98,24 @@ class CliProcessorTest {
void shouldPrintCommandOne() {
String result = executeHierarchyCommands("--help");
assertThat(result).contains("Commands:\n" +
" one");
assertThat(result).contains(format("Commands:%n" +
" one"));
}
@Test
void shouldPrintCommandTwo() {
String result = executeHierarchyCommands("one", "--help");
assertThat(result).contains("Commands:\n" +
" two");
assertThat(result).contains(format("Commands:%n" +
" two"));
}
@Test
void shouldPrintCommandThree() {
String result = executeHierarchyCommands("one", "two", "--help");
assertThat(result).contains("Commands:\n" +
" three");
assertThat(result).contains(format("Commands:%n" +
" three"));
}
}