فهرست منبع

Upgrade to JUnit 5

Sebastian Stenzel 6 سال پیش
والد
کامیت
1e80f4bba4

+ 23 - 23
main/commons/src/test/java/org/cryptomator/common/SemVerComparatorTest.java

@@ -8,10 +8,10 @@
  *******************************************************************************/
 package org.cryptomator.common;
 
-import java.util.Comparator;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
 
-import org.junit.Assert;
-import org.junit.Test;
+import java.util.Comparator;
 
 public class SemVerComparatorTest {
 
@@ -21,38 +21,38 @@ public class SemVerComparatorTest {
 
 	@Test
 	public void compareEqualVersions() {
-		Assert.assertEquals(0, Integer.signum(semVerComparator.compare("1.23.4", "1.23.4")));
-		Assert.assertEquals(0, Integer.signum(semVerComparator.compare("1.23.4-alpha", "1.23.4-alpha")));
-		Assert.assertEquals(0, Integer.signum(semVerComparator.compare("1.23.4+20170101", "1.23.4+20171231")));
-		Assert.assertEquals(0, Integer.signum(semVerComparator.compare("1.23.4-alpha+20170101", "1.23.4-alpha+20171231")));
+		Assertions.assertEquals(0, Integer.signum(semVerComparator.compare("1.23.4", "1.23.4")));
+		Assertions.assertEquals(0, Integer.signum(semVerComparator.compare("1.23.4-alpha", "1.23.4-alpha")));
+		Assertions.assertEquals(0, Integer.signum(semVerComparator.compare("1.23.4+20170101", "1.23.4+20171231")));
+		Assertions.assertEquals(0, Integer.signum(semVerComparator.compare("1.23.4-alpha+20170101", "1.23.4-alpha+20171231")));
 	}
 
 	// newer versions in first argument
 
 	@Test
 	public void compareHigherToLowerVersions() {
-		Assert.assertEquals(1, Integer.signum(semVerComparator.compare("1.23.5", "1.23.4")));
-		Assert.assertEquals(1, Integer.signum(semVerComparator.compare("1.24.4", "1.23.4")));
-		Assert.assertEquals(1, Integer.signum(semVerComparator.compare("1.23.4", "1.23")));
-		Assert.assertEquals(1, Integer.signum(semVerComparator.compare("1.23.4", "1.23.4-SNAPSHOT")));
-		Assert.assertEquals(1, Integer.signum(semVerComparator.compare("1.23.4", "1.23.4-56.78")));
-		Assert.assertEquals(1, Integer.signum(semVerComparator.compare("1.23.4-beta", "1.23.4-alpha")));
-		Assert.assertEquals(1, Integer.signum(semVerComparator.compare("1.23.4-alpha.1", "1.23.4-alpha")));
-		Assert.assertEquals(1, Integer.signum(semVerComparator.compare("1.23.4-56.79", "1.23.4-56.78")));
+		Assertions.assertEquals(1, Integer.signum(semVerComparator.compare("1.23.5", "1.23.4")));
+		Assertions.assertEquals(1, Integer.signum(semVerComparator.compare("1.24.4", "1.23.4")));
+		Assertions.assertEquals(1, Integer.signum(semVerComparator.compare("1.23.4", "1.23")));
+		Assertions.assertEquals(1, Integer.signum(semVerComparator.compare("1.23.4", "1.23.4-SNAPSHOT")));
+		Assertions.assertEquals(1, Integer.signum(semVerComparator.compare("1.23.4", "1.23.4-56.78")));
+		Assertions.assertEquals(1, Integer.signum(semVerComparator.compare("1.23.4-beta", "1.23.4-alpha")));
+		Assertions.assertEquals(1, Integer.signum(semVerComparator.compare("1.23.4-alpha.1", "1.23.4-alpha")));
+		Assertions.assertEquals(1, Integer.signum(semVerComparator.compare("1.23.4-56.79", "1.23.4-56.78")));
 	}
 
 	// newer versions in second argument
 
 	@Test
 	public void compareLowerToHigherVersions() {
-		Assert.assertEquals(-1, Integer.signum(semVerComparator.compare("1.23.4", "1.23.5")));
-		Assert.assertEquals(-1, Integer.signum(semVerComparator.compare("1.23.4", "1.24.4")));
-		Assert.assertEquals(-1, Integer.signum(semVerComparator.compare("1.23", "1.23.4")));
-		Assert.assertEquals(-1, Integer.signum(semVerComparator.compare("1.23.4-SNAPSHOT", "1.23.4")));
-		Assert.assertEquals(-1, Integer.signum(semVerComparator.compare("1.23.4-56.78", "1.23.4")));
-		Assert.assertEquals(-1, Integer.signum(semVerComparator.compare("1.23.4-alpha", "1.23.4-beta")));
-		Assert.assertEquals(-1, Integer.signum(semVerComparator.compare("1.23.4-alpha", "1.23.4-alpha.1")));
-		Assert.assertEquals(-1, Integer.signum(semVerComparator.compare("1.23.4-56.78", "1.23.4-56.79")));
+		Assertions.assertEquals(-1, Integer.signum(semVerComparator.compare("1.23.4", "1.23.5")));
+		Assertions.assertEquals(-1, Integer.signum(semVerComparator.compare("1.23.4", "1.24.4")));
+		Assertions.assertEquals(-1, Integer.signum(semVerComparator.compare("1.23", "1.23.4")));
+		Assertions.assertEquals(-1, Integer.signum(semVerComparator.compare("1.23.4-SNAPSHOT", "1.23.4")));
+		Assertions.assertEquals(-1, Integer.signum(semVerComparator.compare("1.23.4-56.78", "1.23.4")));
+		Assertions.assertEquals(-1, Integer.signum(semVerComparator.compare("1.23.4-alpha", "1.23.4-beta")));
+		Assertions.assertEquals(-1, Integer.signum(semVerComparator.compare("1.23.4-alpha", "1.23.4-alpha.1")));
+		Assertions.assertEquals(-1, Integer.signum(semVerComparator.compare("1.23.4-56.78", "1.23.4-56.79")));
 	}
 
 }

+ 9 - 9
main/commons/src/test/java/org/cryptomator/common/settings/SettingsJsonAdapterTest.java

@@ -5,10 +5,10 @@
  *******************************************************************************/
 package org.cryptomator.common.settings;
 
-import java.io.IOException;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
 
-import org.junit.Assert;
-import org.junit.Test;
+import java.io.IOException;
 
 public class SettingsJsonAdapterTest {
 
@@ -26,12 +26,12 @@ public class SettingsJsonAdapterTest {
 
 		Settings settings = adapter.fromJson(json);
 
-		Assert.assertTrue(settings.checkForUpdates().get());
-		Assert.assertEquals(2, settings.getDirectories().size());
-		Assert.assertEquals(8080, settings.port().get());
-		Assert.assertEquals(42, settings.numTrayNotifications().get());
-		Assert.assertEquals("dav", settings.preferredGvfsScheme().get());
-		Assert.assertEquals(VolumeImpl.FUSE, settings.preferredVolumeImpl().get());
+		Assertions.assertTrue(settings.checkForUpdates().get());
+		Assertions.assertEquals(2, settings.getDirectories().size());
+		Assertions.assertEquals(8080, settings.port().get());
+		Assertions.assertEquals(42, settings.numTrayNotifications().get());
+		Assertions.assertEquals("dav", settings.preferredGvfsScheme().get());
+		Assertions.assertEquals(VolumeImpl.FUSE, settings.preferredVolumeImpl().get());
 	}
 
 }

+ 3 - 3
main/commons/src/test/java/org/cryptomator/common/settings/SettingsTest.java

@@ -5,12 +5,12 @@
  *******************************************************************************/
 package org.cryptomator.common.settings;
 
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+
 import java.io.IOException;
 import java.util.function.Consumer;
 
-import org.junit.Test;
-import org.mockito.Mockito;
-
 public class SettingsTest {
 
 	@Test

+ 9 - 10
main/commons/src/test/java/org/cryptomator/common/settings/VaultSettingsJsonAdapterTest.java

@@ -5,15 +5,14 @@
  *******************************************************************************/
 package org.cryptomator.common.settings;
 
+import com.google.gson.stream.JsonReader;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
 import java.io.IOException;
 import java.io.StringReader;
 import java.nio.file.Paths;
 
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.google.gson.stream.JsonReader;
-
 public class VaultSettingsJsonAdapterTest {
 
 	private final VaultSettingsJsonAdapter adapter = new VaultSettingsJsonAdapter();
@@ -24,11 +23,11 @@ public class VaultSettingsJsonAdapterTest {
 		JsonReader jsonReader = new JsonReader(new StringReader(json));
 
 		VaultSettings vaultSettings = adapter.read(jsonReader);
-		Assert.assertEquals("foo", vaultSettings.getId());
-		Assert.assertEquals(Paths.get("/foo/bar"), vaultSettings.path().get());
-		Assert.assertEquals("test", vaultSettings.mountName().get());
-		Assert.assertEquals("X", vaultSettings.winDriveLetter().get());
-		Assert.assertEquals("/home/test/crypto", vaultSettings.individualMountPath().get());
+		Assertions.assertEquals("foo", vaultSettings.getId());
+		Assertions.assertEquals(Paths.get("/foo/bar"), vaultSettings.path().get());
+		Assertions.assertEquals("test", vaultSettings.mountName().get());
+		Assertions.assertEquals("X", vaultSettings.winDriveLetter().get());
+		Assertions.assertEquals("/home/test/crypto", vaultSettings.individualMountPath().get());
 	}
 
 }

+ 2 - 2
main/commons/src/test/java/org/cryptomator/common/settings/VaultSettingsTest.java

@@ -8,9 +8,9 @@
  *******************************************************************************/
 package org.cryptomator.common.settings;
 
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
 
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class VaultSettingsTest {
 

+ 6 - 6
main/keychain/src/test/java/org/cryptomator/keychain/KeychainModuleTest.java

@@ -5,20 +5,20 @@
  *******************************************************************************/
 package org.cryptomator.keychain;
 
-import java.util.Optional;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
 
-import org.junit.Assert;
-import org.junit.Test;
+import java.util.Optional;
 
 public class KeychainModuleTest {
 
 	@Test
 	public void testGetKeychain() {
 		Optional<KeychainAccess> keychainAccess = DaggerTestKeychainComponent.builder().keychainModule(new TestKeychainModule()).build().keychainAccess();
-		Assert.assertTrue(keychainAccess.isPresent());
-		Assert.assertTrue(keychainAccess.get() instanceof MapKeychainAccess);
+		Assertions.assertTrue(keychainAccess.isPresent());
+		Assertions.assertTrue(keychainAccess.get() instanceof MapKeychainAccess);
 		keychainAccess.get().storePassphrase("test", "asd");
-		Assert.assertArrayEquals("asd".toCharArray(), keychainAccess.get().loadPassphrase("test"));
+		Assertions.assertArrayEquals("asd".toCharArray(), keychainAccess.get().loadPassphrase("test"));
 	}
 
 }

+ 16 - 21
main/keychain/src/test/java/org/cryptomator/keychain/WindowsProtectedKeychainAccessTest.java

@@ -5,32 +5,27 @@
  *******************************************************************************/
 package org.cryptomator.keychain;
 
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Optional;
-
 import org.cryptomator.jni.WinDataProtection;
 import org.cryptomator.jni.WinFunctions;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.mockito.stubbing.Answer;
 
-public class WindowsProtectedKeychainAccessTest {
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Optional;
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
+public class WindowsProtectedKeychainAccessTest {
 
 	private Path tmpFile;
 	private WindowsProtectedKeychainAccess keychain;
 
-	@Before
-	public void setup() throws IOException, ReflectiveOperationException {
+	@BeforeEach
+	public void setup() throws IOException {
 		tmpFile = Files.createTempFile("unit-tests", ".tmp");
 		System.setProperty("cryptomator.keychainPath", tmpFile.toAbsolutePath().normalize().toString());
 		WinFunctions winFunctions = Mockito.mock(WinFunctions.class);
@@ -42,7 +37,7 @@ public class WindowsProtectedKeychainAccessTest {
 		keychain = new WindowsProtectedKeychainAccess(Optional.of(winFunctions));
 	}
 
-	@After
+	@AfterEach
 	public void teardown() throws IOException {
 		Files.deleteIfExists(tmpFile);
 	}
@@ -55,11 +50,11 @@ public class WindowsProtectedKeychainAccessTest {
 		keychain.storePassphrase("myOtherPassword", storedPw2);
 		String loadedPw1 = new String(keychain.loadPassphrase("myPassword"));
 		String loadedPw2 = new String(keychain.loadPassphrase("myOtherPassword"));
-		Assert.assertEquals(storedPw1, loadedPw1);
-		Assert.assertEquals(storedPw2, loadedPw2);
+		Assertions.assertEquals(storedPw1, loadedPw1);
+		Assertions.assertEquals(storedPw2, loadedPw2);
 		keychain.deletePassphrase("myPassword");
-		Assert.assertNull(keychain.loadPassphrase("myPassword"));
-		Assert.assertNull(keychain.loadPassphrase("nonExistingPassword"));
+		Assertions.assertNull(keychain.loadPassphrase("myPassword"));
+		Assertions.assertNull(keychain.loadPassphrase("nonExistingPassword"));
 	}
 
 }

+ 6 - 6
main/launcher/src/test/java/org/cryptomator/launcher/FileOpenRequestHandlerTest.java

@@ -5,6 +5,10 @@
  *******************************************************************************/
 package org.cryptomator.launcher;
 
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+
 import java.io.IOException;
 import java.nio.file.FileSystem;
 import java.nio.file.InvalidPathException;
@@ -14,10 +18,6 @@ import java.nio.file.spi.FileSystemProvider;
 import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.BlockingQueue;
 
-import org.junit.Assert;
-import org.junit.Test;
-import org.mockito.Mockito;
-
 public class FileOpenRequestHandlerTest {
 
 	@Test
@@ -37,8 +37,8 @@ public class FileOpenRequestHandlerTest {
 		FileOpenRequestHandler handler = new FileOpenRequestHandler(queue);
 		handler.handleLaunchArgs(fs, new String[] {"foo", "bar"});
 
-		Assert.assertEquals(p1, queue.poll());
-		Assert.assertEquals(p2, queue.poll());
+		Assertions.assertEquals(p1, queue.poll());
+		Assertions.assertEquals(p2, queue.poll());
 	}
 
 	@Test

+ 15 - 13
main/launcher/src/test/java/org/cryptomator/launcher/InterProcessCommunicatorTest.java

@@ -5,6 +5,11 @@
  *******************************************************************************/
 package org.cryptomator.launcher;
 
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.channels.SeekableByteChannel;
@@ -15,11 +20,6 @@ import java.nio.file.attribute.BasicFileAttributes;
 import java.nio.file.spi.FileSystemProvider;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-
 public class InterProcessCommunicatorTest {
 
 	Path portFilePath = Mockito.mock(Path.class);
@@ -30,7 +30,7 @@ public class InterProcessCommunicatorTest {
 	SeekableByteChannel portFileChannel = Mockito.mock(SeekableByteChannel.class);
 	AtomicInteger port = new AtomicInteger(-1);
 
-	@Before
+	@BeforeEach
 	public void setup() throws IOException {
 		Mockito.when(portFilePath.getFileSystem()).thenReturn(fs);
 		Mockito.when(portFilePath.toAbsolutePath()).thenReturn(portFilePath);
@@ -53,15 +53,17 @@ public class InterProcessCommunicatorTest {
 		});
 	}
 
-	@Test(expected = UnsupportedOperationException.class)
+	@Test
 	public void testStartWithDummyPort1() throws IOException {
 		port.set(0);
 		InterProcessCommunicationProtocol protocol = Mockito.mock(InterProcessCommunicationProtocol.class);
 		try (InterProcessCommunicator result = InterProcessCommunicator.start(portFilePath, protocol)) {
-			Assert.assertTrue(result.isServer());
+			Assertions.assertTrue(result.isServer());
 			Mockito.verify(provider).createDirectory(portFileParentPath);
 			Mockito.verifyZeroInteractions(protocol);
-			result.handleLaunchArgs(new String[] {"foo"});
+			Assertions.assertThrows(UnsupportedOperationException.class, () -> {
+				result.handleLaunchArgs(new String[] {"foo"});
+			});
 		}
 	}
 
@@ -71,7 +73,7 @@ public class InterProcessCommunicatorTest {
 
 		InterProcessCommunicationProtocol protocol = Mockito.mock(InterProcessCommunicationProtocol.class);
 		try (InterProcessCommunicator result = InterProcessCommunicator.start(portFilePath, protocol)) {
-			Assert.assertTrue(result.isServer());
+			Assertions.assertTrue(result.isServer());
 			Mockito.verify(provider).createDirectory(portFileParentPath);
 			Mockito.verifyZeroInteractions(protocol);
 		}
@@ -82,14 +84,14 @@ public class InterProcessCommunicatorTest {
 		port.set(-1);
 		InterProcessCommunicationProtocol protocol = Mockito.mock(InterProcessCommunicationProtocol.class);
 		try (InterProcessCommunicator result1 = InterProcessCommunicator.start(portFilePath, protocol)) {
-			Assert.assertTrue(result1.isServer());
+			Assertions.assertTrue(result1.isServer());
 			Mockito.verify(provider, Mockito.times(1)).createDirectory(portFileParentPath);
 			Mockito.verifyZeroInteractions(protocol);
 
 			try (InterProcessCommunicator result2 = InterProcessCommunicator.start(portFilePath, null)) {
-				Assert.assertFalse(result2.isServer());
+				Assertions.assertFalse(result2.isServer());
 				Mockito.verify(provider, Mockito.times(1)).createDirectory(portFileParentPath);
-				Assert.assertNotSame(result1, result2);
+				Assertions.assertNotSame(result1, result2);
 
 				result2.handleLaunchArgs(new String[] {"foo"});
 				Mockito.verify(protocol).handleLaunchArgs(new String[] {"foo"});

+ 7 - 7
main/launcher/src/test/java/org/cryptomator/logging/LaunchBasedTriggeringPolicyTest.java

@@ -5,12 +5,12 @@
  *******************************************************************************/
 package org.cryptomator.logging;
 
-import java.io.File;
-
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 
+import java.io.File;
+
 public class LaunchBasedTriggeringPolicyTest {
 
 	@Test
@@ -21,15 +21,15 @@ public class LaunchBasedTriggeringPolicyTest {
 
 		// 1st invocation
 		boolean triggered = policy.isTriggeringEvent(activeFile, event);
-		Assert.assertTrue(triggered);
+		Assertions.assertTrue(triggered);
 
 		// 2nd invocation
 		triggered = policy.isTriggeringEvent(activeFile, event);
-		Assert.assertFalse(triggered);
+		Assertions.assertFalse(triggered);
 
 		// 3rd invocation
 		triggered = policy.isTriggeringEvent(activeFile, event);
-		Assert.assertFalse(triggered);
+		Assertions.assertFalse(triggered);
 
 		Mockito.verifyZeroInteractions(activeFile);
 		Mockito.verifyZeroInteractions(event);

+ 14 - 26
main/pom.xml

@@ -45,10 +45,9 @@
 		<slf4j.version>1.7.25</slf4j.version>
 		<logback.version>1.2.3</logback.version>
 
-		<junit.version>4.12</junit.version>
-		<junit.hierarchicalrunner.version>4.12.1</junit.hierarchicalrunner.version>
-		<mockito.version>2.23.0</mockito.version>
-		<hamcrest.version>1.3</hamcrest.version> <!-- keep in sync with version required by JUnit -->
+		<junit.jupiter.version>5.4.0</junit.jupiter.version>
+		<mockito.version>2.24.0</mockito.version>
+		<hamcrest.version>1.3</hamcrest.version>
 	</properties>
 
 	<repositories>
@@ -201,20 +200,10 @@
 
 			<!-- JUnit / Mockito / Hamcrest -->
 			<dependency>
-				<groupId>junit</groupId>
-				<artifactId>junit</artifactId>
-				<version>${junit.version}</version>
-				<exclusions>
-					<exclusion>
-						<artifactId>hamcrest-core</artifactId>
-						<groupId>org.hamcrest</groupId>
-					</exclusion>
-				</exclusions>
-			</dependency>
-			<dependency>
-				<groupId>de.bechte.junit</groupId>
-				<artifactId>junit-hierarchicalcontextrunner</artifactId>
-				<version>${junit.hierarchicalrunner.version}</version>
+				<groupId>org.junit.jupiter</groupId>
+				<artifactId>junit-jupiter</artifactId>
+				<version>${junit.jupiter.version}</version>
+				<scope>test</scope>
 			</dependency>
 			<dependency>
 				<groupId>org.mockito</groupId>
@@ -236,9 +225,8 @@
 			<artifactId>slf4j-api</artifactId>
 		</dependency>
 		<dependency>
-			<groupId>junit</groupId>
-			<artifactId>junit</artifactId>
-			<scope>test</scope>
+			<groupId>org.junit.jupiter</groupId>
+			<artifactId>junit-jupiter</artifactId>
 		</dependency>
 		<dependency>
 			<groupId>org.hamcrest</groupId>
@@ -250,11 +238,6 @@
 			<artifactId>mockito-core</artifactId>
 			<scope>test</scope>
 		</dependency>
-		<dependency>
-			<groupId>de.bechte.junit</groupId>
-			<artifactId>junit-hierarchicalcontextrunner</artifactId>
-			<scope>test</scope>
-		</dependency>
 	</dependencies>
 
 	<modules>
@@ -345,6 +328,11 @@
 					</annotationProcessorPaths>
 				</configuration>
 			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-surefire-plugin</artifactId>
+				<version>2.22.1</version>
+			</plugin>
 		</plugins>
 	</build>
 

+ 6 - 6
main/ui/src/test/java/org/cryptomator/ui/l10n/LocalizationTest.java

@@ -8,6 +8,11 @@
  *******************************************************************************/
 package org.cryptomator.ui.l10n;
 
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
@@ -21,11 +26,6 @@ import java.util.ResourceBundle;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 public class LocalizationTest {
 
 	private static final Logger LOG = LoggerFactory.getLogger(LocalizationTest.class);
@@ -54,7 +54,7 @@ public class LocalizationTest {
 			ResourceBundle lang = loadLanguage(RESOURCE_FOLDER_PATH + langFileName);
 			allGood &= allStringFormatSpecifiersMatchReferenceLanguage(ref, lang, langFileName);
 		}
-		Assert.assertTrue(allGood);
+		Assertions.assertTrue(allGood);
 	}
 
 	private boolean allStringFormatSpecifiersMatchReferenceLanguage(ResourceBundle ref, ResourceBundle lang, String langFileName) {

+ 30 - 34
main/ui/src/test/java/org/cryptomator/ui/model/UpgradeVersion3to4Test.java

@@ -1,24 +1,21 @@
 package org.cryptomator.ui.model;
 
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.FileSystem;
-import java.nio.file.Files;
-import java.nio.file.Path;
-
+import com.google.common.jimfs.Configuration;
+import com.google.common.jimfs.Jimfs;
 import org.cryptomator.ui.l10n.Localization;
 import org.cryptomator.ui.l10n.LocalizationMock;
 import org.cryptomator.ui.model.UpgradeStrategy.UpgradeFailedException;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 
-import com.google.common.jimfs.Configuration;
-import com.google.common.jimfs.Jimfs;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.FileSystem;
+import java.nio.file.Files;
+import java.nio.file.Path;
 
 public class UpgradeVersion3to4Test {
 
@@ -33,8 +30,6 @@ public class UpgradeVersion3to4Test {
 			+ "  \"versionMac\": \"iUmRRHITuyJsJbVNqGNw+82YQ4A3Rma7j/y1v0DCVLA=\"" //
 			+ "}";
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
 	private final UpgradeStrategy upgradeStrategy = new UpgradeVersion3to4(L10N);
 	private FileSystem fs;
 	private Path fsRoot;
@@ -42,7 +37,7 @@ public class UpgradeVersion3to4Test {
 	private Path dataDir;
 	private Path metadataDir;
 
-	@Before
+	@BeforeEach
 	public void setup() throws IOException {
 		fs = Jimfs.newFileSystem(Configuration.unix());
 		fsRoot = fs.getPath("/");
@@ -54,22 +49,23 @@ public class UpgradeVersion3to4Test {
 		Files.write(fsRoot.resolve("masterkey.cryptomator"), NULL_KEY_CONTENTS.getBytes(StandardCharsets.US_ASCII));
 	}
 
-	@After
+	@AfterEach
 	public void teardown() throws IOException {
 		fs.close();
 	}
 
 	@Test
 	public void upgradeFailsWithWrongPassword() throws UpgradeFailedException {
-		thrown.expect(UpgradeFailedException.class);
-		thrown.expectMessage("unlock.errorMessage.wrongPassword");
-		upgradeStrategy.upgrade(vault, "asdd");
+		UpgradeFailedException e = Assertions.assertThrows(UpgradeFailedException.class, () -> {
+			upgradeStrategy.upgrade(vault, "asdd");
+		});
+		Assertions.assertEquals("unlock.errorMessage.wrongPassword", e.getMessage());
 	}
 
 	@Test
 	public void upgradeCreatesBackup() throws UpgradeFailedException {
 		upgradeStrategy.upgrade(vault, "asd");
-		Assert.assertTrue(Files.exists(fsRoot.resolve("masterkey.cryptomator.bkup")));
+		Assertions.assertTrue(Files.exists(fsRoot.resolve("masterkey.cryptomator.bkup")));
 	}
 
 	@Test
@@ -81,8 +77,8 @@ public class UpgradeVersion3to4Test {
 
 		upgradeStrategy.upgrade(vault, "asd");
 		Path newFile = lvl2Dir.resolve("0ABCDEFGH");
-		Assert.assertTrue(Files.exists(newFile));
-		Assert.assertTrue(Files.notExists(oldFile));
+		Assertions.assertTrue(Files.exists(newFile));
+		Assertions.assertTrue(Files.notExists(oldFile));
 	}
 
 	@Test
@@ -94,8 +90,8 @@ public class UpgradeVersion3to4Test {
 
 		upgradeStrategy.upgrade(vault, "asd");
 		Path newFile = lvl2Dir.resolve("0ABCDEFGH (1)");
-		Assert.assertTrue(Files.exists(newFile));
-		Assert.assertTrue(Files.notExists(oldFile));
+		Assertions.assertTrue(Files.exists(newFile));
+		Assertions.assertTrue(Files.notExists(oldFile));
 	}
 
 	@Test
@@ -106,7 +102,7 @@ public class UpgradeVersion3to4Test {
 		Files.createFile(oldFile);
 
 		upgradeStrategy.upgrade(vault, "asd");
-		Assert.assertTrue(Files.exists(oldFile));
+		Assertions.assertTrue(Files.exists(oldFile));
 	}
 
 	@Test
@@ -123,9 +119,9 @@ public class UpgradeVersion3to4Test {
 		// hex2base32(sha1("0OPQRSTUVWXYZ====")) = DDLCFQ3ODTEAHEZJPHIJQRDHROB3K42G
 		Path newMetadataFile = metadataDir.resolve("DD/LC/DDLCFQ3ODTEAHEZJPHIJQRDHROB3K42G.lng");
 		Path newFile = lvl2Dir.resolve("DDLCFQ3ODTEAHEZJPHIJQRDHROB3K42G.lng");
-		Assert.assertTrue(Files.exists(newFile));
-		Assert.assertTrue(Files.exists(newMetadataFile));
-		Assert.assertTrue(Files.notExists(oldFile));
+		Assertions.assertTrue(Files.exists(newFile));
+		Assertions.assertTrue(Files.exists(newMetadataFile));
+		Assertions.assertTrue(Files.notExists(oldFile));
 	}
 
 	@Test
@@ -142,9 +138,9 @@ public class UpgradeVersion3to4Test {
 		// hex2base32(sha1("0OPQRSTUVWXYZ====")) = DDLCFQ3ODTEAHEZJPHIJQRDHROB3K42G
 		Path newMetadataFile = metadataDir.resolve("DD/LC/DDLCFQ3ODTEAHEZJPHIJQRDHROB3K42G.lng");
 		Path newFile = lvl2Dir.resolve("DDLCFQ3ODTEAHEZJPHIJQRDHROB3K42G (1).lng");
-		Assert.assertTrue(Files.exists(newFile));
-		Assert.assertTrue(Files.exists(newMetadataFile));
-		Assert.assertTrue(Files.notExists(oldFile));
+		Assertions.assertTrue(Files.exists(newFile));
+		Assertions.assertTrue(Files.exists(newMetadataFile));
+		Assertions.assertTrue(Files.notExists(oldFile));
 	}
 
 	@Test
@@ -158,7 +154,7 @@ public class UpgradeVersion3to4Test {
 		Files.write(oldMetadataFile, "OPQRSTUVWXYZ====".getBytes(StandardCharsets.UTF_8));
 
 		upgradeStrategy.upgrade(vault, "asd");
-		Assert.assertTrue(Files.exists(oldFile));
+		Assertions.assertTrue(Files.exists(oldFile));
 	}
 
 }

+ 8 - 4
main/ui/src/test/java/org/cryptomator/ui/util/PasswordStrengthUtilTest.java

@@ -1,20 +1,24 @@
 package org.cryptomator.ui.util;
 
 import org.cryptomator.ui.l10n.Localization;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 
+import java.time.Duration;
+
 public class PasswordStrengthUtilTest {
 
-	@Test(timeout = 5000)
+	@Test
 	public void testLongPasswords() {
 		PasswordStrengthUtil util = new PasswordStrengthUtil(Mockito.mock(Localization.class));
 		StringBuilder longPwBuilder = new StringBuilder();
 		for (int i = 0; i < 10000; i++) {
 			longPwBuilder.append('x');
 		}
-		util.computeRate(longPwBuilder.toString());
+		Assertions.assertTimeout(Duration.ofSeconds(5), () -> {
+			util.computeRate(longPwBuilder.toString());
+		});
 	}
 
 }