Remove useless tests from Glassfish 4 instrumentation
DELETE
dd-java-agent/instrumentation/glassfish-4.1/src/test/groovy/datadog/trace/instrumentation/glassfish4/GlassfishInstrumentationTest.groovy
-package datadog.trace.instrumentation.glassfish4
-
-import com.sun.enterprise.v3.server.APIClassLoaderServiceImpl
-import datadog.trace.agent.test.AgentTestRunner
-
-class GlassfishInstrumentationTest extends AgentTestRunner {
-
- def "classes not related to datadog can be black-listed"() {
- setup:
- def cli = new APIClassLoaderServiceImpl()
- def cl = cli.getApiClassLoader()
- cl.triggerAddToBlackList('com.some.Entity')
-// def rf = ReflectionFactory.reflectionFactory
-// def clazz = Class.forName('com.sun.enterprise.v3.server.APIClassLoaderServiceImpl$APIClassLoader')
-// def objDef = clazz.getDeclaredConstructor(ClassLoader.class, ClassLoader.class)
-// def intConstr = rf.newConstructorForSerialization(clazz, objDef)
-// def instance = clazz.cast(intConstr.newInstance())
-
- expect:
- 'com.some.Entity' in cl.blacklist
- }
-
- def "classes related to datadog are not black-listed"() {
- setup:
- def cli = new APIClassLoaderServiceImpl()
- def cl = cli.getApiClassLoader()
- cl.triggerAddToBlackList('io.opentracing.some.Entity')
-
- expect:
- !('io.opentracing.some.Entity' in cl.blacklist)
- '__datadog_no_blacklist.io.opentracing.some.Entity' in cl.blacklist
- }
-}

DELETE
dd-java-agent/instrumentation/glassfish-4.1/src/test/java/com/sun/enterprise/v3/server/APIClassLoaderServiceImpl.java
-package com.sun.enterprise.v3.server;
-
-import java.util.HashSet;
-import java.util.Set;
-
-public class APIClassLoaderServiceImpl {
-
- private APIClassLoader instance;
-
- public APIClassLoaderServiceImpl() {
- this.instance = new APIClassLoader();
- }
-
- public APIClassLoader getApiClassLoader() {
- return instance;
- }
-
- private class APIClassLoader {
-
- private Set<String> blacklist = new HashSet<String>();
-
- public void triggerAddToBlackList(String name) {
- addToBlackList(name);
- }
-
- private synchronized void addToBlackList(String name) {
- blacklist.add(name);
- }
-
- public Set<String> getBlacklist() {
- return blacklist;
- }
- }
-}

RENAME
dd-java-agent/instrumentation/glassfish-4.1/glassfish-4.1.gradle
dd-java-agent/instrumentation/glassfish-4/glassfish-4.gradle
@@ -6,7 +6,8 @@ muzzle {
pass {
group = 'org.glassfish.main.extras'
module = 'glassfish-embedded-all'
- versions = "[4.1,4.1.2)"
+ versions = "[4.0,4.1.2)"
+ assertInverse = true
}
}
@@ -28,7 +29,7 @@ dependencies {
implementation deps.autoservice
testCompile project(':dd-java-agent:testing')
-// testCompile group: 'org.glassfish.main.extras', name: 'glassfish-embedded-all', version: '4.1.2'
+ testCompile group: 'org.glassfish.main.extras', name: 'glassfish-embedded-all', version: '4.1.2'
latestDepTestCompile sourceSets.test.output
}

RENAME
dd-java-agent/instrumentation/glassfish-4.1/src/main/java/datadog/trace/instrumentation/glassfish4/GlassfishInstrumentation.java
dd-java-agent/instrumentation/glassfish-4/src/main/java/datadog/trace/instrumentation/glassfish4/GlassfishInstrumentation.java
@@ -29,7 +29,7 @@ import net.bytebuddy.matcher.ElementMatchers;
public final class GlassfishInstrumentation extends Instrumenter.Default {
public GlassfishInstrumentation() {
- super("cassandra");
+ super("glassfish");
}
@Override

MODIFY
settings.gradle
settings.gradle
@@ -40,7 +40,7 @@ include ':dd-java-agent:instrumentation:elasticsearch:transport-2'
include ':dd-java-agent:instrumentation:elasticsearch:transport-5'
include ':dd-java-agent:instrumentation:elasticsearch:transport-5.3'
include ':dd-java-agent:instrumentation:elasticsearch:transport-6'
-include ':dd-java-agent:instrumentation:glassfish-4.1'
+include ':dd-java-agent:instrumentation:glassfish-4'
include ':dd-java-agent:instrumentation:grpc-1.5'
include ':dd-java-agent:instrumentation:hibernate'
include ':dd-java-agent:instrumentation:hibernate:core-3.3'

Remove useless tests from Glassfish 4 instrumentation