Upgrades to JUnit5; fixes gh-1567
This commit is contained in:
@@ -21,7 +21,7 @@ import java.net.URI;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.sleuth.zipkin2;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import brave.Span;
|
||||
@@ -27,10 +28,9 @@ import brave.sampler.Sampler;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import okhttp3.mockwebserver.RecordedRequest;
|
||||
import org.awaitility.Awaitility;
|
||||
import org.junit.After;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import zipkin2.Call;
|
||||
import zipkin2.codec.Encoding;
|
||||
import zipkin2.reporter.AsyncReporter;
|
||||
@@ -60,17 +60,23 @@ import static org.assertj.core.api.BDDAssertions.then;
|
||||
*/
|
||||
public class ZipkinAutoConfigurationTests {
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Rule
|
||||
public MockWebServer server = new MockWebServer();
|
||||
|
||||
@BeforeEach
|
||||
void setup() throws IOException {
|
||||
server.start();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void clean() throws IOException {
|
||||
server.close();
|
||||
}
|
||||
|
||||
MockEnvironment environment = new MockEnvironment();
|
||||
|
||||
AnnotationConfigApplicationContext context;
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void close() {
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
|
||||
@@ -25,9 +25,9 @@ import brave.Tracing;
|
||||
import brave.sampler.Sampler;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import org.awaitility.Awaitility;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -37,11 +37,9 @@ import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
|
||||
import org.springframework.cloud.client.loadbalancer.LoadBalancerRequest;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = ZipkinDiscoveryClientTests.Config.class, properties = {
|
||||
"spring.zipkin.baseUrl=https://zipkin/", "spring.zipkin.sender.type=web" // override
|
||||
// default
|
||||
@@ -55,9 +53,18 @@ import static org.assertj.core.api.BDDAssertions.then;
|
||||
})
|
||||
public class ZipkinDiscoveryClientTests {
|
||||
|
||||
@ClassRule
|
||||
public static MockWebServer ZIPKIN_RULE = new MockWebServer();
|
||||
|
||||
@BeforeAll
|
||||
static void setup() throws IOException {
|
||||
ZIPKIN_RULE.start();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void clean() throws IOException {
|
||||
ZIPKIN_RULE.close();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
Tracing tracing;
|
||||
|
||||
|
||||
@@ -16,15 +16,12 @@
|
||||
|
||||
package org.springframework.cloud.sleuth.zipkin2;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = ZipkinWithDisabledSleuthTests.Config.class)
|
||||
@TestPropertySource(properties = "spring.sleuth.enabled=false")
|
||||
public class ZipkinWithDisabledSleuthTests {
|
||||
|
||||
@@ -16,13 +16,14 @@
|
||||
|
||||
package org.springframework.cloud.sleuth.zipkin2.sender;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import okhttp3.mockwebserver.RecordedRequest;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import zipkin2.Call;
|
||||
import zipkin2.Endpoint;
|
||||
import zipkin2.Span;
|
||||
@@ -46,9 +47,13 @@ public class RestTemplateSenderTest {
|
||||
.timestamp(1472470996250000L).duration(100000L).putTag("http.method", "GET")
|
||||
.putTag("http.path", "/backend").build();
|
||||
|
||||
@Rule
|
||||
public MockWebServer server = new MockWebServer();
|
||||
|
||||
@AfterEach
|
||||
void clean() throws IOException {
|
||||
server.close();
|
||||
}
|
||||
|
||||
String endpoint = this.server.url("/api/v2/spans").toString();
|
||||
|
||||
RestTemplateSender sender = new RestTemplateSender(new RestTemplate(), this.endpoint,
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.cloud.sleuth.zipkin2.sender;
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
|
||||
Reference in New Issue
Block a user