mirror of https://github.com/apache/lucene.git
Don't load the class before evaluation of a subrule, invoke lazily.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1298925 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9c61a0e8ce
commit
09d422f14f
|
@ -5,7 +5,7 @@ import org.junit.runner.Description;
|
|||
import org.junit.runners.model.Statement;
|
||||
|
||||
public class StoreClassNameRule implements TestRule {
|
||||
private volatile Class<?> testClass;
|
||||
private volatile Description description;
|
||||
|
||||
@Override
|
||||
public Statement apply(final Statement s, final Description d) {
|
||||
|
@ -17,10 +17,10 @@ public class StoreClassNameRule implements TestRule {
|
|||
@Override
|
||||
public void evaluate() throws Throwable {
|
||||
try {
|
||||
testClass = d.getTestClass();
|
||||
description = d;
|
||||
s.evaluate();
|
||||
} finally {
|
||||
testClass = null;
|
||||
description = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -30,10 +30,10 @@ public class StoreClassNameRule implements TestRule {
|
|||
* Returns the test class currently executing in this rule.
|
||||
*/
|
||||
public Class<?> getTestClass() {
|
||||
Class<?> clz = testClass;
|
||||
if (clz == null) {
|
||||
Description localDescription = description;
|
||||
if (localDescription == null) {
|
||||
throw new RuntimeException("The rule is not currently executing.");
|
||||
}
|
||||
return clz;
|
||||
return localDescription.getTestClass();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue