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