Upgrades to JUnit5; fixes gh-1567

This commit is contained in:
Marcin Grzejszczak
2020-03-03 19:53:50 +01:00
parent a59bfb00cf
commit 3ce018bc51
129 changed files with 482 additions and 672 deletions

View File

@@ -19,35 +19,32 @@ package sample;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.assertj.core.api.BDDAssertions;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.system.OutputCaptureRule;
import org.springframework.boot.test.system.CapturedOutput;
import org.springframework.boot.test.system.OutputCaptureExtension;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SampleFeignApplication.class)
@TestPropertySource(properties = "sample.zipkin.enabled=false")
@ExtendWith(OutputCaptureExtension.class)
public class SampleFeignApplicationTests {
private static final Log log = LogFactory.getLog(SampleFeignApplicationTests.class);
@Rule
public OutputCaptureRule outputCapture = new OutputCaptureRule();
@Test
public void contextLoads() {
}
// https://github.com/spring-cloud/spring-cloud-sleuth/issues/1396
@Test
public void should_not_pass_dash_as_default_service_name() {
public void should_not_pass_dash_as_default_service_name(
CapturedOutput outputCapture) {
log.info("HELLO");
BDDAssertions.then(this.outputCapture.toString()).doesNotContain("INFO [-,,,]");
BDDAssertions.then(outputCapture.toString()).doesNotContain("INFO [-,,,]");
}
}

View File

@@ -23,9 +23,8 @@ import java.util.stream.Collectors;
import brave.sampler.Sampler;
import integration.MessagingApplicationTests.IntegrationSpanCollectorConfig;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import sample.SampleMessagingApplication;
import tools.AbstractIntegrationTest;
import tools.SpanUtil;
@@ -38,12 +37,10 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.assertj.core.api.BDDAssertions.then;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(
classes = { IntegrationSpanCollectorConfig.class,
SampleMessagingApplication.class },
@@ -59,7 +56,7 @@ public class MessagingApplicationTests extends AbstractIntegrationTest {
@Autowired
IntegrationTestZipkinSpanReporter integrationTestSpanCollector;
@After
@AfterEach
public void cleanup() {
this.integrationTestSpanCollector.hashedSpans.clear();
}

View File

@@ -16,14 +16,11 @@
package sample;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SampleMessagingApplication.class)
@TestPropertySource(properties = "sample.zipkin.enabled=false")
public class SampleMessagingApplicationTests {

View File

@@ -752,7 +752,6 @@ SockJS = (function () {
on_unload[ref]();
delete on_unload[ref];
}
;
};
var unload_triggered = function () {
@@ -821,7 +820,6 @@ SockJS = (function () {
}
} catch (x) {
}
;
};
iframe.src = iframe_url;
@@ -881,7 +879,6 @@ SockJS = (function () {
}
} catch (x) {
}
;
};
doc.open();
@@ -928,14 +925,12 @@ SockJS = (function () {
that.xhr = new XMLHttpRequest();
} catch (x) {
}
;
if (!that.xhr) {
try {
that.xhr = new _window.ActiveXObject('Microsoft.XMLHTTP');
} catch (x) {
}
;
}
if (_window.ActiveXObject || _window.XDomainRequest) {
// IE8 caches even POSTs
@@ -955,7 +950,6 @@ SockJS = (function () {
that._cleanup();
return;
}
;
if (!opts || !opts.no_credentials) {
// Mozilla docs says https://developer.mozilla.org/en/XMLHttpRequest :
@@ -980,7 +974,6 @@ SockJS = (function () {
var text = x.responseText;
} catch (x) {
}
;
// IE returns 1223 for 204: https://bugs.jquery.com/ticket/1450
if (status === 1223) status = 204;
@@ -1017,7 +1010,6 @@ SockJS = (function () {
that.xhr.abort();
} catch (x) {
}
;
}
that.unload_ref = that.xhr = null;
};
@@ -1099,7 +1091,6 @@ SockJS = (function () {
that.xdr.abort();
} catch (x) {
}
;
}
that.unload_ref = that.xdr = null;
};
@@ -2241,7 +2232,6 @@ SockJS = (function () {
// IE 7
return new InfoReceiverFake();
}
;
};

View File

@@ -16,15 +16,12 @@
package sample;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SampleWebsocketApplication.class)
@WebAppConfiguration
@TestPropertySource(properties = "sample.zipkin.enabled=false")

View File

@@ -16,6 +16,7 @@
package integration;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -29,10 +30,9 @@ import integration.ZipkinTests.WaitUntilZipkinIsUpConfig;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
import org.junit.BeforeClass;
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 sample.SampleZipkinApplication;
import tools.AbstractIntegrationTest;
import tools.SpanUtil;
@@ -47,21 +47,23 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.assertj.core.api.BDDAssertions.then;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(
classes = { WaitUntilZipkinIsUpConfig.class, SampleZipkinApplication.class },
webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@TestPropertySource(properties = { "sample.zipkin.enabled=true" })
public class ZipkinTests extends AbstractIntegrationTest {
@ClassRule
public static final MockWebServer zipkin = new MockWebServer();
@AfterAll
static void clean() throws IOException {
zipkin.close();
}
private static final String APP_NAME = "testsleuthzipkin";
@Autowired
@@ -72,8 +74,9 @@ public class ZipkinTests extends AbstractIntegrationTest {
private String sampleAppUrl = "http://localhost:" + this.port;
@BeforeClass
public static void setup() {
@BeforeAll
public static void setup() throws IOException {
zipkin.start();
// enqueues a request for async reporter health check
zipkin.enqueue(new MockResponse());
}

View File

@@ -16,15 +16,12 @@
package sample;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SampleZipkinApplication.class)
@WebAppConfiguration
@TestPropertySource(properties = "sample.zipkin.enabled=false")

View File

@@ -16,13 +16,10 @@
package sample;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SampleSleuthApplication.class)
public class SampleSleuthApplicationTests {