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; | |
2aac79c7 | 11 | import be.nikiroo.utils.TempFiles; |
22848428 | 12 | import be.nikiroo.utils.resources.Bundles; |
92fb0719 NR |
13 | import be.nikiroo.utils.test.TestLauncher; |
14 | ||
15 | /** | |
16 | * Tests for Fanfix. | |
17 | * | |
18 | * @author niki | |
19 | */ | |
20 | public class Test extends TestLauncher { | |
2aac79c7 NR |
21 | /** |
22 | * The temporary files handler. | |
23 | */ | |
24 | static TempFiles tempFiles; | |
25 | ||
2a25f781 NR |
26 | /** |
27 | * Create the Fanfix {@link TestLauncher}. | |
28 | * | |
29 | * @param args | |
30 | * the arguments to configure the number of columns and the ok/ko | |
31 | * {@link String}s | |
32 | */ | |
92fb0719 | 33 | public Test(String[] args) { |
68e370a4 | 34 | super("Fanfix", args); |
581d42c0 | 35 | Instance.setTraceHandler(null); |
8d59ce07 NR |
36 | addSeries(new BasicSupportUtilitiesTest(args)); |
37 | addSeries(new BasicSupportDeprecatedTest(args)); | |
6cac0e45 | 38 | addSeries(new LibraryTest(args)); |
f7460e4c | 39 | addSeries(new ConversionTest(args)); |
92fb0719 NR |
40 | } |
41 | ||
42 | /** | |
43 | * Main entry point of the program. | |
44 | * | |
45 | * @param args | |
46 | * the arguments passed to the {@link TestLauncher}s. | |
22848428 | 47 | * @throws IOException |
2a25f781 | 48 | * in case of I/O error |
92fb0719 | 49 | */ |
22848428 | 50 | static public void main(String[] args) throws IOException { |
8d59ce07 | 51 | Instance.init(); |
f1ce03f7 | 52 | //Instance.getCache().setOffline(true); |
8d59ce07 | 53 | |
2aac79c7 NR |
54 | int result = 0; |
55 | tempFiles = new TempFiles("fanfix-test"); | |
9fe3f177 | 56 | try { |
2aac79c7 NR |
57 | File tmpConfig = tempFiles.createTempDir("fanfix-config"); |
58 | File tmpCache = tempFiles.createTempDir("fanfix-cache"); | |
59 | ||
60 | FileOutputStream out = null; | |
61 | try { | |
62 | out = new FileOutputStream(new File(tmpConfig, | |
63 | "config.properties")); | |
64 | Properties props = new Properties(); | |
65 | props.setProperty("CACHE_DIR", tmpCache.getAbsolutePath()); | |
66 | props.store(out, null); | |
67 | } finally { | |
68 | if (out != null) { | |
69 | out.close(); | |
70 | } | |
9fe3f177 | 71 | } |
22848428 | 72 | |
2aac79c7 NR |
73 | ConfigBundle config = new ConfigBundle(); |
74 | Bundles.setDirectory(tmpConfig.getAbsolutePath()); | |
75 | config.updateFile(tmpConfig.getPath()); | |
22848428 | 76 | |
2aac79c7 | 77 | System.setProperty("CONFIG_DIR", tmpConfig.getAbsolutePath()); |
22848428 | 78 | |
2aac79c7 | 79 | result = new Test(args).launch(); |
22848428 | 80 | |
2aac79c7 NR |
81 | IOUtils.deltree(tmpConfig); |
82 | IOUtils.deltree(tmpCache); | |
83 | } finally { | |
84 | // Test temp files | |
85 | tempFiles.close(); | |
86 | ||
87 | // This is usually done in Fanfix.Main: | |
88 | Instance.getTempFiles().close(); | |
89 | } | |
22848428 NR |
90 | |
91 | System.exit(result); | |
92fb0719 NR |
92 | } |
93 | } |