Moving testloggingutil into test utilities
This commit is contained in:
parent
f1848fb1ad
commit
886f3f442b
|
@ -15,7 +15,7 @@ import ca.uhn.fhir.jpa.term.VersionIndependentConcept;
|
|||
import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener;
|
||||
import ca.uhn.fhir.jpa.util.ExpungeOptions;
|
||||
import ca.uhn.fhir.jpa.util.JpaConstants;
|
||||
import ca.uhn.fhir.jpa.util.LoggingRule;
|
||||
import ca.uhn.fhir.test.utilities.LoggingRule;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Bundle;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Bundle.Entry;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
|
@ -25,7 +25,6 @@ import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
|||
import ca.uhn.fhir.util.BundleUtil;
|
||||
import ca.uhn.fhir.util.StopWatch;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import com.google.common.base.Charsets;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.Session;
|
||||
|
@ -56,7 +55,6 @@ import java.util.*;
|
|||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static ca.uhn.fhir.util.TestUtil.randomizeLocale;
|
||||
|
|
|
@ -171,7 +171,7 @@ public class PointcutLatch implements IAnonymousInterceptor, IPointcutLatch {
|
|||
super(getName() + ": " + message + " called with values: " + hookParamsToString(theArgs));
|
||||
}
|
||||
|
||||
PointcutLatchException(String message) {
|
||||
public PointcutLatchException(String message) {
|
||||
super(getName() + ": " + message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,10 @@
|
|||
<artifactId>spring-context</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package ca.uhn.fhir.jpa.util;
|
||||
package ca.uhn.fhir.test.utilities;
|
||||
|
||||
import org.junit.rules.TestRule;
|
||||
import org.junit.runner.Description;
|
||||
|
@ -40,19 +40,22 @@ public class LoggingRule implements TestRule {
|
|||
* @param description A description of the test implemented in <code>statement</code>.
|
||||
* @return The modified statement.
|
||||
*/
|
||||
public Statement apply(final Statement statement, final Description description) {
|
||||
@Override
|
||||
public Statement apply(final Statement statement, final Description description) {
|
||||
return new Statement() {
|
||||
@Override
|
||||
public void evaluate() throws Throwable {
|
||||
final Logger logger = LoggerFactory.getLogger(description.getTestClass());
|
||||
logger.info(MessageFormat.format("Starting test case [{0}]", description.getDisplayName()));
|
||||
boolean success = false;
|
||||
try {
|
||||
statement.evaluate();
|
||||
success = true;
|
||||
} catch (final Throwable e) {
|
||||
logger.error(MessageFormat.format("Exception thrown in test case [{0}]: {1}", description.getDisplayName(), e.toString()), e);
|
||||
throw e;
|
||||
} finally {
|
||||
logger.info(MessageFormat.format("Finished test case [{0}]", description.getDisplayName()));
|
||||
logger.info(MessageFormat.format("Finished test case [{0}] (success={1})", description.getDisplayName(), success));
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue