com.atlassian.confluence.util.test.rules
Class TestResource<T>
java.lang.Object
com.atlassian.confluence.util.test.rules.TestResource<T>
- Type Parameters:
T
- the type of the resource to load
- All Implemented Interfaces:
- org.junit.rules.TestRule
- Direct Known Subclasses:
- XmlResource
public abstract class TestResource<T>
- extends java.lang.Object
- implements org.junit.rules.TestRule
Load a resource via the defining ClassLoader of the given test class.
By default, a resource is located relative to the class, meaning it has to reside in the same folder.
- Since:
- 5.4
Constructor Summary |
TestResource(java.lang.Class testClass,
java.lang.String nameSuffix)
|
Method Summary |
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement statement,
org.junit.runner.Description description)
|
T |
get()
|
protected abstract T |
load(java.io.InputStream testResourceStream)
|
protected java.lang.String |
toFileName(java.lang.String testMethodName)
Composes the file name of the resource based upon a hyphenated version of the test class and method name and the
given name suffix. |
protected java.lang.String |
toRelativePathFromClassLoaderRoot(java.lang.reflect.Method testMethod)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
nameSuffix
protected final java.lang.String nameSuffix
testClass
protected final java.lang.Class testClass
TestResource
public TestResource(java.lang.Class testClass,
java.lang.String nameSuffix)
- Parameters:
testClass
- the class of the test the rule is used fornameSuffix
- the file name is composed of the hyphenated method name and the given suffix
apply
public final org.junit.runners.model.Statement apply(org.junit.runners.model.Statement statement,
org.junit.runner.Description description)
- Specified by:
apply
in interface org.junit.rules.TestRule
load
protected abstract T load(java.io.InputStream testResourceStream)
toRelativePathFromClassLoaderRoot
protected java.lang.String toRelativePathFromClassLoaderRoot(java.lang.reflect.Method testMethod)
toFileName
protected java.lang.String toFileName(java.lang.String testMethodName)
- Composes the file name of the resource based upon a hyphenated version of the test class and method name and the
given name suffix.
Example:
{@code public class VersionedTemplateTest
{
get
public T get()
Copyright © 2003-2014 Atlassian. All Rights Reserved.