[#148] Resetting custom hystrix strategy before tests

fixes #148
This commit is contained in:
Marcin Grzejszczak
2016-02-09 10:23:57 +01:00
parent bc48a0094e
commit ebfe276ced
2 changed files with 12 additions and 4 deletions

View File

@@ -18,7 +18,7 @@ public class SpanAssert extends AbstractAssert<SpanAssert, Span> {
return new SpanAssert(actual);
}
public SpanAssert hasTraceIdEqualTo(long traceId) {
public SpanAssert hasTraceIdEqualTo(Long traceId) {
isNotNull();
if (!Objects.equals(this.actual.getTraceId(), traceId)) {
String message = String.format("Expected span's traceId to be <%s> but was <%s>", traceId, this.actual.getTraceId());

View File

@@ -1,11 +1,9 @@
package org.springframework.cloud.sleuth.instrument.hystrix;
import static org.assertj.core.api.BDDAssertions.then;
import static org.springframework.cloud.sleuth.assertions.SleuthAssertions.then;
import java.util.concurrent.atomic.AtomicReference;
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -22,6 +20,10 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.jayway.awaitility.Awaitility;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.strategy.HystrixPlugins;
import static org.assertj.core.api.BDDAssertions.then;
import static org.springframework.cloud.sleuth.assertions.SleuthAssertions.then;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = {
@@ -34,9 +36,15 @@ public class HystrixAnnotationsIntegrationTests {
@Autowired
Tracer tracer;
@BeforeClass
public static void reset() {
HystrixPlugins.reset();
}
@After
public void cleanTrace() {
TestSpanContextHolder.removeCurrentSpan();
HystrixPlugins.reset();
}
@Test