From f3ce19d1c5be34575adeaed0cf991a609ac8a10f Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Thu, 23 Jul 2015 19:31:58 +0200 Subject: Reorganised the test folder a bit more, started working on CLI tests, a bit tricky, will require refactoring --- .../equalparts/cardbase/testutils/TestUtils.java | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/eu/equalparts/cardbase/testutils/TestUtils.java (limited to 'test/eu/equalparts/cardbase/testutils/TestUtils.java') 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..."); + } + } + + + +} -- cgit v1.2.3