Commit | Line | Data |
---|---|---|
92fb0719 NR |
1 | package be.nikiroo.fanfix.test; |
2 | ||
22848428 NR |
3 | import java.io.File; |
4 | import java.io.FileOutputStream; | |
5 | import java.io.IOException; | |
6 | import java.util.Properties; | |
7 | ||
8 | import be.nikiroo.fanfix.bundles.ConfigBundle; | |
9 | import be.nikiroo.utils.IOUtils; | |
10 | import be.nikiroo.utils.resources.Bundles; | |
92fb0719 NR |
11 | import be.nikiroo.utils.test.TestLauncher; |
12 | ||
13 | /** | |
14 | * Tests for Fanfix. | |
15 | * | |
16 | * @author niki | |
17 | */ | |
18 | public class Test extends TestLauncher { | |
19 | public Test(String[] args) { | |
68e370a4 NR |
20 | super("Fanfix", args); |
21 | addSeries(new BasicSupportTest(args)); | |
92fb0719 NR |
22 | } |
23 | ||
24 | /** | |
25 | * Main entry point of the program. | |
26 | * | |
27 | * @param args | |
28 | * the arguments passed to the {@link TestLauncher}s. | |
22848428 | 29 | * @throws IOException |
92fb0719 | 30 | */ |
22848428 NR |
31 | static public void main(String[] args) throws IOException { |
32 | File tmpConfig = File.createTempFile("fanfix-config_", ".test"); | |
33 | File tmpCache = File.createTempFile("fanfix-cache_", ".test"); | |
34 | tmpConfig.delete(); | |
35 | tmpConfig.mkdir(); | |
36 | tmpCache.delete(); | |
37 | tmpCache.mkdir(); | |
38 | ||
39 | FileOutputStream out = new FileOutputStream(new File(tmpConfig, | |
40 | "config.properties")); | |
41 | Properties props = new Properties(); | |
42 | props.setProperty("CACHE_DIR", tmpCache.getAbsolutePath()); | |
43 | props.store(out, null); | |
44 | out.close(); | |
45 | ||
46 | ConfigBundle config = new ConfigBundle(); | |
47 | Bundles.setDirectory(tmpConfig.getAbsolutePath()); | |
48 | config.updateFile(tmpConfig.getPath()); | |
49 | ||
50 | System.setProperty("CONFIG_DIR", tmpConfig.getAbsolutePath()); | |
51 | ||
52 | int result = new Test(args).launch(); | |
53 | ||
54 | IOUtils.deltree(tmpConfig); | |
55 | IOUtils.deltree(tmpCache); | |
56 | ||
57 | System.exit(result); | |
92fb0719 NR |
58 | } |
59 | } |