9422
|
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
|
2 * Software engineering by |
|
3 * Björnsen Beratende Ingenieure GmbH |
|
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt |
|
5 * |
|
6 * This file is Free Software under the GNU AGPL (>=v3) |
|
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
|
8 * documentation coming with Dive4Elements River for details. |
|
9 */ |
|
10 package test; |
|
11 |
9570
|
12 import java.io.File; |
|
13 import java.io.IOException; |
|
14 import java.util.Iterator; |
|
15 |
|
16 import org.apache.commons.io.FileUtils; |
|
17 import org.junit.AfterClass; |
|
18 import org.junit.BeforeClass; |
|
19 |
9422
|
20 /** |
|
21 * @author Domenico Nardi Tironi |
|
22 * |
|
23 */ |
|
24 public abstract class AbstractBerechnungsartenTester { |
|
25 |
|
26 // for common Settings |
|
27 // |
9570
|
28 protected static File testFolder; |
|
29 |
9567
|
30 protected enum FileExportBehaviour { |
|
31 do_not_override, export_all, export_none; |
|
32 // do_not_override: file export is set individually (not overridden) |
9422
|
33 // true: all test files created by running jUnit-Tests will be written to disk |
|
34 // false: no file will be exported |
9567
|
35 }; |
9422
|
36 |
|
37 public static enum River { |
|
38 Beispielfluss, Rhein, Elbe |
|
39 }; |
|
40 |
9570
|
41 @BeforeClass |
|
42 public static final void createTempFolder() { |
|
43 // windows: C:\Users\USER_NAME\AppData\Local\Temp |
|
44 if (testFolder == null) { |
|
45 testFolder = new File(FileUtils.getTempDirectory(), "FlysTestFolder"); |
|
46 if (!testFolder.isDirectory()) |
|
47 testFolder.mkdir(); |
|
48 } |
|
49 } |
|
50 |
|
51 @AfterClass |
|
52 public static void deleteTempFolder() { |
|
53 |
|
54 testFolder = new File(FileUtils.getTempDirectory(), "FlysTestFolder"); |
|
55 if (testFolder.isDirectory() && testFolder.exists()) { |
|
56 |
|
57 try { |
|
58 final Iterator<File> test = FileUtils.iterateFiles(testFolder, null, true); |
|
59 if (!test.hasNext()) { |
|
60 FileUtils.deleteDirectory(testFolder); |
|
61 |
|
62 testFolder = null; |
|
63 } |
|
64 } |
|
65 catch (final IOException e) { |
|
66 e.printStackTrace(); |
|
67 } |
|
68 } |
|
69 } |
9422
|
70 } |