aboutsummaryrefslogtreecommitdiffstats
path: root/test/eu/equalparts/cardbase/testutils/TestUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'test/eu/equalparts/cardbase/testutils/TestUtils.java')
-rw-r--r--test/eu/equalparts/cardbase/testutils/TestUtils.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/eu/equalparts/cardbase/testutils/TestUtils.java b/test/eu/equalparts/cardbase/testutils/TestUtils.java
new file mode 100644
index 0000000..ba590c8
--- /dev/null
+++ b/test/eu/equalparts/cardbase/testutils/TestUtils.java
@@ -0,0 +1,24 @@
+package eu.equalparts.cardbase.testutils;
+
+public class TestUtils {
+
+ public static TestFile createValidTestFile(String fileName) throws Exception {
+ TestFile testFile = new TestFile(fileName);
+ if (!testFile.exists()) {
+ if (testFile.createNewFile()) {
+ if (testFile.canWrite()) {
+ return testFile;
+ } else {
+ throw new IllegalArgumentException("Cannot write to " + testFile.getAbsolutePath() + ", aborting...");
+ }
+ } else {
+ throw new IllegalArgumentException(testFile.getAbsolutePath() + " could not be created, aborting...");
+ }
+ } else {
+ throw new IllegalArgumentException(testFile.getAbsolutePath() + " already exists, aborting...");
+ }
+ }
+
+
+
+}