mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-04-18 16:46:53 -04:00
more unit tests
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package org.cryptomator.common;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
|
||||
@@ -8,8 +10,10 @@ import java.util.Map;
|
||||
|
||||
public class LazyProcessedPropertiesTest {
|
||||
|
||||
LazyProcessedProperties inTest;
|
||||
@ParameterizedTest
|
||||
@CsvSource(value = {"org.example.@{mytest1}.test, org.example.@{mytest1}.test", //
|
||||
@DisplayName("Test template replacement")
|
||||
@CsvSource(value = {"unknown.@{testToken}.test, unknown.@{testToken}.test", //
|
||||
"@{only*words*digits*under_score\\},@{only*words*digits*under_score\\}", //
|
||||
"C:\\Users\\@{appdir}\\dir, C:\\Users\\foobar\\dir", //
|
||||
"@{@{appdir}},@{foobar}", //
|
||||
@@ -20,4 +24,25 @@ public class LazyProcessedPropertiesTest {
|
||||
Assertions.assertEquals(result, expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("@{userhome} is replaced with the user home directory")
|
||||
public void testUserhome(){
|
||||
var expected = System.getProperty("user.home");
|
||||
|
||||
inTest = new LazyProcessedProperties(System.getProperties(), Map.of());
|
||||
var result = inTest.process("@{userhome}");
|
||||
Assertions.assertEquals(result, expected);
|
||||
}
|
||||
|
||||
@DisplayName("Other keywords are replaced accordingly")
|
||||
@ParameterizedTest(name = "Token \"{0}\" replaced with content of {1}")
|
||||
@CsvSource(value = {"appdir, APPDIR, foobar",
|
||||
"appdata, APPDATA, bazbaz",
|
||||
"localappdata, LOCALAPPDATA, boboAlice"})
|
||||
public void testAppDir(String token, String envName, String expected){
|
||||
inTest = new LazyProcessedProperties(System.getProperties(), Map.of(envName, expected));
|
||||
var result = inTest.process("@{"+token+"}");
|
||||
Assertions.assertEquals(result, expected);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user