forked from processing/processing4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettingsTest.java
More file actions
40 lines (35 loc) · 1.14 KB
/
SettingsTest.java
File metadata and controls
40 lines (35 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import org.junit.jupiter.api.Test;
import processing.utils.Settings;
import java.io.IOException;
import java.nio.file.Files;
public class SettingsTest {
/**
* Requesting the settings folder should create it if it doesn't exist
*/
@Test
public void testSettingsFolder() {
try {
var folder = Settings.getFolder();
assert (folder.exists());
} catch (Settings.SettingsFolderException e) {
assert (false);
}
}
/**
* Overriding the settings folder via system property should work
*/
@Test
public void testOverrideFolder() throws IOException {
var settings = Files.createTempDirectory("settings_test");
System.setProperty("processing.settings.folder", settings.toString());
try {
var folder = Settings.getFolder();
assert (folder.toPath().toString().equals(settings.toString()));
} catch (Settings.SettingsFolderException e) {
assert (false);
} finally {
System.clearProperty("processing.settings.folder");
Files.deleteIfExists(settings);
}
}
}