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.TestWatcherJunit4 testRuleto extract and assert test resources.- Since:
- 3.1.0
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Stringnameprivate java.lang.StringprojectsDirprivate java.lang.StringworkDir
-
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 voidassertDirectoryContents(java.io.File dir, java.lang.String... expectedPaths)static voidassertFileContents(java.io.File basedir, java.lang.String expectedPath, java.lang.String actualPath)static voidcp(java.io.File basedir, java.lang.String from, java.lang.String to)static voidcreate(java.io.File basedir, java.lang.String... paths)java.io.FilegetBasedir(java.lang.String project)Creates new clean copy of test project directory structure.static voidrm(java.io.File basedir, java.lang.String path)protected voidstarting(org.junit.runner.Description d)private static java.lang.StringtoString(java.util.Collection<java.lang.String> strings)static voidtouch(java.io.File file)static voidtouch(java.io.File basedir, java.lang.String path)
-
-
-
Method Detail
-
starting
protected void starting(org.junit.runner.Description d)
- Overrides:
startingin classorg.junit.rules.TestWatcher
-
getBasedir
public java.io.File getBasedir(java.lang.String project) throws java.io.IOExceptionCreates 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
-
-