Debian Codegraph @

test/func/Base.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2008 Steve Ratcliffe
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 *
14 * Author: Steve Ratcliffe
15 * Create date: 11-Jan-2009
16 */
17 package func;
18
19 import java.io.File;
20 import java.io.FileNotFoundException;
21
22 import uk.me.parabola.imgfmt.fs.FileSystem;
23 import uk.me.parabola.imgfmt.sys.ImgFS;
24
25 import func.lib.Args;
26 import func.lib.TestUtils;
27 import org.junit.After;
28 import org.junit.Before;
29
30 import static org.junit.Assert.*;
31
32 /**
33 * Base class for tests with some useful routines. It ensures that created
34 * files are deleted before the test starts.
35 *
36 * @author Steve Ratcliffe
37 */
38 public class Base {
39 @Before
40 public void baseSetup() {
41 TestUtils.deleteOutputFiles();
42 }
43
44 @After
45 public void baseTeardown() {
46 TestUtils.closeFiles();
47 }
48
49 protected void checkStdFile() {
50 assertTrue("std output file exists", new File(Args.DEF_MAP_FILENAME).exists());
51 }
52
53 protected void checkNoStdFile() {
54 assertFalse("std output file exists", new File(Args.DEF_MAP_FILENAME).exists());
55 }
56
57 protected FileSystem openFs(String filename) throws FileNotFoundException {
58 FileSystem fs = ImgFS.openFs(filename);
59 TestUtils.registerFile(fs);
60 return fs;
61 }
62 }