Class TestResources
- java.lang.Object
-
- org.junit.rules.TestWatcher
-
- org.apache.maven.plugin.testing.resources.TestResources
-
- All Implemented Interfaces:
org.junit.rules.TestRule
public class TestResources extends org.junit.rules.TestWatcher
Junit4 testRule
to extract and assert test resources.- Since:
- 3.1.0
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
name
private java.lang.String
projectsDir
private java.lang.String
workDir
-
Constructor Summary
Constructors Constructor Description TestResources()
TestResources(java.lang.String projectsDir, java.lang.String workDir)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
assertDirectoryContents(java.io.File dir, java.lang.String... expectedPaths)
static void
assertFileContents(java.io.File basedir, java.lang.String expectedPath, java.lang.String actualPath)
static void
cp(java.io.File basedir, java.lang.String from, java.lang.String to)
static void
create(java.io.File basedir, java.lang.String... paths)
java.io.File
getBasedir(java.lang.String project)
Creates new clean copy of test project directory structure.static void
rm(java.io.File basedir, java.lang.String path)
protected void
starting(org.junit.runner.Description d)
private static java.lang.String
toString(java.util.Collection<java.lang.String> strings)
static void
touch(java.io.File file)
static void
touch(java.io.File basedir, java.lang.String path)
-
-
-
Method Detail
-
starting
protected void starting(org.junit.runner.Description d)
- Overrides:
starting
in classorg.junit.rules.TestWatcher
-
getBasedir
public java.io.File getBasedir(java.lang.String project) throws java.io.IOException
Creates new clean copy of test project directory structure. The copy is named after both the test being executed and test project name, which allows the same test project can be used by multiple tests and by different instances of the same parametrized tests.
TODO Provide alternative working directory naming for Windows, which still limits path names to ~250 charecters- Throws:
java.io.IOException
-
cp
public static void cp(java.io.File basedir, java.lang.String from, java.lang.String to) throws java.io.IOException
- Throws:
java.io.IOException
-
assertFileContents
public static void assertFileContents(java.io.File basedir, java.lang.String expectedPath, java.lang.String actualPath) throws java.io.IOException
- Throws:
java.io.IOException
-
assertDirectoryContents
public static void assertDirectoryContents(java.io.File dir, java.lang.String... expectedPaths)
-
toString
private static java.lang.String toString(java.util.Collection<java.lang.String> strings)
-
touch
public static void touch(java.io.File basedir, java.lang.String path) throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
-
touch
public static void touch(java.io.File file) throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
-
rm
public static void rm(java.io.File basedir, java.lang.String path)
-
create
public static void create(java.io.File basedir, java.lang.String... paths) throws java.io.IOException
- Throws:
java.io.IOException
- Since:
- 3.2.0
-
-