mirror of
https://github.com/apache/lucene.git
synced 2025-02-09 03:25:15 +00:00
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;
|
import org.junit.runners.model.Statement;
|
||||||
|
|
||||||
public class StoreClassNameRule implements TestRule {
|
public class StoreClassNameRule implements TestRule {
|
||||||
private volatile Class<?> testClass;
|
private volatile Description description;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Statement apply(final Statement s, final Description d) {
|
public Statement apply(final Statement s, final Description d) {
|
||||||
@ -17,10 +17,10 @@ public class StoreClassNameRule implements TestRule {
|
|||||||
@Override
|
@Override
|
||||||
public void evaluate() throws Throwable {
|
public void evaluate() throws Throwable {
|
||||||
try {
|
try {
|
||||||
testClass = d.getTestClass();
|
description = d;
|
||||||
s.evaluate();
|
s.evaluate();
|
||||||
} finally {
|
} finally {
|
||||||
testClass = null;
|
description = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -30,10 +30,10 @@ public class StoreClassNameRule implements TestRule {
|
|||||||
* Returns the test class currently executing in this rule.
|
* Returns the test class currently executing in this rule.
|
||||||
*/
|
*/
|
||||||
public Class<?> getTestClass() {
|
public Class<?> getTestClass() {
|
||||||
Class<?> clz = testClass;
|
Description localDescription = description;
|
||||||
if (clz == null) {
|
if (localDescription == null) {
|
||||||
throw new RuntimeException("The rule is not currently executing.");
|
throw new RuntimeException("The rule is not currently executing.");
|
||||||
}
|
}
|
||||||
return clz;
|
return localDescription.getTestClass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user