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 { | |
2a25f781 NR |
20 | /** |
21 | * Create the Fanfix {@link TestLauncher}. | |
22 | * | |
23 | * @param args | |
24 | * the arguments to configure the number of columns and the ok/ko | |
25 | * {@link String}s | |
26 | */ | |
92fb0719 | 27 | public Test(String[] args) { |
68e370a4 | 28 | super("Fanfix", args); |
581d42c0 | 29 | Instance.setTraceHandler(null); |
68e370a4 | 30 | addSeries(new BasicSupportTest(args)); |
6cac0e45 | 31 | addSeries(new LibraryTest(args)); |
f7460e4c | 32 | addSeries(new ConversionTest(args)); |
92fb0719 NR |
33 | } |
34 | ||
35 | /** | |
36 | * Main entry point of the program. | |
37 | * | |
38 | * @param args | |
39 | * the arguments passed to the {@link TestLauncher}s. | |
22848428 | 40 | * @throws IOException |
2a25f781 | 41 | * in case of I/O error |
92fb0719 | 42 | */ |
22848428 NR |
43 | static public void main(String[] args) throws IOException { |
44 | File tmpConfig = File.createTempFile("fanfix-config_", ".test"); | |
45 | File tmpCache = File.createTempFile("fanfix-cache_", ".test"); | |
46 | tmpConfig.delete(); | |
47 | tmpConfig.mkdir(); | |
48 | tmpCache.delete(); | |
49 | tmpCache.mkdir(); | |
50 | ||
9fe3f177 NR |
51 | FileOutputStream out = null; |
52 | try { | |
53 | out = new FileOutputStream(new File(tmpConfig, "config.properties")); | |
54 | Properties props = new Properties(); | |
55 | props.setProperty("CACHE_DIR", tmpCache.getAbsolutePath()); | |
56 | props.store(out, null); | |
57 | } finally { | |
58 | if (out != null) { | |
59 | out.close(); | |
60 | } | |
61 | } | |
22848428 NR |
62 | |
63 | ConfigBundle config = new ConfigBundle(); | |
64 | Bundles.setDirectory(tmpConfig.getAbsolutePath()); | |
65 | config.updateFile(tmpConfig.getPath()); | |
66 | ||
67 | System.setProperty("CONFIG_DIR", tmpConfig.getAbsolutePath()); | |
68 | ||
69 | int result = new Test(args).launch(); | |
70 | ||
71 | IOUtils.deltree(tmpConfig); | |
72 | IOUtils.deltree(tmpCache); | |
73 | ||
74 | System.exit(result); | |
92fb0719 NR |
75 | } |
76 | } |