Index: src/test/org/apache/lucene/util/InterceptTestCaseEvents.java =================================================================== --- src/test/org/apache/lucene/util/InterceptTestCaseEvents.java (revision 916598) +++ src/test/org/apache/lucene/util/InterceptTestCaseEvents.java (working copy) @@ -1,60 +0,0 @@ -package org.apache.lucene.util; - -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -import org.junit.rules.TestWatchman; -import org.junit.runners.model.FrameworkMethod; - -import java.lang.reflect.Method; - - -public final class InterceptTestCaseEvents extends TestWatchman { - private Object obj; - - public InterceptTestCaseEvents(Object obj) { - this.obj = obj; - } - - @Override - public void failed(Throwable e, FrameworkMethod method) { - try { - Method reporter = method.getMethod().getDeclaringClass().getMethod("reportAdditionalFailureInfo",(Class[]) null); - reporter.invoke(obj, (Object[])null); - } catch (Exception e1) { - System.err.println("InterceptTestCaseEvents.failed(). Cannot invoke reportAdditionalFailureInfo() method in" + - " consuming class, is it declared and public?"); - } - super.failed(e, method); - } - - @Override - public void finished(FrameworkMethod method) { - super.finished(method); - } - - @Override - public void starting(FrameworkMethod method) { - super.starting(method); - } - - @Override - public void succeeded(FrameworkMethod method) { - super.succeeded(method); - } -} Index: src/test/org/apache/lucene/util/LuceneTestCaseJ4.java =================================================================== --- src/test/org/apache/lucene/util/LuceneTestCaseJ4.java (revision 916598) +++ src/test/org/apache/lucene/util/LuceneTestCaseJ4.java (working copy) @@ -25,6 +25,8 @@ import org.junit.After; import org.junit.Before; import org.junit.Rule; +import org.junit.rules.TestWatchman; +import org.junit.runners.model.FrameworkMethod; import java.io.PrintStream; import java.util.Arrays; @@ -98,14 +100,21 @@ // Think of this as start/end/success/failed // events. @Rule - public InterceptTestCaseEvents intercept = new InterceptTestCaseEvents(this); + public final TestWatchman intercept = new TestWatchman() { - public LuceneTestCaseJ4() { - } + @Override + public void failed(Throwable e, FrameworkMethod method) { + reportAdditionalFailureInfo(); + super.failed(e, method); + } - public LuceneTestCaseJ4(String name) { - this.name = name; - } + @Override + public void starting(FrameworkMethod method) { + LuceneTestCaseJ4.this.name = method.getName(); + super.starting(method); + } + + }; @Before public void setUp() throws Exception { @@ -291,6 +300,6 @@ // static members private static final Random seedRnd = new Random(); - private String name = ""; + private String name = ""; }