Fix some warnings
[nikiroo-utils.git] / src / be / nikiroo / fanfix / test / Test.java
1 package be.nikiroo.fanfix.test;
2
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.Instance;
9 import be.nikiroo.fanfix.bundles.ConfigBundle;
10 import be.nikiroo.utils.IOUtils;
11 import be.nikiroo.utils.resources.Bundles;
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 /**
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 */
27 public Test(String[] args) {
28 super("Fanfix", args);
29 Instance.setTraceHandler(null);
30 addSeries(new BasicSupportTest(args));
31 addSeries(new LibraryTest(args));
32 }
33
34 /**
35 * Main entry point of the program.
36 *
37 * @param args
38 * the arguments passed to the {@link TestLauncher}s.
39 * @throws IOException
40 * in case of I/O error
41 */
42 static public void main(String[] args) throws IOException {
43 File tmpConfig = File.createTempFile("fanfix-config_", ".test");
44 File tmpCache = File.createTempFile("fanfix-cache_", ".test");
45 tmpConfig.delete();
46 tmpConfig.mkdir();
47 tmpCache.delete();
48 tmpCache.mkdir();
49
50 FileOutputStream out = null;
51 try {
52 out = new FileOutputStream(new File(tmpConfig, "config.properties"));
53 Properties props = new Properties();
54 props.setProperty("CACHE_DIR", tmpCache.getAbsolutePath());
55 props.store(out, null);
56 } finally {
57 if (out != null) {
58 out.close();
59 }
60 }
61
62 ConfigBundle config = new ConfigBundle();
63 Bundles.setDirectory(tmpConfig.getAbsolutePath());
64 config.updateFile(tmpConfig.getPath());
65
66 System.setProperty("CONFIG_DIR", tmpConfig.getAbsolutePath());
67
68 int result = new Test(args).launch();
69
70 IOUtils.deltree(tmpConfig);
71 IOUtils.deltree(tmpCache);
72
73 System.exit(result);
74 }
75 }