public class TestResourceUnavailableException
extends SkipException
This exception should be used by tests that need a particular test resource (i.e., a file that is conventionally
in the src/test/resources
folder, and that available as a classpath resource at runtime) is not
available. It will cause TestNG to mark the test as "skipped" with a suitable message.
Some tests require binary files (such as OSGi bundles) which under Apache conventions are not able to be distributed in our source code release. This exception allows such tests to become "optional" so that they do not cause test failures when running the tests on a source distribution.
Note that the single-string constructors expect the string to be the simple name of the classpath resource that is not available. The exception message is then derived from this. The two-string constructors take both the resource name and an explicit exception message.
Constructor and Description |
---|
TestResourceUnavailableException(java.lang.String resourceName)
Instantiate an exception, giving the name of the unavailable resource.
|
TestResourceUnavailableException(java.lang.String resourceName,
java.lang.String skipMessage)
Instantiate an exception, giving the name of the unavailable resource.
|
TestResourceUnavailableException(java.lang.String resourceName,
java.lang.String skipMessage,
java.lang.Throwable cause)
Instantiate an exception, giving the name of the unavailable resource.
|
TestResourceUnavailableException(java.lang.String resourceName,
java.lang.Throwable cause)
Instantiate an exception, giving the name of the unavailable resource.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getResourceName()
Get the name of the classpath resource that could not be loaded.
|
boolean |
isSkip() |
static void |
throwIfResourceUnavailable(java.lang.Class<?> relativeToClass,
java.lang.String resourceName)
Asserts that a resource is available on the classpath; otherwise, throws
TestResourceUnavailableException
Note that this will use the same classloader that was used to load this class. |
public TestResourceUnavailableException(java.lang.String resourceName)
resourceName
- the name of the resource on the classpath, e.g.
/brooklyn/osgi/brooklyn-test-osgi-entities.jar
public TestResourceUnavailableException(java.lang.String resourceName, java.lang.Throwable cause)
resourceName
- the name of the resource on the classpath, e.g.
/brooklyn/osgi/brooklyn-test-osgi-entities.jar
cause
- the underlying exception that caused this onepublic TestResourceUnavailableException(java.lang.String resourceName, java.lang.String skipMessage)
resourceName
- the name of the resource on the classpath, e.g.
/brooklyn/osgi/brooklyn-test-osgi-entities.jar
skipMessage
- the message associated with the exceptionpublic TestResourceUnavailableException(java.lang.String resourceName, java.lang.String skipMessage, java.lang.Throwable cause)
resourceName
- the name of the resource on the classpath, e.g.
/brooklyn/osgi/brooklyn-test-osgi-entities.jar
skipMessage
- the message associated with the exceptioncause
- the underlying exception that caused this onepublic static void throwIfResourceUnavailable(java.lang.Class<?> relativeToClass, java.lang.String resourceName)
TestResourceUnavailableException
Note that this will use the same classloader that was used to load this class.resourceName
- the classpath resource name, e.g.
/brooklyn/osgi/brooklyn-test-osgi-entities.jar
public java.lang.String getResourceName()
public boolean isSkip()