-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds spring-beans context test and defaults to Spring 5 (#265)
This defaults the spring-beans version to Spring 5, and adds invoker tests for the following: * spring floor version (2.5) continues to work * spring java config (via spring-context) works Closes #212 Signed-off-by: Adrian Cole <[email protected]>
- Loading branch information
1 parent
fcc67bb
commit 22b6727
Showing
9 changed files
with
410 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# spring_context | ||
This tests that the zipkin2.reporter.beans can be using with Java Config. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright The OpenZipkin Authors | ||
SPDX-License-Identifier: Apache-2.0 | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>@project.groupId@</groupId> | ||
<artifactId>spring_context</artifactId> | ||
<version>@project.version@</version> | ||
<name>spring_context</name> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.build.resourceEncoding>UTF-8</project.build.resourceEncoding> | ||
|
||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<maven.compiler.release>8</maven.compiler.release> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>@project.groupId@</groupId> | ||
<artifactId>zipkin-reporter-spring-beans</artifactId> | ||
<version>@project.version@</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.zipkin.brave</groupId> | ||
<artifactId>brave</artifactId> | ||
<version>@brave.version@</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>@project.groupId@</groupId> | ||
<artifactId>zipkin-reporter-brave</artifactId> | ||
<version>@project.version@</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>@project.groupId@</groupId> | ||
<artifactId>zipkin-sender-okhttp3</artifactId> | ||
<version>@project.version@</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter</artifactId> | ||
<version>@junit-jupiter.version@</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<version>@assertj.version@</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.zipkin.zipkin2</groupId> | ||
<artifactId>zipkin-junit5</artifactId> | ||
<version>@zipkin.version@</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-context</artifactId> | ||
<version>@spring.version@</version> | ||
</dependency> | ||
|
||
<!-- route jcl over log4j2 during integration tests --> | ||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-core</artifactId> | ||
<version>@log4j.version@</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-jcl</artifactId> | ||
<version>@log4j.version@</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<testResources> | ||
<testResource> | ||
<directory>@project.basedir@/src/test/resources</directory> | ||
</testResource> | ||
</testResources> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>@maven-compiler-plugin.version@</version> | ||
<configuration> | ||
<includes> | ||
<include>**/IT*.java</include> | ||
</includes> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<!-- Use surefire to run the ITs until someone figures out how to get invoker to run | ||
failsafe --> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>@maven-surefire-plugin.version@</version> | ||
<configuration> | ||
<failIfNoTests>true</failIfNoTests> | ||
<includes> | ||
<include>**/IT*.java</include> | ||
</includes> | ||
<!-- Try to prevent flakes in CI --> | ||
<reuseForks>false</reuseForks> | ||
<!-- workaround to SUREFIRE-1831 --> | ||
<useModulePath>false</useModulePath> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
66 changes: 66 additions & 0 deletions
66
...ext/src/test/java/zipkin2/reporter/beans/context/ITAsyncZipkinSpanHandlerFactoryBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright The OpenZipkin Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package zipkin2.reporter.beans.context; | ||
|
||
import brave.handler.MutableSpan; | ||
import brave.handler.SpanHandler; | ||
import brave.propagation.TraceContext; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
import org.springframework.context.annotation.AnnotationConfigApplicationContext; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import zipkin2.junit5.ZipkinExtension; | ||
import zipkin2.reporter.BytesMessageSender; | ||
import zipkin2.reporter.beans.AsyncZipkinSpanHandlerFactoryBean; | ||
import zipkin2.reporter.beans.OkHttpSenderFactoryBean; | ||
import zipkin2.reporter.brave.AsyncZipkinSpanHandler; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class ITAsyncZipkinSpanHandlerFactoryBean { | ||
@RegisterExtension public static ZipkinExtension zipkin = new ZipkinExtension(); | ||
|
||
final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); | ||
|
||
@AfterEach void close() { | ||
context.close(); | ||
} | ||
|
||
@Configuration static class TestConfiguration { | ||
@Bean public OkHttpSenderFactoryBean sender() { | ||
OkHttpSenderFactoryBean okHttpSenderFactoryBean = new OkHttpSenderFactoryBean(); | ||
okHttpSenderFactoryBean.setEndpoint(zipkin.httpUrl() + "/api/v2/spans"); | ||
return okHttpSenderFactoryBean; | ||
} | ||
|
||
@Bean public AsyncZipkinSpanHandlerFactoryBean spanHandler(BytesMessageSender sender) { | ||
AsyncZipkinSpanHandlerFactoryBean asyncReporterFactoryBean = | ||
new AsyncZipkinSpanHandlerFactoryBean(); | ||
asyncReporterFactoryBean.setSender(sender); | ||
asyncReporterFactoryBean.setMessageTimeout(0); // don't spawn a thread | ||
return asyncReporterFactoryBean; | ||
} | ||
} | ||
|
||
@Test void providesAsyncZipkinSpanHandler() { | ||
context.register(TestConfiguration.class); | ||
context.refresh(); | ||
|
||
// Make sure the spring context was built correctly | ||
SpanHandler spanHandler = context.getBean(SpanHandler.class); | ||
assertThat(spanHandler).isInstanceOf(AsyncZipkinSpanHandler.class); | ||
|
||
// Create and handle a span | ||
TraceContext context = TraceContext.newBuilder().traceId(1).spanId(2).sampled(true).build(); | ||
MutableSpan span = new MutableSpan(context, null); | ||
spanHandler.end(context, span, SpanHandler.Cause.FINISHED); | ||
|
||
// Prove the integrated setup works. | ||
((AsyncZipkinSpanHandler) spanHandler).flush(); | ||
assertThat(zipkin.getTraces()).hasSize(1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# spring_floor | ||
This tests that the zipkin2.reporter.beans package does not rely on Spring 3+ APIs. |
Oops, something went wrong.