Browse Source

made tests public to avoid reflection and "open modules"

see also https://issues.apache.org/jira/browse/SUREFIRE-1909
Sebastian Stenzel 3 năm trước cách đây
mục cha
commit
f10d2b713b

+ 2 - 2
src/main/java/org/cryptomator/common/Environment.java

@@ -99,12 +99,12 @@ public class Environment {
 	}
 
 	// visible for testing
-	Path getHomeDir() {
+	public Path getHomeDir() {
 		return getPath("user.home").orElseThrow();
 	}
 
 	// visible for testing
-	Stream<Path> getPaths(String propertyName) {
+	public Stream<Path> getPaths(String propertyName) {
 		Stream<String> rawSettingsPaths = getRawList(propertyName, PATH_LIST_SEP);
 		return rawSettingsPaths.filter(Predicate.not(Strings::isNullOrEmpty)).map(Paths::get).map(this::replaceHomeDir);
 	}

+ 3 - 3
src/test/java/org/cryptomator/common/EnvironmentTest.java

@@ -17,12 +17,12 @@ import java.util.Optional;
 import java.util.stream.Collectors;
 
 @DisplayName("Environment Variables Test")
-class EnvironmentTest {
+public class EnvironmentTest {
 
 	private Environment env;
 
 	@BeforeEach
-	void init() {
+	public void init() {
 		env = Mockito.spy(new Environment());
 		Mockito.when(env.getHomeDir()).thenReturn(Path.of("/home/testuser"));
 	}
@@ -82,7 +82,7 @@ class EnvironmentTest {
 
 	@Nested
 	@DisplayName("Path Lists")
-	class SettingsPath {
+	public class SettingsPath {
 
 		@Test
 		@DisplayName("test.path.property=")

+ 1 - 1
src/test/java/org/cryptomator/common/LicenseCheckerTest.java

@@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test;
 
 import java.util.Optional;
 
-class LicenseCheckerTest {
+public class LicenseCheckerTest {
 
 	private static final String PUBLIC_KEY = """
 			MIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQBgc4HZz+/fBbC7lmEww0AO3NK9wVZ\

+ 3 - 3
src/test/java/org/cryptomator/ui/controls/SecurePasswordFieldTest.java

@@ -12,12 +12,12 @@ import java.awt.GraphicsEnvironment;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
-class SecurePasswordFieldTest {
+public class SecurePasswordFieldTest {
 
 	private SecurePasswordField pwField = new SecurePasswordField();
 
 	@BeforeAll
-	static void initJavaFx() throws InterruptedException {
+	public static void initJavaFx() throws InterruptedException {
 		Assumptions.assumeFalse(GraphicsEnvironment.isHeadless());
 		final CountDownLatch latch = new CountDownLatch(1);
 		Platform.startup(latch::countDown);
@@ -29,7 +29,7 @@ class SecurePasswordFieldTest {
 
 	@Nested
 	@DisplayName("Content Update Events")
-	class TextChange {
+	public class TextChange {
 
 		@Test
 		@DisplayName("\"ant\".append(\"eater\")")

+ 2 - 2
src/test/java/org/cryptomator/ui/recoverykey/AutoCompleterTest.java

@@ -10,7 +10,7 @@ import org.junit.jupiter.params.provider.ValueSource;
 import java.util.Optional;
 import java.util.Set;
 
-class AutoCompleterTest {
+public class AutoCompleterTest {
 
 	@Test
 	@DisplayName("no match in []")
@@ -30,7 +30,7 @@ class AutoCompleterTest {
 
 	@Nested
 	@DisplayName("search in dict: ['tame', 'teach', 'teacher']")
-	class NarrowedDownDict {
+	public class NarrowedDownDict {
 
 		AutoCompleter autoCompleter = new AutoCompleter(Set.of("tame", "teach", "teacher"));
 

+ 1 - 1
src/test/java/org/cryptomator/ui/recoverykey/RecoveryKeyFactoryTest.java

@@ -13,7 +13,7 @@ import java.io.IOException;
 import java.nio.file.Path;
 import java.security.SecureRandom;
 
-class RecoveryKeyFactoryTest {
+public class RecoveryKeyFactoryTest {
 
 	private WordEncoder wordEncoder = new WordEncoder();
 	private MasterkeyFileAccess masterkeyFileAccess = Mockito.mock(MasterkeyFileAccess.class);

+ 3 - 3
src/test/java/org/cryptomator/ui/recoverykey/WordEncoderTest.java

@@ -12,7 +12,7 @@ import java.util.stream.IntStream;
 import java.util.stream.Stream;
 
 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
-class WordEncoderTest {
+public class WordEncoderTest {
 
 	private static final Random PRNG = new Random(42l);
 	private WordEncoder encoder;
@@ -25,13 +25,13 @@ class WordEncoderTest {
 	@DisplayName("decode(encode(input)) == input")
 	@ParameterizedTest(name = "test {index}")
 	@MethodSource("createRandomByteSequences")
-	void encodeAndDecode(byte[] input) {
+	public void encodeAndDecode(byte[] input) {
 		String encoded = encoder.encodePadded(input);
 		byte[] decoded = encoder.decode(encoded);
 		Assertions.assertArrayEquals(input, decoded);
 	}
 
-	static Stream<byte[]> createRandomByteSequences() {
+	public static Stream<byte[]> createRandomByteSequences() {
 		return IntStream.range(0, 30).mapToObj(i -> {
 			byte[] randomBytes = new byte[i * 3];
 			PRNG.nextBytes(randomBytes);