Should be working
This commit is contained in:
@@ -19,7 +19,7 @@ package sample;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent;
|
||||
import org.springframework.boot.web.servlet.context.ServletWebServerInitializedEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.integration.annotation.MessageEndpoint;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
@@ -31,7 +31,7 @@ import org.springframework.web.client.RestTemplate;
|
||||
*
|
||||
*/
|
||||
@MessageEndpoint public class SampleService implements
|
||||
ApplicationListener<EmbeddedServletContainerInitializedEvent> {
|
||||
ApplicationListener<ServletWebServerInitializedEvent> {
|
||||
private static final Log log = LogFactory.getLog(SampleService.class);
|
||||
|
||||
@Autowired private RestTemplate restTemplate;
|
||||
@@ -43,8 +43,7 @@ import org.springframework.web.client.RestTemplate;
|
||||
this.restTemplate.getForObject("http://localhost:" + this.port + "/foo", String.class);
|
||||
}
|
||||
|
||||
@Override public void onApplicationEvent(
|
||||
EmbeddedServletContainerInitializedEvent event) {
|
||||
this.port = event.getEmbeddedServletContainer().getPort();
|
||||
@Override public void onApplicationEvent(ServletWebServerInitializedEvent event) {
|
||||
this.port = event.getSource().getPort();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,13 +16,10 @@
|
||||
|
||||
package sample;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent;
|
||||
import org.springframework.boot.web.servlet.context.ServletWebServerInitializedEvent;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.SpanAccessor;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
@@ -32,12 +29,15 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
@RestController
|
||||
public class SampleController
|
||||
implements ApplicationListener<EmbeddedServletContainerInitializedEvent> {
|
||||
implements ApplicationListener<ServletWebServerInitializedEvent> {
|
||||
private static final Log log = LogFactory.getLog(SampleController.class);
|
||||
|
||||
@Autowired
|
||||
@@ -118,7 +118,7 @@ public class SampleController
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) {
|
||||
this.port = event.getEmbeddedServletContainer().getPort();
|
||||
public void onApplicationEvent(ServletWebServerInitializedEvent event) {
|
||||
this.port = event.getSource().getPort();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,33 +15,23 @@
|
||||
*/
|
||||
package tools;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.jayway.awaitility.Awaitility;
|
||||
import com.jayway.awaitility.core.ConditionFactory;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.springframework.cloud.sleuth.trace.IntegrationTestSpanContextHolder;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.RequestEntity;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import zipkin.Codec;
|
||||
import zipkin.Span;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.net.URI;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
|
||||
@@ -71,15 +61,15 @@ public abstract class AbstractIntegrationTest {
|
||||
}
|
||||
|
||||
protected Runnable zipkinServerIsUp() {
|
||||
return checkServerHealth("Zipkin Stream Server", this::endpointToCheckZipkinServerHealth);
|
||||
return checkServerHealth(this::endpointToCheckZipkinServerHealth);
|
||||
}
|
||||
|
||||
protected Runnable checkServerHealth(String appName, RequestExchanger requestExchanger) {
|
||||
protected Runnable checkServerHealth(RequestExchanger requestExchanger) {
|
||||
return () -> {
|
||||
ResponseEntity<String> response = requestExchanger.exchange();
|
||||
log.info(String.format("Response from the [%s] health endpoint is [%s]", appName, response));
|
||||
log.info(String.format("Response from the [%s] health endpoint is [%s]", "Zipkin Stream Server", response));
|
||||
then(response.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
log.info(String.format("[%s] is up!", appName));
|
||||
log.info(String.format("[%s] is up!", "Zipkin Stream Server"));
|
||||
};
|
||||
}
|
||||
|
||||
@@ -88,7 +78,7 @@ public abstract class AbstractIntegrationTest {
|
||||
}
|
||||
|
||||
protected ResponseEntity<String> endpointToCheckZipkinServerHealth() {
|
||||
URI uri = URI.create("http://localhost:" +getZipkinServerPort()+"/health");
|
||||
URI uri = URI.create("http://localhost:" +getZipkinServerPort()+"/application/health");
|
||||
log.info(String.format("Sending request to the Zipkin Server [%s]", uri));
|
||||
return exchangeRequest(uri);
|
||||
}
|
||||
|
||||
@@ -16,13 +16,10 @@
|
||||
|
||||
package sample;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent;
|
||||
import org.springframework.boot.web.servlet.context.ServletWebServerInitializedEvent;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.SpanAccessor;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
@@ -32,12 +29,15 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
@RestController
|
||||
public class SampleController implements
|
||||
ApplicationListener<EmbeddedServletContainerInitializedEvent> {
|
||||
ApplicationListener<ServletWebServerInitializedEvent> {
|
||||
|
||||
private static final Log log = LogFactory.getLog(SampleController.class);
|
||||
|
||||
@@ -120,7 +120,7 @@ ApplicationListener<EmbeddedServletContainerInitializedEvent> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) {
|
||||
this.port = event.getEmbeddedServletContainer().getPort();
|
||||
public void onApplicationEvent(ServletWebServerInitializedEvent event) {
|
||||
this.port = event.getSource().getPort();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ spring:
|
||||
application:
|
||||
# This ends up as the service name in zipkin
|
||||
name: testsleuthzipkin
|
||||
zipkin:
|
||||
#zipkin:
|
||||
# Uncomment to send to zipkin, replacing 192.168.99.100 with your zipkin IP address
|
||||
# baseUrl: http://192.168.99.100:9411/
|
||||
sleuth:
|
||||
|
||||
@@ -16,13 +16,10 @@
|
||||
|
||||
package sample;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent;
|
||||
import org.springframework.boot.web.servlet.context.ServletWebServerInitializedEvent;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.SpanAccessor;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
@@ -32,12 +29,15 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
@RestController
|
||||
public class SampleController
|
||||
implements ApplicationListener<EmbeddedServletContainerInitializedEvent> {
|
||||
implements ApplicationListener<ServletWebServerInitializedEvent > {
|
||||
private static final Log log = LogFactory.getLog(SampleController.class);
|
||||
@Autowired
|
||||
private RestTemplate restTemplate;
|
||||
@@ -117,7 +117,7 @@ public class SampleController
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) {
|
||||
this.port = event.getEmbeddedServletContainer().getPort();
|
||||
public void onApplicationEvent(ServletWebServerInitializedEvent event) {
|
||||
this.port = event.getSource().getPort();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user