TestHttpServer is no longer used
Move the java version ignores.
This commit is contained in:
parent
e481092f25
commit
5d6fe43dc6
|
@ -5,9 +5,6 @@ description = 'dd-java-agent-ittests'
|
|||
evaluationDependsOn(':dd-java-agent:agent-tooling')
|
||||
compileTestJava.dependsOn tasks.getByPath(':dd-java-agent:agent-tooling:testClasses')
|
||||
|
||||
// These classes use Ratpack which requires Java 8. (Currently also incompatible with Java 9.)
|
||||
testJava8Only += ['**/TestHttpServer.class', '**/ApacheHttpClientTest.class']
|
||||
|
||||
dependencies {
|
||||
testCompile project(':dd-trace-api')
|
||||
testCompile project(':dd-trace-ot')
|
||||
|
@ -22,7 +19,6 @@ dependencies {
|
|||
|
||||
testCompile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.3'
|
||||
testCompile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.6.0'
|
||||
|
||||
}
|
||||
|
||||
tasks.withType(Test) {
|
||||
|
|
|
@ -1,98 +0,0 @@
|
|||
package datadog.trace.agent.integration
|
||||
|
||||
import io.opentracing.Scope
|
||||
import io.opentracing.SpanContext
|
||||
import io.opentracing.propagation.Format
|
||||
import io.opentracing.propagation.TextMap
|
||||
import io.opentracing.util.GlobalTracer
|
||||
import ratpack.groovy.test.embed.GroovyEmbeddedApp
|
||||
import ratpack.handling.Context
|
||||
|
||||
import static ratpack.groovy.test.embed.GroovyEmbeddedApp.ratpack
|
||||
|
||||
/**
|
||||
* A simple http server used for testing.<br>
|
||||
* Binds locally to {@link #port}.
|
||||
*
|
||||
* <p>To start: {@link #startServer()}<br>
|
||||
* to stop: {@link #stopServer()}
|
||||
*/
|
||||
class TestHttpServer {
|
||||
/**
|
||||
* By default the test server will mock a datadog traced server. Set this header to a value of
|
||||
* false to disable.
|
||||
*/
|
||||
public static final String IS_DD_SERVER = "is-dd-server"
|
||||
|
||||
private static GroovyEmbeddedApp server = null
|
||||
private static int port = 0
|
||||
|
||||
static int getPort() {
|
||||
if (port == 0) {
|
||||
throw new RuntimeException("Server not started")
|
||||
}
|
||||
return port
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the server. Has no effect if already started.
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
static synchronized startServer() {
|
||||
if (null == server) {
|
||||
server = ratpack {
|
||||
handlers {
|
||||
get {
|
||||
String msg = "<html><body><h1>Hello test.</h1>\n"
|
||||
boolean isDDServer = true
|
||||
if (context.request.getHeaders().contains(IS_DD_SERVER)) {
|
||||
isDDServer = Boolean.parseBoolean(context.request.getHeaders().get(IS_DD_SERVER))
|
||||
}
|
||||
if (isDDServer) {
|
||||
final SpanContext extractedContext =
|
||||
GlobalTracer.get()
|
||||
.extract(Format.Builtin.HTTP_HEADERS, new RatpackResponseAdapter(context))
|
||||
Scope scope =
|
||||
GlobalTracer.get()
|
||||
.buildSpan("test-http-server")
|
||||
.asChildOf(extractedContext)
|
||||
.startActive(true)
|
||||
scope.close()
|
||||
}
|
||||
|
||||
response.status(200).send(msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
port = server.address.port
|
||||
}
|
||||
}
|
||||
|
||||
/** Stop the server. Has no effect if already stopped. */
|
||||
static synchronized void stopServer() {
|
||||
if (null != server) {
|
||||
server.close()
|
||||
server = null
|
||||
port = 0
|
||||
}
|
||||
}
|
||||
|
||||
private static class RatpackResponseAdapter implements TextMap {
|
||||
final Context context
|
||||
|
||||
RatpackResponseAdapter(Context context) {
|
||||
this.context = context
|
||||
}
|
||||
|
||||
@Override
|
||||
void put(String key, String value) {
|
||||
context.response.set(key, value)
|
||||
}
|
||||
|
||||
@Override
|
||||
Iterator<Map.Entry<String, String>> iterator() {
|
||||
return context.request.getHeaders().asMultiValueMap().entrySet().iterator()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,6 +24,9 @@ versionScan {
|
|||
|
||||
apply from: "${rootDir}/gradle/java.gradle"
|
||||
|
||||
// These classes use Ratpack which requires Java 8. (Currently also incompatible with Java 9.)
|
||||
testJava8Only += '**/ApacheHttpClientTest.class'
|
||||
|
||||
apply plugin: 'org.unbroken-dome.test-sets'
|
||||
|
||||
testSets {
|
||||
|
|
Loading…
Reference in New Issue