Additional test for shared field
This commit is contained in:
parent
7dea113777
commit
13c96bba33
|
@ -6,7 +6,11 @@ import java.lang.reflect.Method;
|
|||
import java.net.URL;
|
||||
|
||||
public class Utils {
|
||||
/* packages which will be loaded on the bootstrap classloader*/
|
||||
/**
|
||||
* packages which will be loaded on the bootstrap classloader
|
||||
*
|
||||
* <p>Updates should be mirrored in TestUtils#BOOTSTRAP_PACKAGE_PREFIXES_COPY
|
||||
*/
|
||||
public static final String[] BOOTSTRAP_PACKAGE_PREFIXES = {
|
||||
"io.opentracing",
|
||||
"datadog.slf4j",
|
||||
|
@ -14,6 +18,7 @@ public class Utils {
|
|||
"datadog.trace.api",
|
||||
"datadog.trace.context"
|
||||
};
|
||||
|
||||
public static final String[] AGENT_PACKAGE_PREFIXES = {
|
||||
"datadog.trace.common",
|
||||
"datadog.trace.agent",
|
||||
|
|
|
@ -252,9 +252,6 @@ public class TestUtils {
|
|||
|
||||
/**
|
||||
* Parse JVM classpath and return ClassLoader containing all classpath entries. Inspired by Guava.
|
||||
*
|
||||
* <p>TODO: use we cannot use Guava version when we can update Guava to version that has this
|
||||
* logic, i.e. when we drop Java7 support.
|
||||
*/
|
||||
private static ClassLoader buildJavaClassPathClassLoader() {
|
||||
ImmutableList.Builder<URL> urls = ImmutableList.builder();
|
||||
|
|
|
@ -3,7 +3,9 @@ import datadog.trace.agent.test.AgentTestRunner
|
|||
import datadog.trace.agent.test.SpockRunner
|
||||
import datadog.trace.agent.test.TestUtils
|
||||
import datadog.trace.agent.tooling.Utils
|
||||
import io.opentracing.Span
|
||||
import io.opentracing.Tracer
|
||||
import spock.lang.Shared
|
||||
|
||||
import java.lang.reflect.Field
|
||||
|
||||
|
@ -16,12 +18,19 @@ class AgentTestRunnerTest extends AgentTestRunner {
|
|||
// having dd tracer api class in test field should not cause problems
|
||||
private static final datadog.trace.api.Tracer DD_API_TRACER = null
|
||||
|
||||
@Shared
|
||||
private Class sharedSpanClass
|
||||
|
||||
static {
|
||||
// when test class initializes, opentracing should be set up, but not the agent.
|
||||
OT_LOADER = io.opentracing.Tracer.getClassLoader()
|
||||
AGENT_INSTALLED_IN_CLINIT = getAgentTransformer() != null
|
||||
}
|
||||
|
||||
def setupSpec() {
|
||||
sharedSpanClass = Span
|
||||
}
|
||||
|
||||
def "spock runner bootstrap prefixes correct for test setup"() {
|
||||
expect:
|
||||
SpockRunner.BOOTSTRAP_PACKAGE_PREFIXES_COPY == Utils.BOOTSTRAP_PACKAGE_PREFIXES
|
||||
|
@ -43,6 +52,8 @@ class AgentTestRunnerTest extends AgentTestRunner {
|
|||
}
|
||||
|
||||
expect:
|
||||
// a shared OT class should cause no trouble
|
||||
sharedSpanClass.getClassLoader() == BOOTSTRAP_CLASSLOADER
|
||||
A_TRACER == null
|
||||
DD_API_TRACER == null
|
||||
!AGENT_INSTALLED_IN_CLINIT
|
||||
|
|
Loading…
Reference in New Issue