diff --git a/agent/pom.xml b/agent/pom.xml
index 6c4125067..ef04c13ef 100644
--- a/agent/pom.xml
+++ b/agent/pom.xml
@@ -20,6 +20,10 @@
com.navercorp.pinpoint
pinpoint-profiler
+
+ com.navercorp.pinpoint
+ pinpoint-profiler-test
+
com.navercorp.pinpoint
pinpoint-profiler-optional
diff --git a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/PinpointStarter.java b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/PinpointStarter.java
index 392e4f140..57fd35174 100644
--- a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/PinpointStarter.java
+++ b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/PinpointStarter.java
@@ -1,11 +1,11 @@
-/**
+/*
* Copyright 2014 NAVER Corp.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,6 +16,7 @@ package com.navercorp.pinpoint.bootstrap;
import java.lang.instrument.Instrumentation;
import java.net.URL;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -34,7 +35,6 @@ import com.navercorp.pinpoint.common.util.SimpleProperty;
import com.navercorp.pinpoint.common.util.SystemProperty;
import com.navercorp.pinpoint.common.util.logger.CommonLoggerFactory;
import com.navercorp.pinpoint.common.util.logger.StdoutCommonLoggerFactory;
-import com.navercorp.pinpoint.exception.PinpointException;
/**
* @author Jongho Moon
@@ -44,7 +44,12 @@ class PinpointStarter {
private final BootLogger logger = BootLogger.getLogger(PinpointStarter.class.getName());
+ public static final String AGENT_TYPE = "AGENT_TYPE";
+
+ public static final String DEFAULT_AGENT = "DEFAULT_AGENT";
public static final String BOOT_CLASS = "com.navercorp.pinpoint.profiler.DefaultAgent";
+
+ public static final String PLUGIN_TEST_AGENT = "PLUGIN_TEST";
public static final String PLUGIN_TEST_BOOT_CLASS = "com.navercorp.pinpoint.test.PluginTestAgent";
private SimpleProperty systemProperty = SystemProperty.INSTANCE;
@@ -85,13 +90,13 @@ class PinpointStarter {
if (applicationName == null) {
return false;
}
-
+
URL[] pluginJars = classPathResolver.resolvePlugins();
// TODO using PLogger instead of CommonLogger
CommonLoggerFactory loggerFactory = StdoutCommonLoggerFactory.INSTANCE;
TraceMetadataLoaderService typeLoaderService = new DefaultTraceMetadataLoaderService(pluginJars, loggerFactory);
- ServiceTypeRegistryService serviceTypeRegistryService = new DefaultServiceTypeRegistryService(typeLoaderService, loggerFactory);
+ ServiceTypeRegistryService serviceTypeRegistryService = new DefaultServiceTypeRegistryService(typeLoaderService, loggerFactory);
AnnotationKeyRegistryService annotationKeyRegistryService = new DefaultAnnotationKeyRegistryService(typeLoaderService, loggerFactory);
String configPath = getConfigPath(classPathResolver);
@@ -131,16 +136,16 @@ class PinpointStarter {
private String getBootClass() {
final String agentType = getAgentType().toUpperCase();
- if ("PLUGIN_TEST".equals(agentType)) {
+ if (PLUGIN_TEST_AGENT.equals(agentType)) {
return PLUGIN_TEST_BOOT_CLASS;
}
return BOOT_CLASS;
}
private String getAgentType() {
- String agentType = agentArgs.get("AGENT_TYPE");
+ String agentType = agentArgs.get(AGENT_TYPE);
if (agentType == null) {
- return "DEFAULT_AGENT";
+ return DEFAULT_AGENT;
}
return agentType;
@@ -196,7 +201,7 @@ class PinpointStarter {
String classPathAgentConfigPath = classPathResolver.getAgentConfigPath();
if (classPathAgentConfigPath != null) {
- logger.info("classpath " + configName + " found. " + classPathAgentConfigPath);
+ logger.info("classpath " + configName + " found. " + classPathAgentConfigPath);
return classPathAgentConfigPath;
}
@@ -205,11 +210,11 @@ class PinpointStarter {
}
- private List resolveLib(ClassPathResolver classPathResolver) {
+ private List resolveLib(ClassPathResolver classPathResolver) {
// this method may handle only absolute path, need to handle relative path (./..agentlib/lib)
String agentJarFullPath = classPathResolver.getAgentJarFullPath();
String agentLibPath = classPathResolver.getAgentLibPath();
- List urlList = classPathResolver.resolveLib();
+ List urlList = resolveLib(classPathResolver.resolveLib());
String agentConfigPath = classPathResolver.getAgentConfigPath();
if (logger.isInfoEnabled()) {
@@ -224,4 +229,21 @@ class PinpointStarter {
return urlList;
}
+ private List resolveLib(List urlList) {
+ if (DEFAULT_AGENT.equals(getAgentType().toUpperCase())) {
+ final List releaseLib = new ArrayList(urlList.size());
+ for (URL url : urlList) {
+ //
+ if (!url.toExternalForm().contains("pinpoint-profiler-test")) {
+ releaseLib.add(url);
+ }
+ }
+ return releaseLib;
+ } else {
+ logger.info("load " + PLUGIN_TEST_AGENT + " lib");
+ // plugin test
+ return urlList;
+ }
+ }
+
}
diff --git a/plugins/jboss/pom.xml b/plugins/jboss/pom.xml
index cc94cdd6f..a6703054b 100644
--- a/plugins/jboss/pom.xml
+++ b/plugins/jboss/pom.xml
@@ -33,6 +33,11 @@
pinpoint-profiler
test
+
+ com.navercorp.pinpoint
+ pinpoint-profiler-test
+ test
+
com.navercorp.pinpoint
pinpoint-test
diff --git a/plugins/redis/pom.xml b/plugins/redis/pom.xml
index 7953b53fd..328090980 100644
--- a/plugins/redis/pom.xml
+++ b/plugins/redis/pom.xml
@@ -27,6 +27,11 @@
pinpoint-profiler
test
+
+ com.navercorp.pinpoint
+ pinpoint-profiler-test
+ test
+
com.navercorp.pinpoint
pinpoint-commons-server
diff --git a/plugins/tomcat/pom.xml b/plugins/tomcat/pom.xml
index eff0ad979..381024f71 100644
--- a/plugins/tomcat/pom.xml
+++ b/plugins/tomcat/pom.xml
@@ -28,6 +28,11 @@
pinpoint-profiler
test
+
+ com.navercorp.pinpoint
+ pinpoint-profiler-test
+ test
+
com.navercorp.pinpoint
pinpoint-test
diff --git a/pom.xml b/pom.xml
index e94c13a1f..39b4b96ac 100644
--- a/pom.xml
+++ b/pom.xml
@@ -59,6 +59,7 @@
plugins
profiler
profiler-optional
+ profiler-test
rpc
thrift
test
@@ -163,6 +164,11 @@
pom
${project.version}
+
+ com.navercorp.pinpoint
+ pinpoint-profiler-test
+ ${project.version}
+
com.navercorp.pinpoint
pinpoint-collector
diff --git a/profiler-test/.gitignore b/profiler-test/.gitignore
new file mode 100644
index 000000000..31dc463a2
--- /dev/null
+++ b/profiler-test/.gitignore
@@ -0,0 +1,5 @@
+/.settings/
+/*.iml
+/.project
+/target/
+/.classpath
diff --git a/profiler-test/clover.license b/profiler-test/clover.license
new file mode 100644
index 000000000..569fa6175
--- /dev/null
+++ b/profiler-test/clover.license
@@ -0,0 +1,5 @@
+RMRqrdbgbKFhbaVnDxHUdDQvrOQXxIBklnvcmahheubVC
+mh2KM35CLkwUHS4DH7QVhxy52J5hnWbyEm6Cyd3KkF
+ 4.0.0
+
+ com.navercorp.pinpoint
+ pinpoint
+ 1.6.1-SNAPSHOT
+
+
+ pinpoint-profiler-test
+ pinpoint-profiler-test
+ jar
+
+
+
+ com.navercorp.pinpoint
+ pinpoint-commons
+
+
+ org.apache.thrift
+ libthrift
+
+
+ org.slf4j
+ slf4j-api
+
+
+
+
+ com.navercorp.pinpoint
+ pinpoint-commons-server
+ provided
+
+
+ com.navercorp.pinpoint
+ pinpoint-commons-hbase
+
+
+
+
+ com.navercorp.pinpoint
+ pinpoint-profiler
+
+
+ com.navercorp.pinpoint
+ pinpoint-thrift
+
+
+ org.apache.thrift
+ libthrift
+
+
+ org.slf4j
+ slf4j-api
+
+
+
+
+ com.navercorp.pinpoint
+ pinpoint-bootstrap-core
+
+
+ com.navercorp.pinpoint
+ pinpoint-bootstrap
+
+
+ com.navercorp.pinpoint
+ pinpoint-rpc
+
+
+ com.navercorp.pinpoint
+ pinpoint-google-guava
+
+
+
+
+ org.springframework
+ spring-test
+ test
+
+
+ org.springframework
+ spring-context
+ test
+
+
+ org.springframework
+ spring-jdbc
+ test
+
+
+ org.springframework
+ spring-tx
+ test
+
+
+ org.apache.commons
+ commons-lang3
+ test
+
+
+
+
+
+ org.javassist
+ javassist
+
+
+ org.ow2.asm
+ asm-debug-all
+
+
+
+ org.apache.thrift
+ libthrift
+
+
+ httpclient
+ org.apache.httpcomponents
+
+
+ httpcore
+ org.apache.httpcomponents
+
+
+ slf4j-api
+ org.slf4j
+
+
+ org.apache.commons
+ commons-lang3
+
+
+
+
+
+
+
+ org.slf4j
+ slf4j-api
+
+
+
+ org.slf4j
+ jcl-over-slf4j
+ test
+
+
+ org.slf4j
+ slf4j-log4j12
+
+
+ log4j
+ log4j
+
+
+
+
+ io.dropwizard.metrics
+ metrics-core
+
+
+ io.dropwizard.metrics
+ metrics-jvm
+
+
+
+
+
+
+
+
+
+
+
+
+
+ junit
+ junit
+ compile
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+ **/pinpoint.config
+ **/log4j.xml
+
+
+
+
+
+
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/DummyInstrumentation.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/DummyInstrumentation.java
similarity index 100%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/DummyInstrumentation.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/DummyInstrumentation.java
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/ListenableDataSender.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/ListenableDataSender.java
similarity index 100%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/ListenableDataSender.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/ListenableDataSender.java
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/MethodDescriptionUtils.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/MethodDescriptionUtils.java
similarity index 100%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/MethodDescriptionUtils.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/MethodDescriptionUtils.java
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/MockAgent.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/MockAgent.java
similarity index 97%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/MockAgent.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/MockAgent.java
index eef68eb83..5d89d47f3 100644
--- a/profiler/src/main/java/com/navercorp/pinpoint/test/MockAgent.java
+++ b/profiler-test/src/main/java/com/navercorp/pinpoint/test/MockAgent.java
@@ -1,217 +1,217 @@
-/*
- * Copyright 2014 NAVER Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.navercorp.pinpoint.test;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig;
-import com.navercorp.pinpoint.bootstrap.instrument.InstrumentContext;
-import com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformTemplate;
-import com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformTemplateAware;
-import com.navercorp.pinpoint.profiler.plugin.GuardProfilerPluginContext;
-import org.apache.thrift.TBase;
-
-import com.navercorp.pinpoint.bootstrap.AgentOption;
-import com.navercorp.pinpoint.bootstrap.DefaultAgentOption;
-import com.navercorp.pinpoint.bootstrap.config.ProfilerConfig;
-import com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder;
-import com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin;
-import com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedAnnotation;
-import com.navercorp.pinpoint.common.plugin.PluginLoader;
-import com.navercorp.pinpoint.common.service.DefaultAnnotationKeyRegistryService;
-import com.navercorp.pinpoint.common.service.DefaultServiceTypeRegistryService;
-import com.navercorp.pinpoint.common.trace.ServiceType;
-import com.navercorp.pinpoint.profiler.DefaultAgent;
-import com.navercorp.pinpoint.profiler.context.Span;
-import com.navercorp.pinpoint.profiler.context.SpanEvent;
-import com.navercorp.pinpoint.profiler.context.storage.StorageFactory;
-import com.navercorp.pinpoint.profiler.instrument.ClassInjector;
-import com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder;
-import com.navercorp.pinpoint.profiler.plugin.DefaultProfilerPluginContext;
-import com.navercorp.pinpoint.profiler.receiver.CommandDispatcher;
-import com.navercorp.pinpoint.profiler.sender.DataSender;
-import com.navercorp.pinpoint.profiler.sender.EnhancedDataSender;
-import com.navercorp.pinpoint.profiler.util.RuntimeMXBeanUtils;
-import com.navercorp.pinpoint.thrift.dto.TAnnotation;
-
-/**
- * @author emeroad
- * @author koo.taejin
- * @author hyungil.jeong
- */
-public class MockAgent extends DefaultAgent {
-
-
- public static MockAgent of(String configPath) {
- ProfilerConfig profilerConfig = null;
- try {
- URL resource = MockAgent.class.getClassLoader().getResource(configPath);
- if (resource == null) {
- throw new FileNotFoundException("pinpoint.config not found. configPath:" + configPath);
- }
- profilerConfig = DefaultProfilerConfig.load(resource.getPath());
- ((DefaultProfilerConfig)profilerConfig).setApplicationServerType(ServiceType.TEST_STAND_ALONE.getName());
- } catch (IOException ex) {
- throw new RuntimeException(ex.getMessage(), ex);
- }
-
- return of(profilerConfig);
- }
-
- public static MockAgent of(ProfilerConfig config) {
- AgentOption agentOption = new DefaultAgentOption(new DummyInstrumentation(), "mockAgent", "mockApplicationName", config, new URL[0], null, new DefaultServiceTypeRegistryService(), new DefaultAnnotationKeyRegistryService());
- InterceptorRegistryBinder binder = new TestInterceptorRegistryBinder();
-
- return new MockAgent(agentOption, binder);
- }
-
- public MockAgent(AgentOption agentOption) {
- this(agentOption, new TestInterceptorRegistryBinder());
- }
-
- public MockAgent(AgentOption agentOption, InterceptorRegistryBinder binder) {
- super(agentOption, binder);
- }
-
- @Override
- protected DataSender createUdpStatDataSender(int port, String threadName, int writeQueueSize, int timeout, int sendBufferSize) {
- return new ListenableDataSender>();
- }
-
- @Override
- protected DataSender createUdpSpanDataSender(int port, String threadName, int writeQueueSize, int timeout, int sendBufferSize) {
- return new ListenableDataSender>();
- }
-
- public DataSender getSpanDataSender() {
- return super.getSpanDataSender();
- }
-
-
- @Override
- protected StorageFactory createStorageFactory() {
- return new SimpleSpanStorageFactory(super.getSpanDataSender());
- }
-
-
- @Override
- protected EnhancedDataSender createTcpDataSender(CommandDispatcher commandDispatcher) {
- return new TestTcpDataSender();
- }
-
- @Override
- protected ServerMetaDataHolder createServerMetaDataHolder() {
- List vmArgs = RuntimeMXBeanUtils.getVmArgs();
- return new ResettableServerMetaDataHolder(vmArgs);
- }
-
- @Override
- protected List loadPlugins(AgentOption agentOption) {
- List pluginContexts = new ArrayList();
- ClassInjector classInjector = new TestProfilerPluginClassLoader();
-
- List plugins = PluginLoader.load(ProfilerPlugin.class, ClassLoader.getSystemClassLoader());
-
- for (ProfilerPlugin plugin : plugins) {
- final DefaultProfilerPluginContext context = new DefaultProfilerPluginContext(this, classInjector);
- final GuardProfilerPluginContext guard = new GuardProfilerPluginContext(context);
- try {
- preparePlugin(plugin, context);
- plugin.setup(guard);
- } finally {
- guard.close();
- }
- pluginContexts.add(context);
- }
-
-
- return pluginContexts;
-
- }
-
- /**
- * TODO duplicated code : com/navercorp/pinpoint/profiler/plugin/ProfilerPluginLoader.java
- * @param plugin
- * @param context
- */
- private void preparePlugin(ProfilerPlugin plugin, InstrumentContext context) {
-
- if (plugin instanceof TransformTemplateAware) {
- final TransformTemplate transformTemplate = new TransformTemplate(context);
- ((TransformTemplateAware) plugin).setTransformTemplate(transformTemplate);
- }
- }
-
-
- public static String toString(Span span) {
- StringBuilder builder = new StringBuilder();
- builder.append('(');
- builder.append(span.getServiceType());
- builder.append(", [");
- appendAnnotations(builder, span.getAnnotations());
- builder.append("])");
-
- return builder.toString();
- }
-
- public static String toString(SpanEvent span) {
- StringBuilder builder = new StringBuilder();
- builder.append('(');
- builder.append(span.getServiceType());
- builder.append(", [");
- appendAnnotations(builder, span.getAnnotations());
- builder.append("])");
-
- return builder.toString();
- }
-
- private static void appendAnnotations(StringBuilder builder, List annotations) {
- boolean first = true;
-
- if (annotations != null) {
- for (TAnnotation a : annotations) {
- if (first) {
- first = false;
- } else {
- builder.append(", ");
- }
-
- builder.append(toString(a));
- }
- }
- }
-
- private static String toString(TAnnotation a) {
- return a.getKey() + "=" + a.getValue().getFieldValue();
- }
-
- public static String toString(short serviceCode, ExpectedAnnotation...annotations) {
- StringBuilder builder = new StringBuilder();
- builder.append('(');
- builder.append(serviceCode);
- builder.append(", ");
- builder.append(Arrays.deepToString(annotations));
- builder.append(")");
-
- return builder.toString();
- }
-}
+/*
+ * Copyright 2014 NAVER Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.navercorp.pinpoint.test;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig;
+import com.navercorp.pinpoint.bootstrap.instrument.InstrumentContext;
+import com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformTemplate;
+import com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformTemplateAware;
+import com.navercorp.pinpoint.profiler.plugin.GuardProfilerPluginContext;
+import org.apache.thrift.TBase;
+
+import com.navercorp.pinpoint.bootstrap.AgentOption;
+import com.navercorp.pinpoint.bootstrap.DefaultAgentOption;
+import com.navercorp.pinpoint.bootstrap.config.ProfilerConfig;
+import com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder;
+import com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin;
+import com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedAnnotation;
+import com.navercorp.pinpoint.common.plugin.PluginLoader;
+import com.navercorp.pinpoint.common.service.DefaultAnnotationKeyRegistryService;
+import com.navercorp.pinpoint.common.service.DefaultServiceTypeRegistryService;
+import com.navercorp.pinpoint.common.trace.ServiceType;
+import com.navercorp.pinpoint.profiler.DefaultAgent;
+import com.navercorp.pinpoint.profiler.context.Span;
+import com.navercorp.pinpoint.profiler.context.SpanEvent;
+import com.navercorp.pinpoint.profiler.context.storage.StorageFactory;
+import com.navercorp.pinpoint.profiler.instrument.ClassInjector;
+import com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder;
+import com.navercorp.pinpoint.profiler.plugin.DefaultProfilerPluginContext;
+import com.navercorp.pinpoint.profiler.receiver.CommandDispatcher;
+import com.navercorp.pinpoint.profiler.sender.DataSender;
+import com.navercorp.pinpoint.profiler.sender.EnhancedDataSender;
+import com.navercorp.pinpoint.profiler.util.RuntimeMXBeanUtils;
+import com.navercorp.pinpoint.thrift.dto.TAnnotation;
+
+/**
+ * @author emeroad
+ * @author koo.taejin
+ * @author hyungil.jeong
+ */
+public class MockAgent extends DefaultAgent {
+
+
+ public static MockAgent of(String configPath) {
+ ProfilerConfig profilerConfig = null;
+ try {
+ URL resource = MockAgent.class.getClassLoader().getResource(configPath);
+ if (resource == null) {
+ throw new FileNotFoundException("pinpoint.config not found. configPath:" + configPath);
+ }
+ profilerConfig = DefaultProfilerConfig.load(resource.getPath());
+ ((DefaultProfilerConfig)profilerConfig).setApplicationServerType(ServiceType.TEST_STAND_ALONE.getName());
+ } catch (IOException ex) {
+ throw new RuntimeException(ex.getMessage(), ex);
+ }
+
+ return of(profilerConfig);
+ }
+
+ public static MockAgent of(ProfilerConfig config) {
+ AgentOption agentOption = new DefaultAgentOption(new DummyInstrumentation(), "mockAgent", "mockApplicationName", config, new URL[0], null, new DefaultServiceTypeRegistryService(), new DefaultAnnotationKeyRegistryService());
+ InterceptorRegistryBinder binder = new TestInterceptorRegistryBinder();
+
+ return new MockAgent(agentOption, binder);
+ }
+
+ public MockAgent(AgentOption agentOption) {
+ this(agentOption, new TestInterceptorRegistryBinder());
+ }
+
+ public MockAgent(AgentOption agentOption, InterceptorRegistryBinder binder) {
+ super(agentOption, binder);
+ }
+
+ @Override
+ protected DataSender createUdpStatDataSender(int port, String threadName, int writeQueueSize, int timeout, int sendBufferSize) {
+ return new ListenableDataSender>();
+ }
+
+ @Override
+ protected DataSender createUdpSpanDataSender(int port, String threadName, int writeQueueSize, int timeout, int sendBufferSize) {
+ return new ListenableDataSender>();
+ }
+
+ public DataSender getSpanDataSender() {
+ return super.getSpanDataSender();
+ }
+
+
+ @Override
+ protected StorageFactory createStorageFactory() {
+ return new SimpleSpanStorageFactory(super.getSpanDataSender());
+ }
+
+
+ @Override
+ protected EnhancedDataSender createTcpDataSender(CommandDispatcher commandDispatcher) {
+ return new TestTcpDataSender();
+ }
+
+ @Override
+ protected ServerMetaDataHolder createServerMetaDataHolder() {
+ List vmArgs = RuntimeMXBeanUtils.getVmArgs();
+ return new ResettableServerMetaDataHolder(vmArgs);
+ }
+
+ @Override
+ protected List loadPlugins(AgentOption agentOption) {
+ List pluginContexts = new ArrayList();
+ ClassInjector classInjector = new TestProfilerPluginClassLoader();
+
+ List plugins = PluginLoader.load(ProfilerPlugin.class, ClassLoader.getSystemClassLoader());
+
+ for (ProfilerPlugin plugin : plugins) {
+ final DefaultProfilerPluginContext context = new DefaultProfilerPluginContext(this, classInjector);
+ final GuardProfilerPluginContext guard = new GuardProfilerPluginContext(context);
+ try {
+ preparePlugin(plugin, context);
+ plugin.setup(guard);
+ } finally {
+ guard.close();
+ }
+ pluginContexts.add(context);
+ }
+
+
+ return pluginContexts;
+
+ }
+
+ /**
+ * TODO duplicated code : com/navercorp/pinpoint/profiler/plugin/ProfilerPluginLoader.java
+ * @param plugin
+ * @param context
+ */
+ private void preparePlugin(ProfilerPlugin plugin, InstrumentContext context) {
+
+ if (plugin instanceof TransformTemplateAware) {
+ final TransformTemplate transformTemplate = new TransformTemplate(context);
+ ((TransformTemplateAware) plugin).setTransformTemplate(transformTemplate);
+ }
+ }
+
+
+ public static String toString(Span span) {
+ StringBuilder builder = new StringBuilder();
+ builder.append('(');
+ builder.append(span.getServiceType());
+ builder.append(", [");
+ appendAnnotations(builder, span.getAnnotations());
+ builder.append("])");
+
+ return builder.toString();
+ }
+
+ public static String toString(SpanEvent span) {
+ StringBuilder builder = new StringBuilder();
+ builder.append('(');
+ builder.append(span.getServiceType());
+ builder.append(", [");
+ appendAnnotations(builder, span.getAnnotations());
+ builder.append("])");
+
+ return builder.toString();
+ }
+
+ private static void appendAnnotations(StringBuilder builder, List annotations) {
+ boolean first = true;
+
+ if (annotations != null) {
+ for (TAnnotation a : annotations) {
+ if (first) {
+ first = false;
+ } else {
+ builder.append(", ");
+ }
+
+ builder.append(toString(a));
+ }
+ }
+ }
+
+ private static String toString(TAnnotation a) {
+ return a.getKey() + "=" + a.getValue().getFieldValue();
+ }
+
+ public static String toString(short serviceCode, ExpectedAnnotation...annotations) {
+ StringBuilder builder = new StringBuilder();
+ builder.append('(');
+ builder.append(serviceCode);
+ builder.append(", ");
+ builder.append(Arrays.deepToString(annotations));
+ builder.append(")");
+
+ return builder.toString();
+ }
+}
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/MockTraceContextFactory.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/MockTraceContextFactory.java
similarity index 100%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/MockTraceContextFactory.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/MockTraceContextFactory.java
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/OrderedSpanRecorder.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/OrderedSpanRecorder.java
similarity index 95%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/OrderedSpanRecorder.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/OrderedSpanRecorder.java
index efe347cb3..62931cc4e 100644
--- a/profiler/src/main/java/com/navercorp/pinpoint/test/OrderedSpanRecorder.java
+++ b/profiler-test/src/main/java/com/navercorp/pinpoint/test/OrderedSpanRecorder.java
@@ -35,16 +35,16 @@ public class OrderedSpanRecorder implements ListenableDataSender.Listener, Itera
private static final int ASYNC_ID_NOT_SET = -1;
private final List- list = new ArrayList
- ();
-
+
private static final class Item implements Comparable
- {
-
+
private final TBase, ?> value;
private final long time;
private final long spanId;
private final int sequence;
private final int asyncId;
-
+
public Item(TBase, ?> value, long time, long spanId, int sequence) {
this(value, time, spanId, sequence, ASYNC_ID_NOT_SET);
}
@@ -74,12 +74,12 @@ public class OrderedSpanRecorder implements ListenableDataSender.Listener, Itera
} else if (this.asyncId > o.asyncId) {
return 1;
}
-
+
// if both async events have the same asyncId, do normal event comparison
}
}
-
-
+
+
if (this.time < o.time) {
return -1;
} else if (this.time > o.time) {
@@ -97,71 +97,71 @@ public class OrderedSpanRecorder implements ListenableDataSender.Listener, Itera
} else {
int h1 = System.identityHashCode(this.value);
int h2 = System.identityHashCode(o.value);
-
+
return h1 < h2 ? -1 : (h1 > h2 ? 1 : 0);
}
}
}
}
}
-
+
@Override
public synchronized boolean handleSend(TBase, ?> data) {
if (data instanceof Span) {
- insertSpan((Span)data);
+ insertSpan((Span) data);
return true;
} else if (data instanceof SpanEvent) {
- handleSpanEvent((SpanEvent)data);
+ handleSpanEvent((SpanEvent) data);
return true;
}
-
+
return false;
}
-
+
private void insertSpan(Span span) {
long startTime = span.getStartTime();
long spanId = span.getSpanId();
insertItem(new Item(span, startTime, spanId, ROOT_SEQUENCE));
}
-
+
private void insertItem(Item item) {
int pos = Collections.binarySearch(list, item);
-
+
if (pos >= 0) {
throw new IllegalArgumentException("Duplicated?? list: " + list + ", item: " + item);
}
-
+
int index = -(pos + 1);
list.add(index, item);
}
-
+
private void handleSpanEvent(SpanEvent event) {
Span span = event.getSpan();
int asyncId = event.isSetAsyncId() ? event.getAsyncId() : ASYNC_ID_NOT_SET;
insertItem(new Item(event, span.getStartTime() + event.getStartElapsed(), span.getSpanId(), event.getSequence(), asyncId));
}
-
+
public synchronized TBase, ?> pop() {
if (list.isEmpty()) {
return null;
}
-
+
return list.remove(0).value;
}
-
+
public synchronized void print(PrintStream out) {
out.println("TRACES(" + list.size() + "):");
-
+
for (TBase, ?> obj : this) {
out.println(obj);
}
}
-
+
public synchronized void clear() {
list.clear();
}
-
+
public synchronized int size() {
return list.size();
}
@@ -197,7 +197,7 @@ public class OrderedSpanRecorder implements ListenableDataSender.Listener, Itera
if (current == -1) {
throw new IllegalStateException();
}
-
+
list.remove(current);
current = -1;
index--;
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/PluginTestAgent.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/PluginTestAgent.java
similarity index 99%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/PluginTestAgent.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/PluginTestAgent.java
index 17a153215..ea9a82ca3 100644
--- a/profiler/src/main/java/com/navercorp/pinpoint/test/PluginTestAgent.java
+++ b/profiler-test/src/main/java/com/navercorp/pinpoint/test/PluginTestAgent.java
@@ -587,7 +587,7 @@ public class PluginTestAgent extends DefaultAgent implements PluginTestVerifier
private static boolean equals(Object expected, Object actual) {
// if expected is null, no need to compare.
- return expected == null ? true : (expected.equals(actual));
+ return expected == null || (expected.equals(actual));
}
private void verifySpan(ResolvedExpectedTrace expected, ActualTrace actual) {
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/ProjectPathResolver.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/ProjectPathResolver.java
similarity index 100%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/ProjectPathResolver.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/ProjectPathResolver.java
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/ResettableServerMetaDataHolder.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/ResettableServerMetaDataHolder.java
similarity index 96%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/ResettableServerMetaDataHolder.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/ResettableServerMetaDataHolder.java
index 495659e6a..c7bf3510c 100644
--- a/profiler/src/main/java/com/navercorp/pinpoint/test/ResettableServerMetaDataHolder.java
+++ b/profiler-test/src/main/java/com/navercorp/pinpoint/test/ResettableServerMetaDataHolder.java
@@ -1,37 +1,37 @@
-/*
- * Copyright 2014 NAVER Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.navercorp.pinpoint.test;
-
-import java.util.List;
-
-import com.navercorp.pinpoint.profiler.context.DefaultServerMetaDataHolder;
-
-/**
- * @author hyungil.jeong
- */
-public class ResettableServerMetaDataHolder extends DefaultServerMetaDataHolder {
-
- public ResettableServerMetaDataHolder(List vmArgs) {
- super(vmArgs);
- }
-
- public void reset() {
- this.serverName = null;
- this.serviceInfos.clear();
- }
-
-}
+/*
+ * Copyright 2014 NAVER Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.navercorp.pinpoint.test;
+
+import java.util.List;
+
+import com.navercorp.pinpoint.profiler.context.DefaultServerMetaDataHolder;
+
+/**
+ * @author hyungil.jeong
+ */
+public class ResettableServerMetaDataHolder extends DefaultServerMetaDataHolder {
+
+ public ResettableServerMetaDataHolder(List vmArgs) {
+ super(vmArgs);
+ }
+
+ public void reset() {
+ this.serverName = null;
+ this.serviceInfos.clear();
+ }
+
+}
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/SimpleSpanStorage.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/SimpleSpanStorage.java
similarity index 100%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/SimpleSpanStorage.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/SimpleSpanStorage.java
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/SimpleSpanStorageFactory.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/SimpleSpanStorageFactory.java
similarity index 100%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/SimpleSpanStorageFactory.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/SimpleSpanStorageFactory.java
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/TBaseRecorder.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/TBaseRecorder.java
similarity index 100%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/TBaseRecorder.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/TBaseRecorder.java
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/TBaseRecorderAdaptor.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/TBaseRecorderAdaptor.java
similarity index 100%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/TBaseRecorderAdaptor.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/TBaseRecorderAdaptor.java
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/TestAgentInformation.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/TestAgentInformation.java
similarity index 97%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/TestAgentInformation.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/TestAgentInformation.java
index bed513b06..ad2ed9739 100644
--- a/profiler/src/main/java/com/navercorp/pinpoint/test/TestAgentInformation.java
+++ b/profiler-test/src/main/java/com/navercorp/pinpoint/test/TestAgentInformation.java
@@ -1,42 +1,42 @@
-/*
- * Copyright 2015 NAVER Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.navercorp.pinpoint.test;
-
-import com.navercorp.pinpoint.common.Version;
-import com.navercorp.pinpoint.common.trace.ServiceType;
-import com.navercorp.pinpoint.common.util.JvmUtils;
-import com.navercorp.pinpoint.common.util.SystemPropertyKey;
-import com.navercorp.pinpoint.profiler.AgentInformation;
-
-/**
- * @author HyunGil Jeong
- */
-public class TestAgentInformation extends AgentInformation {
-
- private static final String AGENT_ID = "test-agent";
- private static final String APPLICATION_NAME = "TEST_APPLICATION";
- private static final int PID = 10;
- private static final String MACHINE_NAME = "test-machine";
- private static final String HOST_IP = "127.0.0.1";
- private static final ServiceType SERVICE_TYPE = ServiceType.TEST_STAND_ALONE;
- private static final String JVM_VERSION = JvmUtils.getSystemProperty(SystemPropertyKey.JAVA_VERSION);
- private static final String AGENT_VERSION = Version.VERSION;
-
- public TestAgentInformation() {
- super(AGENT_ID, APPLICATION_NAME, System.currentTimeMillis(), PID, MACHINE_NAME, HOST_IP, SERVICE_TYPE, JVM_VERSION, AGENT_VERSION);
- }
-}
+/*
+ * Copyright 2015 NAVER Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.navercorp.pinpoint.test;
+
+import com.navercorp.pinpoint.common.Version;
+import com.navercorp.pinpoint.common.trace.ServiceType;
+import com.navercorp.pinpoint.common.util.JvmUtils;
+import com.navercorp.pinpoint.common.util.SystemPropertyKey;
+import com.navercorp.pinpoint.profiler.AgentInformation;
+
+/**
+ * @author HyunGil Jeong
+ */
+public class TestAgentInformation extends AgentInformation {
+
+ private static final String AGENT_ID = "test-agent";
+ private static final String APPLICATION_NAME = "TEST_APPLICATION";
+ private static final int PID = 10;
+ private static final String MACHINE_NAME = "test-machine";
+ private static final String HOST_IP = "127.0.0.1";
+ private static final ServiceType SERVICE_TYPE = ServiceType.TEST_STAND_ALONE;
+ private static final String JVM_VERSION = JvmUtils.getSystemProperty(SystemPropertyKey.JAVA_VERSION);
+ private static final String AGENT_VERSION = Version.VERSION;
+
+ public TestAgentInformation() {
+ super(AGENT_ID, APPLICATION_NAME, System.currentTimeMillis(), PID, MACHINE_NAME, HOST_IP, SERVICE_TYPE, JVM_VERSION, AGENT_VERSION);
+ }
+}
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/TestInterceptorRegistryBinder.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/TestInterceptorRegistryBinder.java
similarity index 100%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/TestInterceptorRegistryBinder.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/TestInterceptorRegistryBinder.java
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/TestProfilerPluginClassLoader.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/TestProfilerPluginClassLoader.java
similarity index 99%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/TestProfilerPluginClassLoader.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/TestProfilerPluginClassLoader.java
index 5085d96fb..a66850796 100644
--- a/profiler/src/main/java/com/navercorp/pinpoint/test/TestProfilerPluginClassLoader.java
+++ b/profiler-test/src/main/java/com/navercorp/pinpoint/test/TestProfilerPluginClassLoader.java
@@ -1,11 +1,11 @@
-/**
+/*
* Copyright 2014 NAVER Corp.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/TestTcpDataSender.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/TestTcpDataSender.java
similarity index 99%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/TestTcpDataSender.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/TestTcpDataSender.java
index 757cce1af..fa2f81d4b 100644
--- a/profiler/src/main/java/com/navercorp/pinpoint/test/TestTcpDataSender.java
+++ b/profiler-test/src/main/java/com/navercorp/pinpoint/test/TestTcpDataSender.java
@@ -1,11 +1,11 @@
-/**
+/*
* Copyright 2014 NAVER Corp.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/TestableServerMetaDataListener.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/TestableServerMetaDataListener.java
similarity index 96%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/TestableServerMetaDataListener.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/TestableServerMetaDataListener.java
index 7795c982f..18dcfcac6 100644
--- a/profiler/src/main/java/com/navercorp/pinpoint/test/TestableServerMetaDataListener.java
+++ b/profiler-test/src/main/java/com/navercorp/pinpoint/test/TestableServerMetaDataListener.java
@@ -1,38 +1,38 @@
-/*
- * Copyright 2015 NAVER Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.navercorp.pinpoint.test;
-
-import com.navercorp.pinpoint.bootstrap.context.ServerMetaData;
-import com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder.ServerMetaDataListener;
-
-/**
- * @author HyunGil Jeong
- */
-public class TestableServerMetaDataListener implements ServerMetaDataListener {
-
- private volatile ServerMetaData serverMetaData;
-
- @Override
- public void publishServerMetaData(ServerMetaData serverMetaData) {
- this.serverMetaData = serverMetaData;
- }
-
- public ServerMetaData getServerMetaData() {
- return this.serverMetaData;
- }
-
-}
+/*
+ * Copyright 2015 NAVER Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.navercorp.pinpoint.test;
+
+import com.navercorp.pinpoint.bootstrap.context.ServerMetaData;
+import com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder.ServerMetaDataListener;
+
+/**
+ * @author HyunGil Jeong
+ */
+public class TestableServerMetaDataListener implements ServerMetaDataListener {
+
+ private volatile ServerMetaData serverMetaData;
+
+ @Override
+ public void publishServerMetaData(ServerMetaData serverMetaData) {
+ this.serverMetaData = serverMetaData;
+ }
+
+ public ServerMetaData getServerMetaData() {
+ return this.serverMetaData;
+ }
+
+}
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/classloader/DefaultTranslator.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/classloader/DefaultTranslator.java
similarity index 100%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/classloader/DefaultTranslator.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/classloader/DefaultTranslator.java
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/classloader/JavassistTranslator.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/classloader/JavassistTranslator.java
similarity index 100%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/classloader/JavassistTranslator.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/classloader/JavassistTranslator.java
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/classloader/TestClassList.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/classloader/TestClassList.java
similarity index 100%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/classloader/TestClassList.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/classloader/TestClassList.java
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/classloader/TestClassLoader.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/classloader/TestClassLoader.java
similarity index 100%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/classloader/TestClassLoader.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/classloader/TestClassLoader.java
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/classloader/TestClassLoaderFactory.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/classloader/TestClassLoaderFactory.java
similarity index 100%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/classloader/TestClassLoaderFactory.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/classloader/TestClassLoaderFactory.java
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/classloader/TransformClassLoader.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/classloader/TransformClassLoader.java
similarity index 100%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/classloader/TransformClassLoader.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/classloader/TransformClassLoader.java
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/classloader/Translator.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/classloader/Translator.java
similarity index 100%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/classloader/Translator.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/classloader/Translator.java
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/junit4/AfterCallbackStatement.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/junit4/AfterCallbackStatement.java
similarity index 100%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/junit4/AfterCallbackStatement.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/junit4/AfterCallbackStatement.java
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/junit4/BasePinpointTest.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/junit4/BasePinpointTest.java
similarity index 97%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/junit4/BasePinpointTest.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/junit4/BasePinpointTest.java
index 4f844b95f..a30ac4fad 100644
--- a/profiler/src/main/java/com/navercorp/pinpoint/test/junit4/BasePinpointTest.java
+++ b/profiler-test/src/main/java/com/navercorp/pinpoint/test/junit4/BasePinpointTest.java
@@ -1,111 +1,111 @@
-/*
- * Copyright 2014 NAVER Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.navercorp.pinpoint.test.junit4;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.navercorp.pinpoint.common.server.bo.SpanFactory;
-import com.navercorp.pinpoint.profiler.sender.DataSender;
-import com.navercorp.pinpoint.test.ListenableDataSender;
-import com.navercorp.pinpoint.test.MockAgent;
-import com.navercorp.pinpoint.test.ResettableServerMetaDataHolder;
-import com.navercorp.pinpoint.test.TestableServerMetaDataListener;
-
-import org.apache.thrift.TBase;
-import org.junit.runner.RunWith;
-
-import com.navercorp.pinpoint.bootstrap.context.ServerMetaData;
-import com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder;
-import com.navercorp.pinpoint.common.server.bo.SpanBo;
-import com.navercorp.pinpoint.common.server.bo.SpanEventBo;
-import com.navercorp.pinpoint.profiler.context.Span;
-import com.navercorp.pinpoint.profiler.context.SpanEvent;
-import com.navercorp.pinpoint.test.TBaseRecorder;
-
-/**
- * @author hyungil.jeong
- */
-@RunWith(value = PinpointJUnit4ClassRunner.class)
-public abstract class BasePinpointTest {
-
- private volatile TBaseRecorder extends TBase, ?>> tBaseRecorder;
- private volatile ServerMetaDataHolder serverMetaDataHolder;
- private final TestableServerMetaDataListener listener = new TestableServerMetaDataListener();
- private final SpanFactory spanFactory = new SpanFactory();
-
- protected List getCurrentSpanEvents() {
- List spanEvents = new ArrayList();
- for (TBase, ?> span : this.tBaseRecorder) {
- if (span instanceof SpanEvent) {
- SpanEvent spanEvent = (SpanEvent)span;
- SpanEventBo spanEventBo = spanFactory.buildSpanEventBo(spanEvent);
- spanEvents.add(spanEventBo);
- }
- }
- return spanEvents;
- }
-
- protected List getCurrentRootSpans() {
- List rootSpans = new ArrayList();
- for (TBase, ?> span : this.tBaseRecorder) {
- if (span instanceof Span) {
- SpanBo spanBo = spanFactory.buildSpanBo((Span) span);
- rootSpans.add(spanBo);
- }
- }
- return rootSpans;
- }
-
- protected ServerMetaData getServerMetaData() {
- return this.listener.getServerMetaData();
- }
-
- private void setTBaseRecorder(TBaseRecorder tBaseRecorder) {
- this.tBaseRecorder = tBaseRecorder;
- }
-
- private void setServerMetaDataHolder(ServerMetaDataHolder serverMetaDataHolder) {
- this.serverMetaDataHolder = serverMetaDataHolder;
- }
-
- public void setup(TestContext testContext) {
- MockAgent mockAgent = testContext.getMockAgent();
-
- DataSender spanDataSender = mockAgent.getSpanDataSender();
- if (spanDataSender instanceof ListenableDataSender) {
- ListenableDataSender listenableDataSender = (ListenableDataSender) spanDataSender;
-
- final TBaseRecorder tBaseRecord = new TBaseRecorder();
-
- listenableDataSender.setListener(new ListenableDataSender.Listener() {
- @Override
- public boolean handleSend(TBase, ?> data) {
- return tBaseRecord.add(data);
- }
- });
- setTBaseRecorder(tBaseRecord);
- }
-
- ServerMetaDataHolder serverMetaDataHolder = mockAgent.getTraceContext().getServerMetaDataHolder();
- if (serverMetaDataHolder instanceof ResettableServerMetaDataHolder) {
- ResettableServerMetaDataHolder resettableServerMetaDataHolder = (ResettableServerMetaDataHolder) serverMetaDataHolder;
- this.setServerMetaDataHolder(resettableServerMetaDataHolder);
- }
- this.serverMetaDataHolder.addListener(this.listener);
- }
-}
+/*
+ * Copyright 2014 NAVER Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.navercorp.pinpoint.test.junit4;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.navercorp.pinpoint.common.server.bo.SpanFactory;
+import com.navercorp.pinpoint.profiler.sender.DataSender;
+import com.navercorp.pinpoint.test.ListenableDataSender;
+import com.navercorp.pinpoint.test.MockAgent;
+import com.navercorp.pinpoint.test.ResettableServerMetaDataHolder;
+import com.navercorp.pinpoint.test.TestableServerMetaDataListener;
+
+import org.apache.thrift.TBase;
+import org.junit.runner.RunWith;
+
+import com.navercorp.pinpoint.bootstrap.context.ServerMetaData;
+import com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder;
+import com.navercorp.pinpoint.common.server.bo.SpanBo;
+import com.navercorp.pinpoint.common.server.bo.SpanEventBo;
+import com.navercorp.pinpoint.profiler.context.Span;
+import com.navercorp.pinpoint.profiler.context.SpanEvent;
+import com.navercorp.pinpoint.test.TBaseRecorder;
+
+/**
+ * @author hyungil.jeong
+ */
+@RunWith(value = PinpointJUnit4ClassRunner.class)
+public abstract class BasePinpointTest {
+
+ private volatile TBaseRecorder extends TBase, ?>> tBaseRecorder;
+ private volatile ServerMetaDataHolder serverMetaDataHolder;
+ private final TestableServerMetaDataListener listener = new TestableServerMetaDataListener();
+ private final SpanFactory spanFactory = new SpanFactory();
+
+ protected List getCurrentSpanEvents() {
+ List spanEvents = new ArrayList();
+ for (TBase, ?> span : this.tBaseRecorder) {
+ if (span instanceof SpanEvent) {
+ SpanEvent spanEvent = (SpanEvent)span;
+ SpanEventBo spanEventBo = spanFactory.buildSpanEventBo(spanEvent);
+ spanEvents.add(spanEventBo);
+ }
+ }
+ return spanEvents;
+ }
+
+ protected List getCurrentRootSpans() {
+ List rootSpans = new ArrayList();
+ for (TBase, ?> span : this.tBaseRecorder) {
+ if (span instanceof Span) {
+ SpanBo spanBo = spanFactory.buildSpanBo((Span) span);
+ rootSpans.add(spanBo);
+ }
+ }
+ return rootSpans;
+ }
+
+ protected ServerMetaData getServerMetaData() {
+ return this.listener.getServerMetaData();
+ }
+
+ private void setTBaseRecorder(TBaseRecorder tBaseRecorder) {
+ this.tBaseRecorder = tBaseRecorder;
+ }
+
+ private void setServerMetaDataHolder(ServerMetaDataHolder serverMetaDataHolder) {
+ this.serverMetaDataHolder = serverMetaDataHolder;
+ }
+
+ public void setup(TestContext testContext) {
+ MockAgent mockAgent = testContext.getMockAgent();
+
+ DataSender spanDataSender = mockAgent.getSpanDataSender();
+ if (spanDataSender instanceof ListenableDataSender) {
+ ListenableDataSender listenableDataSender = (ListenableDataSender) spanDataSender;
+
+ final TBaseRecorder tBaseRecord = new TBaseRecorder();
+
+ listenableDataSender.setListener(new ListenableDataSender.Listener() {
+ @Override
+ public boolean handleSend(TBase, ?> data) {
+ return tBaseRecord.add(data);
+ }
+ });
+ setTBaseRecorder(tBaseRecord);
+ }
+
+ ServerMetaDataHolder serverMetaDataHolder = mockAgent.getTraceContext().getServerMetaDataHolder();
+ if (serverMetaDataHolder instanceof ResettableServerMetaDataHolder) {
+ ResettableServerMetaDataHolder resettableServerMetaDataHolder = (ResettableServerMetaDataHolder) serverMetaDataHolder;
+ this.setServerMetaDataHolder(resettableServerMetaDataHolder);
+ }
+ this.serverMetaDataHolder.addListener(this.listener);
+ }
+}
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/junit4/BeforeCallbackStatement.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/junit4/BeforeCallbackStatement.java
similarity index 100%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/junit4/BeforeCallbackStatement.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/junit4/BeforeCallbackStatement.java
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/junit4/IsRootSpan.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/junit4/IsRootSpan.java
similarity index 100%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/junit4/IsRootSpan.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/junit4/IsRootSpan.java
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/junit4/PinpointJUnit4ClassRunner.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/junit4/PinpointJUnit4ClassRunner.java
similarity index 89%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/junit4/PinpointJUnit4ClassRunner.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/junit4/PinpointJUnit4ClassRunner.java
index e5d86de30..4ae556fc8 100644
--- a/profiler/src/main/java/com/navercorp/pinpoint/test/junit4/PinpointJUnit4ClassRunner.java
+++ b/profiler-test/src/main/java/com/navercorp/pinpoint/test/junit4/PinpointJUnit4ClassRunner.java
@@ -1,187 +1,184 @@
-/*
- * Copyright 2014 NAVER Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.navercorp.pinpoint.test.junit4;
-
-import java.lang.reflect.Method;
-
-
-
-
-import org.junit.internal.runners.model.EachTestNotifier;
-import org.junit.runner.notification.RunNotifier;
-import org.junit.runners.BlockJUnit4ClassRunner;
-import org.junit.runners.model.FrameworkMethod;
-import org.junit.runners.model.InitializationError;
-import org.junit.runners.model.Statement;
-import org.junit.runners.model.TestClass;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.navercorp.pinpoint.bootstrap.context.SpanRecorder;
-import com.navercorp.pinpoint.bootstrap.context.Trace;
-import com.navercorp.pinpoint.bootstrap.context.TraceContext;
-import com.navercorp.pinpoint.common.trace.ServiceType;
-
-/**
- * @author hyungil.jeong
- * @author emeroad
- */
-public final class PinpointJUnit4ClassRunner extends BlockJUnit4ClassRunner {
-
- private static final Logger logger = LoggerFactory.getLogger(PinpointJUnit4ClassRunner.class);
-
- private static TestContext testContext;
-
- public PinpointJUnit4ClassRunner(Class> clazz) throws InitializationError {
- super(clazz);
- if (logger.isDebugEnabled()) {
- logger.debug("PinpointJUnit4ClassRunner constructor called with [{}].", clazz);
- }
- }
-
- private void beforeTestClass() {
- try {
- // TODO fix static TestContext
- if (testContext == null) {
- logger.debug("traceContext is null");
- this.testContext = new TestContext();
- }
- } catch (Throwable ex) {
- throw new RuntimeException(ex.getMessage(), ex);
- }
- }
-
- protected TestClass createTestClass(Class> testClass) {
- logger.debug("createTestClass {}", testClass);
- beforeTestClass();
- return testContext.createTestClass(testClass);
- }
-
- @Override
- protected void runChild(FrameworkMethod method, RunNotifier notifier) {
- beginTracing(method);
- final Thread thread = Thread.currentThread();
- ClassLoader originalClassLoader = thread.getContextClassLoader();
- try {
- thread.setContextClassLoader(this.testContext.getClassLoader());
- super.runChild(method, notifier);
- } finally {
- thread.setContextClassLoader(originalClassLoader);
- endTracing(method, notifier);
- }
- }
-
- private void beginTracing(FrameworkMethod method) {
- if (shouldCreateNewTraceObject(method)) {
- TraceContext traceContext = this.testContext.getMockAgent().getTraceContext();
- Trace trace = traceContext.newTraceObject();
- SpanRecorder recorder = trace.getSpanRecorder();
- recorder.recordServiceType(ServiceType.TEST);
- }
- }
-
- private void endTracing(FrameworkMethod method, RunNotifier notifier) {
- if (shouldCreateNewTraceObject(method)) {
- TraceContext traceContext = this.testContext.getMockAgent().getTraceContext();
- try {
- Trace trace = traceContext.currentRawTraceObject();
- if (trace == null) {
- // Trace is already detached from the ThreadLocal storage.
- // Happens when root trace method is tested without @IsRootSpan.
- EachTestNotifier testMethodNotifier = new EachTestNotifier(notifier, super.describeChild(method));
- String traceObjectAlreadyDetachedMessage = "Trace object already detached. If you're testing a trace root, please add @IsRootSpan to the test method";
- testMethodNotifier.addFailure(new IllegalStateException(traceObjectAlreadyDetachedMessage));
- } else {
- trace.close();
- }
- } finally {
- traceContext.removeTraceObject();
- }
- }
- }
-
- private boolean shouldCreateNewTraceObject(FrameworkMethod method) {
- IsRootSpan isRootSpan = method.getAnnotation(IsRootSpan.class);
- if (isRootSpan == null || !isRootSpan.value()) {
- return true;
- }
- return false;
- }
-
- @Override
- protected Statement methodInvoker(FrameworkMethod method, Object test) {
- return super.methodInvoker(method, test);
- }
-
- @Override
- protected Statement withBefores(FrameworkMethod method, final Object target, Statement statement) {
- Statement before = super.withBefores(method, target, statement);
- BeforeCallbackStatement callbackStatement = new BeforeCallbackStatement(before, new Statement() {
- @Override
- public void evaluate() throws Throwable {
- setupBaseTest(target);
- }
- });
- return callbackStatement;
- }
-
- private void setupBaseTest(Object test) {
- logger.debug("setupBaseTest");
- // It's safe to cast
- final Class> baseTestClass = this.testContext.getBaseTestClass();
- if (baseTestClass.isInstance(test)) {
- try {
- Method reset = baseTestClass.getDeclaredMethod("setup", TestContext.class);
- reset.invoke(test, this.testContext);
- } catch (Exception e) {
- throw new RuntimeException("setCurrentHolder Error. Caused by:" + e.getMessage(), e);
- }
- }
- }
-
- @Override
- protected Statement withBeforeClasses(Statement statement) {
- final Statement beforeClasses = super.withBeforeClasses(statement);
- return new BeforeCallbackStatement(beforeClasses, new Statement() {
- @Override
- public void evaluate() throws Throwable {
- beforeClass();
- }
- });
- }
-
- public void beforeClass() throws Throwable {
- logger.debug("beforeClass");
- // TODO MockAgent.start();
- }
-
- @Override
- protected Statement withAfterClasses(Statement statement) {
- final Statement afterClasses = super.withAfterClasses(statement);
- return new AfterCallbackStatement(afterClasses, new Statement() {
- @Override
- public void evaluate() throws Throwable {
- afterClass();
- }
- });
- }
-
- public void afterClass() throws Throwable {
- logger.debug("afterClass");
- // TODO MockAgent.close()
- }
+/*
+ * Copyright 2014 NAVER Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.navercorp.pinpoint.test.junit4;
+
+import java.lang.reflect.Method;
+
+
+
+
+import org.junit.internal.runners.model.EachTestNotifier;
+import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.InitializationError;
+import org.junit.runners.model.Statement;
+import org.junit.runners.model.TestClass;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.navercorp.pinpoint.bootstrap.context.SpanRecorder;
+import com.navercorp.pinpoint.bootstrap.context.Trace;
+import com.navercorp.pinpoint.bootstrap.context.TraceContext;
+import com.navercorp.pinpoint.common.trace.ServiceType;
+
+/**
+ * @author hyungil.jeong
+ * @author emeroad
+ */
+public final class PinpointJUnit4ClassRunner extends BlockJUnit4ClassRunner {
+
+ private static final Logger logger = LoggerFactory.getLogger(PinpointJUnit4ClassRunner.class);
+
+ private static TestContext testContext;
+
+ public PinpointJUnit4ClassRunner(Class> clazz) throws InitializationError {
+ super(clazz);
+ if (logger.isDebugEnabled()) {
+ logger.debug("PinpointJUnit4ClassRunner constructor called with [{}].", clazz);
+ }
+ }
+
+ private void beforeTestClass() {
+ try {
+ // TODO fix static TestContext
+ if (testContext == null) {
+ logger.debug("traceContext is null");
+ testContext = new TestContext();
+ }
+ } catch (Throwable ex) {
+ throw new RuntimeException(ex.getMessage(), ex);
+ }
+ }
+
+ protected TestClass createTestClass(Class> testClass) {
+ logger.debug("createTestClass {}", testClass);
+ beforeTestClass();
+ return testContext.createTestClass(testClass);
+ }
+
+ @Override
+ protected void runChild(FrameworkMethod method, RunNotifier notifier) {
+ beginTracing(method);
+ final Thread thread = Thread.currentThread();
+ ClassLoader originalClassLoader = thread.getContextClassLoader();
+ try {
+ thread.setContextClassLoader(testContext.getClassLoader());
+ super.runChild(method, notifier);
+ } finally {
+ thread.setContextClassLoader(originalClassLoader);
+ endTracing(method, notifier);
+ }
+ }
+
+ private void beginTracing(FrameworkMethod method) {
+ if (shouldCreateNewTraceObject(method)) {
+ TraceContext traceContext = testContext.getMockAgent().getTraceContext();
+ Trace trace = traceContext.newTraceObject();
+ SpanRecorder recorder = trace.getSpanRecorder();
+ recorder.recordServiceType(ServiceType.TEST);
+ }
+ }
+
+ private void endTracing(FrameworkMethod method, RunNotifier notifier) {
+ if (shouldCreateNewTraceObject(method)) {
+ TraceContext traceContext = testContext.getMockAgent().getTraceContext();
+ try {
+ Trace trace = traceContext.currentRawTraceObject();
+ if (trace == null) {
+ // Trace is already detached from the ThreadLocal storage.
+ // Happens when root trace method is tested without @IsRootSpan.
+ EachTestNotifier testMethodNotifier = new EachTestNotifier(notifier, super.describeChild(method));
+ String traceObjectAlreadyDetachedMessage = "Trace object already detached. If you're testing a trace root, please add @IsRootSpan to the test method";
+ testMethodNotifier.addFailure(new IllegalStateException(traceObjectAlreadyDetachedMessage));
+ } else {
+ trace.close();
+ }
+ } finally {
+ traceContext.removeTraceObject();
+ }
+ }
+ }
+
+ private boolean shouldCreateNewTraceObject(FrameworkMethod method) {
+ IsRootSpan isRootSpan = method.getAnnotation(IsRootSpan.class);
+ return isRootSpan == null || !isRootSpan.value();
+ }
+
+ @Override
+ protected Statement methodInvoker(FrameworkMethod method, Object test) {
+ return super.methodInvoker(method, test);
+ }
+
+ @Override
+ protected Statement withBefores(FrameworkMethod method, final Object target, Statement statement) {
+ Statement before = super.withBefores(method, target, statement);
+ BeforeCallbackStatement callbackStatement = new BeforeCallbackStatement(before, new Statement() {
+ @Override
+ public void evaluate() throws Throwable {
+ setupBaseTest(target);
+ }
+ });
+ return callbackStatement;
+ }
+
+ private void setupBaseTest(Object test) {
+ logger.debug("setupBaseTest");
+ // It's safe to cast
+ final Class> baseTestClass = testContext.getBaseTestClass();
+ if (baseTestClass.isInstance(test)) {
+ try {
+ Method reset = baseTestClass.getDeclaredMethod("setup", TestContext.class);
+ reset.invoke(test, testContext);
+ } catch (Exception e) {
+ throw new RuntimeException("setCurrentHolder Error. Caused by:" + e.getMessage(), e);
+ }
+ }
+ }
+
+ @Override
+ protected Statement withBeforeClasses(Statement statement) {
+ final Statement beforeClasses = super.withBeforeClasses(statement);
+ return new BeforeCallbackStatement(beforeClasses, new Statement() {
+ @Override
+ public void evaluate() throws Throwable {
+ beforeClass();
+ }
+ });
+ }
+
+ public void beforeClass() throws Throwable {
+ logger.debug("beforeClass");
+ // TODO MockAgent.start();
+ }
+
+ @Override
+ protected Statement withAfterClasses(Statement statement) {
+ final Statement afterClasses = super.withAfterClasses(statement);
+ return new AfterCallbackStatement(afterClasses, new Statement() {
+ @Override
+ public void evaluate() throws Throwable {
+ afterClass();
+ }
+ });
+ }
+
+ public void afterClass() throws Throwable {
+ logger.debug("afterClass");
+ // TODO MockAgent.close()
+ }
}
\ No newline at end of file
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/junit4/TestContext.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/junit4/TestContext.java
similarity index 100%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/junit4/TestContext.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/junit4/TestContext.java
index 9ac1b77b0..15cc477e6 100644
--- a/profiler/src/main/java/com/navercorp/pinpoint/test/junit4/TestContext.java
+++ b/profiler-test/src/main/java/com/navercorp/pinpoint/test/junit4/TestContext.java
@@ -19,6 +19,8 @@ package com.navercorp.pinpoint.test.junit4;
import java.io.Closeable;
import java.io.IOException;
+import com.navercorp.pinpoint.test.classloader.TestClassLoader;
+import com.navercorp.pinpoint.test.classloader.TestClassLoaderFactory;
import org.junit.runners.model.TestClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -27,8 +29,6 @@ import com.navercorp.pinpoint.bootstrap.logging.PLoggerBinder;
import com.navercorp.pinpoint.bootstrap.logging.PLoggerFactory;
import com.navercorp.pinpoint.profiler.logging.Slf4jLoggerBinder;
import com.navercorp.pinpoint.test.MockAgent;
-import com.navercorp.pinpoint.test.classloader.TestClassLoader;
-import com.navercorp.pinpoint.test.classloader.TestClassLoaderFactory;
/**
* @author hyungil.jeong
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/util/BytecodeUtils.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/util/BytecodeUtils.java
similarity index 99%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/util/BytecodeUtils.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/util/BytecodeUtils.java
index 3bf42d87c..5783f5343 100644
--- a/profiler/src/main/java/com/navercorp/pinpoint/test/util/BytecodeUtils.java
+++ b/profiler-test/src/main/java/com/navercorp/pinpoint/test/util/BytecodeUtils.java
@@ -122,7 +122,7 @@ public final class BytecodeUtils {
}
} finally {
if (close) {
- is.close();
+ close(is);
}
}
}
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/util/LoaderUtils.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/util/LoaderUtils.java
similarity index 71%
rename from profiler/src/main/java/com/navercorp/pinpoint/test/util/LoaderUtils.java
rename to profiler-test/src/main/java/com/navercorp/pinpoint/test/util/LoaderUtils.java
index edc03fabd..3749bfa68 100644
--- a/profiler/src/main/java/com/navercorp/pinpoint/test/util/LoaderUtils.java
+++ b/profiler-test/src/main/java/com/navercorp/pinpoint/test/util/LoaderUtils.java
@@ -38,11 +38,7 @@ public final class LoaderUtils {
}
Loader loader;
if (SECURITY_MANAGER != null) {
- loader = AccessController.doPrivileged(new PrivilegedAction() {
- public Loader run() {
- return new Loader(classPool);
- }
- });
+ loader = AccessController.doPrivileged(new LoaderCreateAction(classPool));
} else {
loader = new Loader(classPool);
}
@@ -50,4 +46,20 @@ public final class LoaderUtils {
return loader;
}
+ static class LoaderCreateAction implements PrivilegedAction {
+ private final ClassPool classPool;
+
+ public LoaderCreateAction(final ClassPool classPool) {
+ if (classPool == null) {
+ throw new NullPointerException("classPool must not be null");
+ }
+ this.classPool = classPool;
+ }
+
+ public Loader run() {
+ return new Loader(classPool);
+ }
+ }
+
+
}
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/test/MethodDescriptionUtilsTest.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/MethodDescriptionUtilsTest.java
similarity index 100%
rename from profiler/src/test/java/com/navercorp/pinpoint/test/MethodDescriptionUtilsTest.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/MethodDescriptionUtilsTest.java
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/test/OrderedSpanRecorderTest.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/OrderedSpanRecorderTest.java
similarity index 96%
rename from profiler/src/test/java/com/navercorp/pinpoint/test/OrderedSpanRecorderTest.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/OrderedSpanRecorderTest.java
index 5bb8c31cb..a999b174a 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/test/OrderedSpanRecorderTest.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/OrderedSpanRecorderTest.java
@@ -1,172 +1,172 @@
-/*
- * Copyright 2015 NAVER Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.navercorp.pinpoint.test;
-
-import static org.junit.Assert.*;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.thrift.TBase;
-import org.junit.After;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.navercorp.pinpoint.profiler.context.Span;
-import com.navercorp.pinpoint.profiler.context.SpanEvent;
-
-/**
- * @author HyunGil Jeong
- */
-public class OrderedSpanRecorderTest {
-
- private static final int UNSET_ASYNC_ID = 0;
-
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
- private final OrderedSpanRecorder recorder = new OrderedSpanRecorder();
-
- @After
- public void tearDown() throws Exception {
- this.recorder.clear();
- }
-
- @Test
- public void testOrderingWithSameEventTime() {
- // given
- final long startTime = System.currentTimeMillis();
- final long spanId = 1L;
- Span span = createSpan(startTime, spanId);
- SpanEvent event = createSpanEvent(span, 0, (short)0);
- SpanEvent event1 = createSpanEvent(span, 0, (short)1);
- SpanEvent event2 = createSpanEvent(span, 0, (short)2);
- SpanEvent asyncEvent1 = createAsyncSpanEvent(span, 0, (short)0, 1);
- SpanEvent asyncEvent1_1 = createAsyncSpanEvent(span, 0, (short)1, 1);
- SpanEvent asyncEvent2 = createAsyncSpanEvent(span, 0, (short)0, 2);
- @SuppressWarnings("unchecked")
- final List extends TBase,?>> expectedOrder = Arrays.asList(
- span,
- event,
- event1,
- event2,
- asyncEvent1,
- asyncEvent1_1,
- asyncEvent2
- );
- // when
- @SuppressWarnings("unchecked")
- final List extends TBase,?>> listToBeHandled = Arrays.asList(
- span, event, event1, event2, asyncEvent1, asyncEvent1_1, asyncEvent2
- );
- Collections.shuffle(listToBeHandled);
- for (TBase,?> base : listToBeHandled) {
- this.recorder.handleSend(base);
- }
- // then
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- this.recorder.print(new PrintStream(baos));
- this.logger.info(baos.toString());
- for (TBase,?> expectedBase : expectedOrder) {
- TBase,?> actualBase = this.recorder.pop();
- assertSame(expectedBase, actualBase);
- }
- assertNull(this.recorder.pop());
- }
-
- @Test
- public void testMultipleSpanOrdering() {
- // given
- final long startTime1 = System.currentTimeMillis();
- final long spanId1 = 1L;
- final long startTime2 = startTime1 + 10L;
- final long spanId2 = 2L;
- Span span1 = createSpan(startTime1, spanId1);
- SpanEvent event1_0 = createSpanEvent(span1, 1, (short)0);
- SpanEvent event1_1 = createSpanEvent(span1, 2, (short)1);
- SpanEvent asyncEvent1_0 = createAsyncSpanEvent(span1, 1, (short)0, 1);
- SpanEvent asyncEvent1_1 = createAsyncSpanEvent(span1, 2, (short)1, 1);
- Span span2 = createSpan(startTime2, spanId2);
- SpanEvent event2_0 = createSpanEvent(span2, 0, (short)0);
- SpanEvent event2_1 = createSpanEvent(span2, 1, (short)1);
- SpanEvent asyncEvent2_0 = createAsyncSpanEvent(span2, 0, (short)0, 1);
- @SuppressWarnings("unchecked")
- final List extends TBase,?>> expectedOrder = Arrays.asList(
- span1,
- event1_0,
- event1_1,
- span2,
- event2_0,
- event2_1,
- asyncEvent1_0,
- asyncEvent1_1,
- asyncEvent2_0
- );
- // when
- @SuppressWarnings("unchecked")
- final List extends TBase,?>> listToBeHandled = Arrays.asList(
- span1, event1_0, event1_1, span2, event2_0, event2_1, asyncEvent1_0, asyncEvent1_1, asyncEvent2_0
- );
- Collections.shuffle(listToBeHandled);
- for (TBase,?> base : listToBeHandled) {
- this.recorder.handleSend(base);
- }
- // then
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- this.recorder.print(new PrintStream(baos));
- this.logger.info(baos.toString());
- for (TBase,?> expectedBase : expectedOrder) {
- TBase,?> actualBase = this.recorder.pop();
- assertSame(expectedBase, actualBase);
- }
- assertNull(this.recorder.pop());
- }
-
- private SpanEvent createSpanEvent(Span associatedSpan, int startElapsed, short sequence) {
- return createAsyncSpanEvent(associatedSpan, startElapsed, sequence, UNSET_ASYNC_ID);
- }
-
- private SpanEvent createAsyncSpanEvent(Span associatedSpan, int startElapsed, short sequence, int asyncId) {
- if (startElapsed < 0) {
- throw new IllegalArgumentException("startElapsed cannot be less than 0");
- }
- if (sequence < 0) {
- throw new IllegalArgumentException("sequence cannot be less than 0");
- }
- if (asyncId < 0) {
- throw new IllegalArgumentException("asyncId cannot be less than 0");
- }
- SpanEvent event = new SpanEvent(associatedSpan);
- event.setStartElapsed(startElapsed);
- event.setSequence(sequence);
- if (asyncId != UNSET_ASYNC_ID) {
- event.setAsyncId(asyncId);
- }
- return event;
- }
-
- private Span createSpan(long startTime, long spanId) {
- Span span = new Span();
- span.setStartTime(startTime);
- span.setSpanId(spanId);
- return span;
- }
-
-}
+/*
+ * Copyright 2015 NAVER Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.navercorp.pinpoint.test;
+
+import static org.junit.Assert.*;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.thrift.TBase;
+import org.junit.After;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.navercorp.pinpoint.profiler.context.Span;
+import com.navercorp.pinpoint.profiler.context.SpanEvent;
+
+/**
+ * @author HyunGil Jeong
+ */
+public class OrderedSpanRecorderTest {
+
+ private static final int UNSET_ASYNC_ID = 0;
+
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ private final OrderedSpanRecorder recorder = new OrderedSpanRecorder();
+
+ @After
+ public void tearDown() throws Exception {
+ this.recorder.clear();
+ }
+
+ @Test
+ public void testOrderingWithSameEventTime() {
+ // given
+ final long startTime = System.currentTimeMillis();
+ final long spanId = 1L;
+ Span span = createSpan(startTime, spanId);
+ SpanEvent event = createSpanEvent(span, 0, (short)0);
+ SpanEvent event1 = createSpanEvent(span, 0, (short)1);
+ SpanEvent event2 = createSpanEvent(span, 0, (short)2);
+ SpanEvent asyncEvent1 = createAsyncSpanEvent(span, 0, (short)0, 1);
+ SpanEvent asyncEvent1_1 = createAsyncSpanEvent(span, 0, (short)1, 1);
+ SpanEvent asyncEvent2 = createAsyncSpanEvent(span, 0, (short)0, 2);
+ @SuppressWarnings("unchecked")
+ final List extends TBase,?>> expectedOrder = Arrays.asList(
+ span,
+ event,
+ event1,
+ event2,
+ asyncEvent1,
+ asyncEvent1_1,
+ asyncEvent2
+ );
+ // when
+ @SuppressWarnings("unchecked")
+ final List extends TBase,?>> listToBeHandled = Arrays.asList(
+ span, event, event1, event2, asyncEvent1, asyncEvent1_1, asyncEvent2
+ );
+ Collections.shuffle(listToBeHandled);
+ for (TBase,?> base : listToBeHandled) {
+ this.recorder.handleSend(base);
+ }
+ // then
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ this.recorder.print(new PrintStream(baos));
+ this.logger.debug(baos.toString());
+ for (TBase,?> expectedBase : expectedOrder) {
+ TBase,?> actualBase = this.recorder.pop();
+ assertSame(expectedBase, actualBase);
+ }
+ assertNull(this.recorder.pop());
+ }
+
+ @Test
+ public void testMultipleSpanOrdering() {
+ // given
+ final long startTime1 = System.currentTimeMillis();
+ final long spanId1 = 1L;
+ final long startTime2 = startTime1 + 10L;
+ final long spanId2 = 2L;
+ Span span1 = createSpan(startTime1, spanId1);
+ SpanEvent event1_0 = createSpanEvent(span1, 1, (short)0);
+ SpanEvent event1_1 = createSpanEvent(span1, 2, (short)1);
+ SpanEvent asyncEvent1_0 = createAsyncSpanEvent(span1, 1, (short)0, 1);
+ SpanEvent asyncEvent1_1 = createAsyncSpanEvent(span1, 2, (short)1, 1);
+ Span span2 = createSpan(startTime2, spanId2);
+ SpanEvent event2_0 = createSpanEvent(span2, 0, (short)0);
+ SpanEvent event2_1 = createSpanEvent(span2, 1, (short)1);
+ SpanEvent asyncEvent2_0 = createAsyncSpanEvent(span2, 0, (short)0, 1);
+ @SuppressWarnings("unchecked")
+ final List extends TBase,?>> expectedOrder = Arrays.asList(
+ span1,
+ event1_0,
+ event1_1,
+ span2,
+ event2_0,
+ event2_1,
+ asyncEvent1_0,
+ asyncEvent1_1,
+ asyncEvent2_0
+ );
+ // when
+ @SuppressWarnings("unchecked")
+ final List extends TBase,?>> listToBeHandled = Arrays.asList(
+ span1, event1_0, event1_1, span2, event2_0, event2_1, asyncEvent1_0, asyncEvent1_1, asyncEvent2_0
+ );
+ Collections.shuffle(listToBeHandled);
+ for (TBase,?> base : listToBeHandled) {
+ this.recorder.handleSend(base);
+ }
+ // then
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ this.recorder.print(new PrintStream(baos));
+ this.logger.debug(baos.toString());
+ for (TBase,?> expectedBase : expectedOrder) {
+ TBase,?> actualBase = this.recorder.pop();
+ assertSame(expectedBase, actualBase);
+ }
+ assertNull(this.recorder.pop());
+ }
+
+ private SpanEvent createSpanEvent(Span associatedSpan, int startElapsed, short sequence) {
+ return createAsyncSpanEvent(associatedSpan, startElapsed, sequence, UNSET_ASYNC_ID);
+ }
+
+ private SpanEvent createAsyncSpanEvent(Span associatedSpan, int startElapsed, short sequence, int asyncId) {
+ if (startElapsed < 0) {
+ throw new IllegalArgumentException("startElapsed cannot be less than 0");
+ }
+ if (sequence < 0) {
+ throw new IllegalArgumentException("sequence cannot be less than 0");
+ }
+ if (asyncId < 0) {
+ throw new IllegalArgumentException("asyncId cannot be less than 0");
+ }
+ SpanEvent event = new SpanEvent(associatedSpan);
+ event.setStartElapsed(startElapsed);
+ event.setSequence(sequence);
+ if (asyncId != UNSET_ASYNC_ID) {
+ event.setAsyncId(asyncId);
+ }
+ return event;
+ }
+
+ private Span createSpan(long startTime, long spanId) {
+ Span span = new Span();
+ span.setStartTime(startTime);
+ span.setSpanId(spanId);
+ return span;
+ }
+
+}
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/JavaAssistTest.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/JavaAssistInterceptorTest.java
similarity index 87%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/JavaAssistTest.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/JavaAssistInterceptorTest.java
index 9e106df79..f43cd7165 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/JavaAssistTest.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/JavaAssistInterceptorTest.java
@@ -14,14 +14,15 @@
* limitations under the License.
*/
-package com.navercorp.pinpoint.profiler.interceptor.bci;
+package com.navercorp.pinpoint.test.javasssit;
+
import com.navercorp.pinpoint.test.util.LoaderUtils;
-
import javassist.*;
import javassist.expr.ExprEditor;
import javassist.expr.MethodCall;
+import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -31,7 +32,8 @@ import java.lang.reflect.InvocationTargetException;
/**
* @author emeroad
*/
-public class JavaAssistTest {
+@Deprecated
+public class JavaAssistInterceptorTest {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@@ -40,7 +42,7 @@ public class JavaAssistTest {
ClassPool pool = new ClassPool(true);
Loader loader = getLoader(pool);
- CtClass ctClass = pool.get("com.navercorp.pinpoint.profiler.interceptor.bci.TestObject");
+ CtClass ctClass = pool.get("com.navercorp.pinpoint.test.javasssit.mock.TestObject");
CtClass object = pool.get("java.lang.String");
logger.debug("target:{}", ctClass);
@@ -83,7 +85,7 @@ public class JavaAssistTest {
public void afterCatch2() throws NotFoundException, CannotCompileException, NoSuchMethodException, IllegalAccessException, InstantiationException, InvocationTargetException, ClassNotFoundException {
ClassPool pool = new ClassPool(true);
Loader loader = getLoader(pool);
- CtClass ctClass = pool.get("com.navercorp.pinpoint.profiler.interceptor.bci.TestObject");
+ CtClass ctClass = pool.get("com.navercorp.pinpoint.test.javasssit.mock.TestObject");
CtClass object = pool.get("java.lang.String");
logger.debug("target:{}", ctClass);
@@ -109,7 +111,7 @@ public class JavaAssistTest {
Loader loader = getLoader(pool);
- CtClass ctClass = pool.get("com.navercorp.pinpoint.profiler.interceptor.bci.TestObject");
+ CtClass ctClass = pool.get("com.navercorp.pinpoint.test.javasssit.mock.TestObject");
CtClass object = pool.get("java.lang.String");
logger.debug("target:{}", ctClass);
@@ -118,9 +120,9 @@ public class JavaAssistTest {
callA.addLocalVariable("__test", object);
String inti = "__test = \"abc\";";
// callA.insertBefore("__test = \"abc\";);
- callA.insertBefore("{com.navercorp.pinpoint.profiler.interceptor.bci.TestObject.before();}");
- callA.insertAfter("{com.navercorp.pinpoint.profiler.interceptor.bci.TestObject.after();}");
- callA.addCatch("{ com.navercorp.pinpoint.profiler.interceptor.bci.TestObject.callCatch(); throw $e; }", pool.get("java.lang.Throwable"));
+ callA.insertBefore("{com.navercorp.pinpoint.test.javasssit.mock.TestObject.before();}");
+ callA.insertAfter("{com.navercorp.pinpoint.test.javasssit.mock.TestObject.after();}");
+ callA.addCatch("{ com.navercorp.pinpoint.test.javasssit.mock.TestObject.callCatch(); throw $e; }", pool.get("java.lang.Throwable"));
Class aClass = loader.loadClass(ctClass.getName());
java.lang.reflect.Method callA1 = aClass.getMethod("callA");
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/javaassist/JavaAssistTest.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/JavaAssistTest.java
similarity index 64%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/javaassist/JavaAssistTest.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/JavaAssistTest.java
index c36bbd44a..cfab8d8b0 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/javaassist/JavaAssistTest.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/JavaAssistTest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.navercorp.pinpoint.profiler.javaassist;
+package com.navercorp.pinpoint.test.javasssit;
import javassist.ClassPool;
import javassist.CtClass;
@@ -32,6 +32,7 @@ import java.util.Arrays;
/**
* @author emeroad
*/
+@Deprecated
public class JavaAssistTest {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@@ -44,16 +45,11 @@ public class JavaAssistTest {
pool.appendSystemPath();
}
- @Test
- public void newClass() {
-
- }
-
@Test
public void testAssist() throws NotFoundException, NoSuchMethodException {
CtClass ctClass = pool.get(String.class.getName());
- logger.info(ctClass.toString());
+ logger.debug(ctClass.toString());
String s = "";
// ctClass.getMethod("valueOf", "(D)");
@@ -63,15 +59,15 @@ public class JavaAssistTest {
// }
CtMethod endsWith = ctClass.getMethod("endsWith", "(Ljava/lang/String;)Z");
- logger.info(endsWith.getMethodInfo().toString());
- logger.info(endsWith.getSignature());
- logger.info(endsWith.getLongName());
- logger.info(endsWith.toString());
- logger.info(endsWith.getName());
- logger.info(endsWith.getMethodInfo().getName());
- logger.info(endsWith.getMethodInfo().getDescriptor());
+ logger.debug(endsWith.getMethodInfo().toString());
+ logger.debug(endsWith.getSignature());
+ logger.debug(endsWith.getLongName());
+ logger.debug(endsWith.toString());
+ logger.debug(endsWith.getName());
+ logger.debug(endsWith.getMethodInfo().getName());
+ logger.debug(endsWith.getMethodInfo().getDescriptor());
- Method endsWith1 = String.class.getMethod("endsWith", new Class[]{String.class});
+ Method endsWith1 = String.class.getMethod("endsWith", String.class);
logger.debug(endsWith1.toString());
}
@@ -85,29 +81,29 @@ public class JavaAssistTest {
private void sout(String str) {
URL resource = this.getClass().getClassLoader().getResource(str);
- logger.info("{}", resource);
+ logger.debug("{}", resource);
}
@Test
public void genericTest() throws NotFoundException {
- CtClass testClass = pool.get("com.navercorp.pinpoint.profiler.javaassist.TestClass");
+ CtClass testClass = pool.get("com.navercorp.pinpoint.test.javasssit.TestClass");
// CtMethod setb = testClass.getMethod("setb");
CtMethod[] declaredMethods = testClass.getDeclaredMethods();
for (CtMethod declaredMethod : declaredMethods) {
- logger.info(declaredMethod.toString());
- logger.info(declaredMethod.getGenericSignature());
- logger.info(declaredMethod.getSignature());
- logger.info("paramTypes:{}", Arrays.toString(declaredMethod.getParameterTypes()));
- logger.info(declaredMethod.getMethodInfo2().getDescriptor());
- logger.info(declaredMethod.getMethodInfo().getDescriptor());
-// logger.info(declaredMethod.());
+ logger.debug(declaredMethod.toString());
+ logger.debug(declaredMethod.getGenericSignature());
+ logger.debug(declaredMethod.getSignature());
+ logger.debug("paramTypes:{}", Arrays.toString(declaredMethod.getParameterTypes()));
+ logger.debug(declaredMethod.getMethodInfo2().getDescriptor());
+ logger.debug(declaredMethod.getMethodInfo().getDescriptor());
+// logger.debug(declaredMethod.());
}
CtMethod setb = testClass.getDeclaredMethod("setA", new CtClass[]{pool.get("int")});
- logger.info(setb.toString());
+ logger.debug(setb.toString());
CtMethod setStringArray = testClass.getDeclaredMethod("setStringArray", new CtClass[]{pool.get("java.lang.String[]")});
- logger.info(setStringArray.toString());
+ logger.debug(setStringArray.toString());
@@ -115,17 +111,17 @@ public class JavaAssistTest {
@Test
public void innerClass() throws NotFoundException {
- CtClass testClass = pool.get("com.navercorp.pinpoint.profiler.javaassist.TestClass");
+ CtClass testClass = pool.get("com.navercorp.pinpoint.test.javasssit.TestClass");
logger.debug(testClass.toString());
CtClass[] nestedClasses = testClass.getNestedClasses();
for(CtClass nested : nestedClasses) {
logger.debug("nestedClass:{}", nested);
}
- CtClass innerClass = pool.get("com.navercorp.pinpoint.profiler.javaassist.TestClass$InnerClass");
+ CtClass innerClass = pool.get("com.navercorp.pinpoint.test.javasssit.TestClass$InnerClass");
logger.debug("{}", innerClass);
- CtClass class1 = pool.get("com.navercorp.pinpoint.profiler.javaassist.TestClass$1");
+ CtClass class1 = pool.get("com.navercorp.pinpoint.test.javasssit.TestClass$1");
logger.debug("{}", class1);
}
}
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/JavassistClassTest.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/JavassistClassTest.java
similarity index 53%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/JavassistClassTest.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/JavassistClassTest.java
index 1d1062fc9..d650306e5 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/JavassistClassTest.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/JavassistClassTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 NAVER Corp.
+ * Copyright 2016 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -12,28 +12,12 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
+ *
*/
-package com.navercorp.pinpoint.profiler.interceptor.bci;
-
-import static org.junit.Assert.*;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.security.ProtectionDomain;
+package com.navercorp.pinpoint.test.javasssit;
import com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig;
-import com.navercorp.pinpoint.test.util.BytecodeUtils;
-import javassist.bytecode.Descriptor;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import com.navercorp.pinpoint.bootstrap.context.DatabaseInfo;
import com.navercorp.pinpoint.bootstrap.instrument.ClassFilters;
import com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass;
@@ -51,10 +35,39 @@ import com.navercorp.pinpoint.profiler.interceptor.registry.GlobalInterceptorReg
import com.navercorp.pinpoint.profiler.logging.Slf4jLoggerBinder;
import com.navercorp.pinpoint.test.MockAgent;
import com.navercorp.pinpoint.test.classloader.TestClassLoader;
+import com.navercorp.pinpoint.test.javasssit.accessor.BindValueTraceValue;
+import com.navercorp.pinpoint.test.javasssit.accessor.DatabaseInfoTraceValue;
+import com.navercorp.pinpoint.test.javasssit.accessor.IntArrayGetter;
+import com.navercorp.pinpoint.test.javasssit.accessor.IntArraySetter;
+import com.navercorp.pinpoint.test.javasssit.accessor.IntArrayTraceValue;
+import com.navercorp.pinpoint.test.javasssit.accessor.IntGetter;
+import com.navercorp.pinpoint.test.javasssit.accessor.IntSetter;
+import com.navercorp.pinpoint.test.javasssit.accessor.IntTraceValue;
+import com.navercorp.pinpoint.test.javasssit.accessor.IntegerArrayGetter;
+import com.navercorp.pinpoint.test.javasssit.accessor.IntegerArraySetter;
+import com.navercorp.pinpoint.test.javasssit.accessor.IntegerArrayTraceValue;
+import com.navercorp.pinpoint.test.javasssit.accessor.ObjectTraceValue;
+import com.navercorp.pinpoint.test.javasssit.accessor.StringGetter;
+import com.navercorp.pinpoint.test.util.BytecodeUtils;
+import javassist.bytecode.Descriptor;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.security.ProtectionDomain;
+
+import static org.junit.Assert.assertEquals;
/**
* @author emeroad
*/
+@Deprecated
public class JavassistClassTest {
private Logger logger = LoggerFactory.getLogger(JavassistClassTest.class.getName());
@@ -72,7 +85,7 @@ public class JavassistClassTest {
public void testClassHierarchy() throws InstrumentException {
JavassistClassPool pool = new JavassistClassPool(new GlobalInterceptorRegistryBinder(), null);
- String testObjectName = "com.navercorp.pinpoint.profiler.interceptor.bci.TestObject";
+ String testObjectName = "com.navercorp.pinpoint.test.javasssit.mock.TestObject";
byte[] testObjectByteCode = readByteCode(testObjectName);
InstrumentClass testObject = pool.getClass(null, null, testObjectName, testObjectByteCode);
@@ -85,7 +98,7 @@ public class JavassistClassTest {
String[] testObjectSuperClassInterfaces = testObject.getInterfaces();
Assert.assertEquals(testObjectSuperClassInterfaces.length, 0);
- final String classHierarchyTestMockName = "com.navercorp.pinpoint.profiler.interceptor.bci.ClassHierarchyTestMock";
+ final String classHierarchyTestMockName = "com.navercorp.pinpoint.test.javasssit.mock.ClassHierarchyTestMock";
byte[] classHierarchyTestMockByteCode = readByteCode(classHierarchyTestMockName);
InstrumentClass classHierarchyObject = pool.getClass(null, null, classHierarchyTestMockName, classHierarchyTestMockByteCode);
String hierarchySuperClass = classHierarchyObject.getSuperClass();
@@ -102,7 +115,7 @@ public class JavassistClassTest {
JavassistClassPool pool = new JavassistClassPool(new GlobalInterceptorRegistryBinder(), null);
- String testObjectName = "com.navercorp.pinpoint.profiler.interceptor.bci.TestObject";
+ String testObjectName = "com.navercorp.pinpoint.test.javasssit.mock.TestObject";
byte[] testObjectByteCode = readByteCode(testObjectName);
InstrumentClass testObject = pool.getClass(null, null, testObjectName, testObjectByteCode);
@@ -118,7 +131,7 @@ public class JavassistClassTest {
JavassistClassPool pool = new JavassistClassPool(new GlobalInterceptorRegistryBinder(), null);
- String testObjectName = "com.navercorp.pinpoint.profiler.interceptor.bci.TestObject";
+ String testObjectName = "com.navercorp.pinpoint.test.javasssit.mock.TestObject";
byte[] testObjectByteCode = readByteCode(testObjectName);
InstrumentClass testObject = pool.getClass(null, null, testObjectName, testObjectByteCode);
Assert.assertEquals(testObject.getName(), testObjectName);
@@ -136,84 +149,10 @@ public class JavassistClassTest {
Assert.assertEquals(findMethodCount, 1);
}
- @Test
- public void addTraceValue() throws Exception {
- final TestClassLoader loader = getTestClassLoader();
- final String javassistClassName = "com.navercorp.pinpoint.profiler.interceptor.bci.TestObject";
-
- loader.addTransformer(javassistClassName, new TransformCallback() {
-
- @Override
- public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, String className, Class> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws InstrumentException {
- try {
- logger.info("modify cl:{}", loader);
-
- InstrumentClass aClass = instrumentor.getInstrumentClass(loader, javassistClassName, classfileBuffer);
-
- aClass.addField(ObjectTraceValue.class.getName());
- aClass.addField(IntTraceValue.class.getName());
- aClass.addField(IntArrayTraceValue.class.getName());
- aClass.addField(IntegerArrayTraceValue.class.getName());
- aClass.addField(DatabaseInfoTraceValue.class.getName());
- aClass.addField(BindValueTraceValue.class.getName());
-
- String methodName = "callA";
- aClass.getDeclaredMethod(methodName).addInterceptor("com.navercorp.pinpoint.profiler.interceptor.TestBeforeInterceptor");
- return aClass.toBytecode();
- } catch (InstrumentException e) {
- e.printStackTrace();
- throw new RuntimeException(e.getMessage(), e);
- }
- }
- });
-
- Class> testObjectClazz = loader.loadClass(javassistClassName);
- final String methodName = "callA";
- logger.info("class:{}", testObjectClazz.toString());
- final Object testObject = testObjectClazz.newInstance();
- Method callA = testObjectClazz.getMethod(methodName);
- callA.invoke(testObject);
-
- Class> objectTraceValue = loader.loadClass(ObjectTraceValue.class.getName());
- Assert.assertTrue("ObjectTraceValue implements fail", objectTraceValue.isInstance(testObject));
- objectTraceValue.getMethod("_$PINPOINT$_setTraceObject", Object.class).invoke(testObject, "a");
- Object get = objectTraceValue.getMethod("_$PINPOINT$_getTraceObject").invoke(testObject);
- Assert.assertEquals("a", get);
-
- Class> intTraceValue = loader.loadClass(IntTraceValue.class.getName());
- Assert.assertTrue("IntTraceValue implements fail", intTraceValue.isInstance(testObject));
- intTraceValue.getMethod("_$PINPOINT$_setTraceInt", int.class).invoke(testObject, 1);
- int a = (Integer) intTraceValue.getMethod("_$PINPOINT$_getTraceInt").invoke(testObject);
- Assert.assertEquals(1, a);
-
- Class> intArrayTraceValue = loader.loadClass(IntArrayTraceValue.class.getName());
- Assert.assertTrue("IntArrayTraceValue implements fail", intArrayTraceValue.isInstance(testObject));
- int[] expectedInts = {1, 2, 3};
- intArrayTraceValue.getMethod("_$PINPOINT$_setTraceIntArray", int[].class).invoke(testObject, expectedInts);
- int[] ints = (int[]) intArrayTraceValue.getMethod("_$PINPOINT$_getTraceIntArray").invoke(testObject);
- Assert.assertEquals(expectedInts, ints);
-
- Class> integerArrayTraceValue = loader.loadClass(IntegerArrayTraceValue.class.getName());
- Assert.assertTrue("IntegerArrayTraceValue implements fail", integerArrayTraceValue.isInstance(testObject));
- Integer[] expectedIntegers = {1, 2};
- // wrap due to vararg expansion
- Object[] wrappedExpectedIntegers = new Object[]{expectedIntegers};
- integerArrayTraceValue.getMethod("_$PINPOINT$_setTraceIntegerArray", Integer[].class).invoke(testObject, wrappedExpectedIntegers);
- Integer[] integers = (Integer[]) integerArrayTraceValue.getMethod("_$PINPOINT$_getTraceIntegerArray").invoke(testObject);
- Assert.assertArrayEquals(expectedIntegers, integers);
-
- Class> databaseTraceValue = loader.loadClass(DatabaseInfoTraceValue.class.getName());
- Assert.assertTrue("DatabaseInfoTraceValue implements fail", databaseTraceValue.isInstance(testObject));
- databaseTraceValue.getMethod("_$PINPOINT$_setTraceDatabaseInfo", DatabaseInfo.class).invoke(testObject, UnKnownDatabaseInfo.INSTANCE);
- Object databaseInfo = databaseTraceValue.getMethod("_$PINPOINT$_getTraceDatabaseInfo").invoke(testObject);
- Assert.assertSame(UnKnownDatabaseInfo.INSTANCE, databaseInfo);
- }
-
- @Ignore
@Test
public void testBeforeAddInterceptor() throws Exception {
final TestClassLoader loader = getTestClassLoader();
- final String javassistClassName = "com.navercorp.pinpoint.profiler.interceptor.bci.TestObject";
+ final String javassistClassName = "com.navercorp.pinpoint.test.javasssit.mock.TestObject";
loader.addTransformer(javassistClassName, new TransformCallback() {
@@ -225,7 +164,7 @@ public class JavassistClassTest {
InstrumentClass aClass = instrumentor.getInstrumentClass(classLoader, javassistClassName, classfileBuffer);
String methodName = "callA";
- aClass.getDeclaredMethod(methodName).addInterceptor("com.navercorp.pinpoint.profiler.interceptor.TestBeforeInterceptor");
+ aClass.getDeclaredMethod(methodName).addInterceptor("com.navercorp.pinpoint.test.javasssit.TestBeforeInterceptor");
return aClass.toBytecode();
} catch (InstrumentException e) {
@@ -243,7 +182,7 @@ public class JavassistClassTest {
callA.invoke(testObject);
Interceptor interceptor = getInterceptor(loader, 0);
assertEqualsIntField(interceptor, "call", 1);
- assertEqualsObjectField(interceptor, "className", "com.navercorp.pinpoint.profiler.interceptor.bci.TestObject");
+ assertEqualsObjectField(interceptor, "className", "com.navercorp.pinpoint.test.javasssit.mock.TestObject");
assertEqualsObjectField(interceptor, "methodName", methodName);
assertEqualsObjectField(interceptor, "args", null);
@@ -251,7 +190,7 @@ public class JavassistClassTest {
}
private Interceptor getInterceptor(final TestClassLoader loader, int index) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException {
- Interceptor interceptor = (Interceptor) loader.loadClass("com.navercorp.pinpoint.profiler.interceptor.bci.TestInterceptors").getMethod("get", int.class).invoke(null, index);
+ Interceptor interceptor = (Interceptor) loader.loadClass("com.navercorp.pinpoint.test.javasssit.TestInterceptors").getMethod("get", int.class).invoke(null, index);
return interceptor;
}
@@ -284,7 +223,7 @@ public class JavassistClassTest {
public void testAddAfterInterceptor() throws Exception {
final TestClassLoader loader = getTestClassLoader();
- final String testClassObject = "com.navercorp.pinpoint.profiler.interceptor.bci.TestObject2";
+ final String testClassObject = "com.navercorp.pinpoint.test.javasssit.mock.TestObject2";
loader.addTransformer(testClassObject, new TransformCallback() {
@@ -345,139 +284,12 @@ public class JavassistClassTest {
logger.info("Descript null:{}", nullDescriptor);
}
- @Test
- public void testAddGetter() throws Exception {
- final TestClassLoader loader = getTestClassLoader();
- final String targetClassName = "com.navercorp.pinpoint.profiler.interceptor.bci.TestObject3";
-
-
- loader.addTransformer(targetClassName, new TransformCallback() {
-
- @Override
- public byte[] doInTransform(Instrumentor instrumentor, ClassLoader classLoader, String className, Class> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws InstrumentException {
- try {
- logger.info("modify cl:{}", classLoader);
- InstrumentClass aClass = instrumentor.getInstrumentClass(classLoader, className, classfileBuffer);
-
- aClass.addGetter(StringGetter.class.getName(), "value");
- aClass.addGetter(IntGetter.class.getName(), "intValue");
- aClass.addGetter(IntArrayGetter.class.getName(), "intValues");
- aClass.addGetter(IntegerArrayGetter.class.getName(), "integerValues");
-
- return aClass.toBytecode();
- } catch (InstrumentException e) {
- throw new RuntimeException(e.getMessage(), e);
- }
- }
- });
-
-
- Object testObject = loader.loadClass(targetClassName).newInstance();
-
- Class> stringGetter = loader.loadClass(StringGetter.class.getName());
- Class> intGetter = loader.loadClass(IntGetter.class.getName());
- Class> intsGetter = loader.loadClass(IntArrayGetter.class.getName());
- Class> integersGetter = loader.loadClass(IntegerArrayGetter.class.getName());
-
- Assert.assertTrue(stringGetter.isInstance(testObject));
- Assert.assertTrue(intGetter.isInstance(testObject));
- Assert.assertTrue(intsGetter.isInstance(testObject));
- Assert.assertTrue(integersGetter.isInstance(testObject));
-
- String value = "hehe";
- int intValue = 99;
- int[] intValues = {99, 100};
- Integer[] integerValues = {99, 100};
-
- Method method = testObject.getClass().getMethod("setValue", String.class);
- method.invoke(testObject, value);
-
- Method getString = stringGetter.getMethod("_$PINPOINT$_getString");
- Assert.assertEquals(value, getString.invoke(testObject));
-
- Method setIntValue = testObject.getClass().getMethod("setIntValue", int.class);
- setIntValue.invoke(testObject, intValue);
-
- Method getInt = intGetter.getMethod("_$PINPOINT$_getInt");
- Assert.assertEquals(intValue, getInt.invoke(testObject));
-
- Method setIntValues = testObject.getClass().getMethod("setIntValues", int[].class);
- setIntValues.invoke(testObject, intValues);
-
- Method getIntValues = intsGetter.getMethod("_$PINPOINT$_getIntArray");
- Assert.assertEquals(intValues, getIntValues.invoke(testObject));
-
- Method setIntegerValues = testObject.getClass().getMethod("setIntegerValues", Integer[].class);
- // wrap due to vararg expansion
- Object[] wrappedIntegerValues = new Object[]{integerValues};
- setIntegerValues.invoke(testObject, wrappedIntegerValues);
-
- Method getIntegerValues = integersGetter.getMethod("_$PINPOINT$_getIntegerArray");
- Assert.assertEquals(integerValues, getIntegerValues.invoke(testObject));
-
- }
-
- @Test
- public void testAddSetter() throws Exception {
- final TestClassLoader loader = getTestClassLoader();
- final String targetClassName = "com.navercorp.pinpoint.profiler.interceptor.bci.TestObject4";
-
- loader.addTransformer(targetClassName, new TransformCallback() {
- @Override
- public byte[] doInTransform(Instrumentor instrumentor, ClassLoader classLoader, String className, Class> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws InstrumentException {
- try {
- logger.info("modify cl:{}", classLoader);
- InstrumentClass testClass = instrumentor.getInstrumentClass(classLoader, className, classfileBuffer);
-
- testClass.addSetter(IntSetter.class.getName(), "intValue");
- testClass.addSetter(IntArraySetter.class.getName(), "intValues");
- testClass.addSetter(IntegerArraySetter.class.getName(), "integerValues");
-
- return testClass.toBytecode();
- } catch (InstrumentException e) {
- throw new RuntimeException(e.getMessage(), e);
- }
- }
- });
-
-
- Object testObject = loader.loadClass(targetClassName).newInstance();
-
- Class> intSetter = loader.loadClass(IntSetter.class.getName());
- Class> intsSetter = loader.loadClass(IntArraySetter.class.getName());
- Class> integersSetter = loader.loadClass(IntegerArraySetter.class.getName());
-
- Assert.assertTrue(intSetter.isInstance(testObject));
- Assert.assertTrue(intsSetter.isInstance(testObject));
- Assert.assertTrue(integersSetter.isInstance(testObject));
-
- int intValue = 99;
- int[] intValues = {99, 100};
- Integer[] integerValues = {99, 100};
-
- Method setInt = intSetter.getMethod("_$PINPOINT$_setInt", int.class);
- setInt.invoke(testObject, intValue);
- Method getInt = testObject.getClass().getMethod("getIntValue");
- Assert.assertEquals(intValue, getInt.invoke(testObject));
-
- Method setInts = intsSetter.getMethod("_$PINPOINT$_setIntArray", int[].class);
- setInts.invoke(testObject, intValues);
- Method getInts = testObject.getClass().getMethod("getIntValues");
- Assert.assertEquals(intValues, getInts.invoke(testObject));
-
- Method setIntegers = integersSetter.getMethod("_$PINPOINT$_setIntegerArray", Integer[].class);
- // wrap due to vararg expansion
- Object[] wrappedIntegerValues = new Object[]{integerValues};
- setIntegers.invoke(testObject, wrappedIntegerValues);
- Method getIntegers = testObject.getClass().getMethod("getIntegerValues");
- Assert.assertEquals(integerValues, getIntegers.invoke(testObject));
- }
@Test
public void getNestedClasses() throws Exception {
JavassistClassPool pool = new JavassistClassPool(new GlobalInterceptorRegistryBinder(), null);
- String testObjectName = "com.navercorp.pinpoint.profiler.interceptor.bci.TestObjectNestedClass";
+ String testObjectName = "com.navercorp.pinpoint.test.javasssit.mock.TestObjectNestedClass";
byte[] testObjectByteCode = readByteCode(testObjectName);
InstrumentClass testObject = pool.getClass(null, null, testObjectName, testObjectByteCode);
@@ -502,7 +314,7 @@ public class JavassistClassTest {
@Test
public void hasEnclodingMethod() throws Exception {
JavassistClassPool pool = new JavassistClassPool(new GlobalInterceptorRegistryBinder(), null);
- String testObjectName = "com.navercorp.pinpoint.profiler.interceptor.bci.TestObjectNestedClass";
+ String testObjectName = "com.navercorp.pinpoint.test.javasssit.mock.TestObjectNestedClass";
byte[] testObjectByteCode = readByteCode(testObjectName);
InstrumentClass testObject = pool.getClass(null, null, testObjectName, testObjectByteCode);
diff --git a/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/TestBeforeInterceptor.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/TestBeforeInterceptor.java
new file mode 100644
index 000000000..ca1fd95dd
--- /dev/null
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/TestBeforeInterceptor.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2016 NAVER Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.navercorp.pinpoint.test.javasssit;
+
+import com.navercorp.pinpoint.bootstrap.interceptor.StaticAroundInterceptor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Arrays;
+
+/**
+ * @author emeroad
+ */
+public class TestBeforeInterceptor implements StaticAroundInterceptor {
+ static {
+ System.out.println("load TestBeforeInterceptor cl:" + TestBeforeInterceptor.class.getClassLoader());
+ }
+
+ private Logger logger = LoggerFactory.getLogger(this.getClass().getName());
+
+ public int call = 0;
+ public Object target;
+ public String className;
+ public String methodName;
+ public Object[] args;
+
+ @Override
+ public void before(Object target, String className, String methodName, String parameterDescription, Object[] args) {
+ logger.info("BEFORE target:" + target + " " + className + "." + methodName + parameterDescription + " args:" + Arrays.toString(args));
+ this.target = target;
+ this.className = className;
+ this.methodName = methodName;
+ this.args = args;
+ call++;
+
+ TestInterceptors.add(this);
+ }
+
+ @Override
+ public void after(Object target, String className, String methodName, String parameterDescription, Object[] args, Object result, Throwable throwable) {
+
+ }
+}
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/javaassist/TestBootstrapClass.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/TestBootstrapClass.java
similarity index 60%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/javaassist/TestBootstrapClass.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/TestBootstrapClass.java
index 24879b5b6..8dc2e3216 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/javaassist/TestBootstrapClass.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/TestBootstrapClass.java
@@ -14,14 +14,15 @@
* limitations under the License.
*/
-package com.navercorp.pinpoint.profiler.javaassist;
+package com.navercorp.pinpoint.test.javasssit;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
-import java.net.HttpURLConnection;
+import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
+import com.navercorp.pinpoint.test.util.BytecodeUtils;
import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.CtClass;
@@ -31,14 +32,14 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.navercorp.pinpoint.test.util.BytecodeUtils;
/**
* @author emeroad
*/
+@Deprecated
public class TestBootstrapClass {
- private static final String TEST_CLASS_NAME = "com.navercorp.pinpoint.profiler.javaassist.DynamicTest";
+ private static final String TEST_CLASS_NAME = "com.navercorp.pinpoint.profiler.javaassist.DynamicCreateTest";
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@@ -54,44 +55,35 @@ public class TestBootstrapClass {
CtClass ctClass = cp.makeClass(TEST_CLASS_NAME);
byte[] bytes = ctClass.toBytecode();
- logger.info(classLoader.getClass().getName());
+ logger.debug(classLoader.getClass().getName());
Class> aClass = BytecodeUtils.defineClass(classLoader, TEST_CLASS_NAME, bytes);
- logger.info("{}", aClass.getName());
+ logger.debug("{}", aClass.getName());
}
@Test
public void testJdkClassClassLoader() throws IOException {
- URL url = new URL("http://test");
-
- HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
- logger.info(urlConnection.toString());
- logger.info("{}", urlConnection.getClass().getClassLoader());
ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
ClassLoader parent = systemClassLoader.getParent();
- logger.info("parent:{}", parent);
- logger.info("pparent:{}", parent.getParent());
-
- logger.info("{}", String.class.getClassLoader());
- logger.info("{}", TestBootstrapClass.class.getClassLoader());
-
-
- urlConnection.disconnect();
+ logger.debug("parent:{}", parent);
+ logger.debug("pparent:{}", parent.getParent());
+ logger.debug("{}", String.class.getClassLoader());
+ logger.debug("{}", TestBootstrapClass.class.getClassLoader());
}
@Test
public void testReflection() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
- java.lang.ClassLoader contextClassLoader = java.lang.Thread.currentThread().getContextClassLoader();
- java.lang.Class> interceptorRegistry = contextClassLoader.loadClass("com.navercorp.pinpoint.bootstrap.interceptor.registry.GlobalInterceptorRegistry");
- java.lang.reflect.Method getInterceptorMethod = interceptorRegistry.getMethod("getInterceptor", new java.lang.Class[]{int.class});
- java.lang.Object interceptor = getInterceptorMethod.invoke(interceptorRegistry, Integer.valueOf(1));
+ ClassLoader contextClassLoader = java.lang.Thread.currentThread().getContextClassLoader();
+ Class> interceptorRegistry = contextClassLoader.loadClass("com.navercorp.pinpoint.bootstrap.interceptor.registry.GlobalInterceptorRegistry");
+ Method getInterceptorMethod = interceptorRegistry.getMethod("getInterceptor", int.class);
+ Object interceptor = getInterceptorMethod.invoke(interceptorRegistry, Integer.valueOf(1));
- java.lang.reflect.Method beforeMethod = interceptor.getClass().getMethod("before", java.lang.Object.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object[].class);
+ Method beforeMethod = interceptor.getClass().getMethod("before", java.lang.Object.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object[].class);
beforeMethod.invoke(interceptor, null, null, null, null, null);
}
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/javaassist/TestClass.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/TestClass.java
similarity index 96%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/javaassist/TestClass.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/TestClass.java
index 29fc6b040..b97f9788e 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/javaassist/TestClass.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/TestClass.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.navercorp.pinpoint.profiler.javaassist;
+package com.navercorp.pinpoint.test.javasssit;
import java.util.List;
diff --git a/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/TestInterceptors.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/TestInterceptors.java
new file mode 100644
index 000000000..a094c8359
--- /dev/null
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/TestInterceptors.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2016 NAVER Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package com.navercorp.pinpoint.test.javasssit;
+
+import com.navercorp.pinpoint.bootstrap.interceptor.Interceptor;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author Jongho Moon
+ *
+ */
+public class TestInterceptors {
+
+ private static final List interceptors = Collections.synchronizedList(new ArrayList());
+
+ public static void clear() {
+ interceptors.clear();
+ }
+
+ public static void add(Interceptor interceptor) {
+ interceptors.add(interceptor);
+ }
+
+ public static Interceptor get(int index) {
+ return interceptors.get(index);
+ }
+}
diff --git a/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/AccessorInjectionTest.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/AccessorInjectionTest.java
new file mode 100644
index 000000000..e52df2761
--- /dev/null
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/AccessorInjectionTest.java
@@ -0,0 +1,263 @@
+/*
+ * Copyright 2016 NAVER Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.navercorp.pinpoint.test.javasssit.accessor;
+
+import com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig;
+import com.navercorp.pinpoint.bootstrap.context.DatabaseInfo;
+import com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass;
+import com.navercorp.pinpoint.bootstrap.instrument.InstrumentException;
+import com.navercorp.pinpoint.bootstrap.instrument.Instrumentor;
+import com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback;
+import com.navercorp.pinpoint.bootstrap.logging.PLoggerFactory;
+import com.navercorp.pinpoint.bootstrap.plugin.jdbc.UnKnownDatabaseInfo;
+import com.navercorp.pinpoint.common.trace.ServiceType;
+import com.navercorp.pinpoint.profiler.DefaultAgent;
+import com.navercorp.pinpoint.profiler.logging.Slf4jLoggerBinder;
+import com.navercorp.pinpoint.test.MockAgent;
+import com.navercorp.pinpoint.test.classloader.TestClassLoader;
+import com.navercorp.pinpoint.test.javasssit.JavassistClassTest;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.reflect.Method;
+import java.security.ProtectionDomain;
+
+/**
+ * @author Woonduk Kang(emeroad)
+ */
+@Deprecated
+public class AccessorInjectionTest {
+
+ private Logger logger = LoggerFactory.getLogger(JavassistClassTest.class.getName());
+
+ private TestClassLoader getTestClassLoader() {
+ PLoggerFactory.initialize(new Slf4jLoggerBinder());
+
+ DefaultProfilerConfig profilerConfig = new DefaultProfilerConfig();
+ profilerConfig.setApplicationServerType(ServiceType.TEST_STAND_ALONE.getName());
+ DefaultAgent agent = MockAgent.of(profilerConfig);
+
+ TestClassLoader testClassLoader = new TestClassLoader(agent);
+ testClassLoader.initialize();
+ return testClassLoader;
+ }
+
+ @Test
+ public void addTraceValue() throws Exception {
+ final TestClassLoader loader = getTestClassLoader();
+ final String javassistClassName = "com.navercorp.pinpoint.test.javasssit.mock.TestObject";
+
+ loader.addTransformer(javassistClassName, new TransformCallback() {
+
+ @Override
+ public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, String className, Class> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws InstrumentException {
+ try {
+ logger.info("modify cl:{}", loader);
+
+ InstrumentClass aClass = instrumentor.getInstrumentClass(loader, javassistClassName, classfileBuffer);
+
+ aClass.addField(ObjectTraceValue.class.getName());
+ aClass.addField(IntTraceValue.class.getName());
+ aClass.addField(IntArrayTraceValue.class.getName());
+ aClass.addField(IntegerArrayTraceValue.class.getName());
+ aClass.addField(DatabaseInfoTraceValue.class.getName());
+ aClass.addField(BindValueTraceValue.class.getName());
+
+ String methodName = "callA";
+ aClass.getDeclaredMethod(methodName).addInterceptor("com.navercorp.pinpoint.test.javasssit.TestBeforeInterceptor");
+ return aClass.toBytecode();
+ } catch (InstrumentException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ }
+ });
+
+ Class> testObjectClazz = loader.loadClass(javassistClassName);
+ final String methodName = "callA";
+ logger.info("class:{}", testObjectClazz.toString());
+ final Object testObject = testObjectClazz.newInstance();
+ Method callA = testObjectClazz.getMethod(methodName);
+ callA.invoke(testObject);
+
+ Class> objectTraceValue = loader.loadClass(ObjectTraceValue.class.getName());
+ Assert.assertTrue("ObjectTraceValue implements fail", objectTraceValue.isInstance(testObject));
+ objectTraceValue.getMethod("_$PINPOINT$_setTraceObject", Object.class).invoke(testObject, "a");
+ Object get = objectTraceValue.getMethod("_$PINPOINT$_getTraceObject").invoke(testObject);
+ Assert.assertEquals("a", get);
+
+ Class> intTraceValue = loader.loadClass(IntTraceValue.class.getName());
+ Assert.assertTrue("IntTraceValue implements fail", intTraceValue.isInstance(testObject));
+ intTraceValue.getMethod("_$PINPOINT$_setTraceInt", int.class).invoke(testObject, 1);
+ int a = (Integer) intTraceValue.getMethod("_$PINPOINT$_getTraceInt").invoke(testObject);
+ Assert.assertEquals(1, a);
+
+ Class> intArrayTraceValue = loader.loadClass(IntArrayTraceValue.class.getName());
+ Assert.assertTrue("IntArrayTraceValue implements fail", intArrayTraceValue.isInstance(testObject));
+ int[] expectedInts = {1, 2, 3};
+ intArrayTraceValue.getMethod("_$PINPOINT$_setTraceIntArray", int[].class).invoke(testObject, expectedInts);
+ int[] ints = (int[]) intArrayTraceValue.getMethod("_$PINPOINT$_getTraceIntArray").invoke(testObject);
+ Assert.assertEquals(expectedInts, ints);
+
+ Class> integerArrayTraceValue = loader.loadClass(IntegerArrayTraceValue.class.getName());
+ Assert.assertTrue("IntegerArrayTraceValue implements fail", integerArrayTraceValue.isInstance(testObject));
+ Integer[] expectedIntegers = {1, 2};
+ // wrap due to vararg expansion
+ Object[] wrappedExpectedIntegers = new Object[]{expectedIntegers};
+ integerArrayTraceValue.getMethod("_$PINPOINT$_setTraceIntegerArray", Integer[].class).invoke(testObject, wrappedExpectedIntegers);
+ Integer[] integers = (Integer[]) integerArrayTraceValue.getMethod("_$PINPOINT$_getTraceIntegerArray").invoke(testObject);
+ Assert.assertArrayEquals(expectedIntegers, integers);
+
+ Class> databaseTraceValue = loader.loadClass(DatabaseInfoTraceValue.class.getName());
+ Assert.assertTrue("DatabaseInfoTraceValue implements fail", databaseTraceValue.isInstance(testObject));
+ databaseTraceValue.getMethod("_$PINPOINT$_setTraceDatabaseInfo", DatabaseInfo.class).invoke(testObject, UnKnownDatabaseInfo.INSTANCE);
+ Object databaseInfo = databaseTraceValue.getMethod("_$PINPOINT$_getTraceDatabaseInfo").invoke(testObject);
+ Assert.assertSame(UnKnownDatabaseInfo.INSTANCE, databaseInfo);
+ }
+
+ @Test
+ public void testAddGetter() throws Exception {
+ final TestClassLoader loader = getTestClassLoader();
+ final String targetClassName = "com.navercorp.pinpoint.test.javasssit.mock.TestObject3";
+
+
+ loader.addTransformer(targetClassName, new TransformCallback() {
+
+ @Override
+ public byte[] doInTransform(Instrumentor instrumentor, ClassLoader classLoader, String className, Class> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws InstrumentException {
+ try {
+ logger.info("modify cl:{}", classLoader);
+ InstrumentClass aClass = instrumentor.getInstrumentClass(classLoader, className, classfileBuffer);
+
+ aClass.addGetter(StringGetter.class.getName(), "value");
+ aClass.addGetter(IntGetter.class.getName(), "intValue");
+ aClass.addGetter(IntArrayGetter.class.getName(), "intValues");
+ aClass.addGetter(IntegerArrayGetter.class.getName(), "integerValues");
+
+ return aClass.toBytecode();
+ } catch (InstrumentException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ }
+ });
+
+
+ Object testObject = loader.loadClass(targetClassName).newInstance();
+
+ Class> stringGetter = loader.loadClass(StringGetter.class.getName());
+ Class> intGetter = loader.loadClass(IntGetter.class.getName());
+ Class> intsGetter = loader.loadClass(IntArrayGetter.class.getName());
+ Class> integersGetter = loader.loadClass(IntegerArrayGetter.class.getName());
+
+ Assert.assertTrue(stringGetter.isInstance(testObject));
+ Assert.assertTrue(intGetter.isInstance(testObject));
+ Assert.assertTrue(intsGetter.isInstance(testObject));
+ Assert.assertTrue(integersGetter.isInstance(testObject));
+
+ String value = "hehe";
+ int intValue = 99;
+ int[] intValues = {99, 100};
+ Integer[] integerValues = {99, 100};
+
+ Method method = testObject.getClass().getMethod("setValue", String.class);
+ method.invoke(testObject, value);
+
+ Method getString = stringGetter.getMethod("_$PINPOINT$_getString");
+ Assert.assertEquals(value, getString.invoke(testObject));
+
+ Method setIntValue = testObject.getClass().getMethod("setIntValue", int.class);
+ setIntValue.invoke(testObject, intValue);
+
+ Method getInt = intGetter.getMethod("_$PINPOINT$_getInt");
+ Assert.assertEquals(intValue, getInt.invoke(testObject));
+
+ Method setIntValues = testObject.getClass().getMethod("setIntValues", int[].class);
+ setIntValues.invoke(testObject, intValues);
+
+ Method getIntValues = intsGetter.getMethod("_$PINPOINT$_getIntArray");
+ Assert.assertEquals(intValues, getIntValues.invoke(testObject));
+
+ Method setIntegerValues = testObject.getClass().getMethod("setIntegerValues", Integer[].class);
+ // wrap due to vararg expansion
+ Object[] wrappedIntegerValues = new Object[]{integerValues};
+ setIntegerValues.invoke(testObject, wrappedIntegerValues);
+
+ Method getIntegerValues = integersGetter.getMethod("_$PINPOINT$_getIntegerArray");
+ Assert.assertEquals(integerValues, getIntegerValues.invoke(testObject));
+
+ }
+
+ @Test
+ public void testAddSetter() throws Exception {
+ final TestClassLoader loader = getTestClassLoader();
+ final String targetClassName = "com.navercorp.pinpoint.test.javasssit.mock.TestObject4";
+
+ loader.addTransformer(targetClassName, new TransformCallback() {
+ @Override
+ public byte[] doInTransform(Instrumentor instrumentor, ClassLoader classLoader, String className, Class> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws InstrumentException {
+ try {
+ logger.info("modify cl:{}", classLoader);
+ InstrumentClass testClass = instrumentor.getInstrumentClass(classLoader, className, classfileBuffer);
+
+ testClass.addSetter(IntSetter.class.getName(), "intValue");
+ testClass.addSetter(IntArraySetter.class.getName(), "intValues");
+ testClass.addSetter(IntegerArraySetter.class.getName(), "integerValues");
+
+ return testClass.toBytecode();
+ } catch (InstrumentException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ }
+ });
+
+
+ Object testObject = loader.loadClass(targetClassName).newInstance();
+
+ Class> intSetter = loader.loadClass(IntSetter.class.getName());
+ Class> intsSetter = loader.loadClass(IntArraySetter.class.getName());
+ Class> integersSetter = loader.loadClass(IntegerArraySetter.class.getName());
+
+ Assert.assertTrue(intSetter.isInstance(testObject));
+ Assert.assertTrue(intsSetter.isInstance(testObject));
+ Assert.assertTrue(integersSetter.isInstance(testObject));
+
+ int intValue = 99;
+ int[] intValues = {99, 100};
+ Integer[] integerValues = {99, 100};
+
+ Method setInt = intSetter.getMethod("_$PINPOINT$_setInt", int.class);
+ setInt.invoke(testObject, intValue);
+ Method getInt = testObject.getClass().getMethod("getIntValue");
+ Assert.assertEquals(intValue, getInt.invoke(testObject));
+
+ Method setInts = intsSetter.getMethod("_$PINPOINT$_setIntArray", int[].class);
+ setInts.invoke(testObject, intValues);
+ Method getInts = testObject.getClass().getMethod("getIntValues");
+ Assert.assertEquals(intValues, getInts.invoke(testObject));
+
+ Method setIntegers = integersSetter.getMethod("_$PINPOINT$_setIntegerArray", Integer[].class);
+ // wrap due to vararg expansion
+ Object[] wrappedIntegerValues = new Object[]{integerValues};
+ setIntegers.invoke(testObject, wrappedIntegerValues);
+ Method getIntegers = testObject.getClass().getMethod("getIntegerValues");
+ Assert.assertEquals(integerValues, getIntegers.invoke(testObject));
+ }
+
+}
diff --git a/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/BindValueTraceValue.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/BindValueTraceValue.java
new file mode 100644
index 000000000..3fdc88ded
--- /dev/null
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/BindValueTraceValue.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2016 NAVER Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.navercorp.pinpoint.test.javasssit.accessor;
+
+
+import java.util.Map;
+
+/**
+ * @author emeroad
+ */
+public interface BindValueTraceValue {
+ void _$PINPOINT$_setTraceBindValue(Map value);
+ Map _$PINPOINT$_getTraceBindValue();
+}
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/DatabaseInfoTraceValue.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/DatabaseInfoTraceValue.java
similarity index 90%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/DatabaseInfoTraceValue.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/DatabaseInfoTraceValue.java
index 63385fd81..ed1238edd 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/DatabaseInfoTraceValue.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/DatabaseInfoTraceValue.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 NAVER Corp.
+ * Copyright 2016 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -12,9 +12,10 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
+ *
*/
-package com.navercorp.pinpoint.profiler.interceptor.bci;
+package com.navercorp.pinpoint.test.javasssit.accessor;
import com.navercorp.pinpoint.bootstrap.context.DatabaseInfo;
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntArrayGetter.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntArrayGetter.java
similarity index 88%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntArrayGetter.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntArrayGetter.java
index b02e42053..e5da5349b 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntArrayGetter.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntArrayGetter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Naver Corp.
+ * Copyright 2016 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -12,9 +12,10 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
+ *
*/
-package com.navercorp.pinpoint.profiler.interceptor.bci;
+package com.navercorp.pinpoint.test.javasssit.accessor;
/**
* @author HyunGil Jeong
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntArraySetter.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntArraySetter.java
similarity index 88%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntArraySetter.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntArraySetter.java
index a8ab44f32..696f5ba75 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntArraySetter.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntArraySetter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Naver Corp.
+ * Copyright 2016 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -12,9 +12,10 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
+ *
*/
-package com.navercorp.pinpoint.profiler.interceptor.bci;
+package com.navercorp.pinpoint.test.javasssit.accessor;
/**
* @author HyunGil Jeong
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntArrayTraceValue.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntArrayTraceValue.java
similarity index 89%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntArrayTraceValue.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntArrayTraceValue.java
index 0f58ed20e..97529bd89 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntArrayTraceValue.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntArrayTraceValue.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Naver Corp.
+ * Copyright 2016 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -12,9 +12,10 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
+ *
*/
-package com.navercorp.pinpoint.profiler.interceptor.bci;
+package com.navercorp.pinpoint.test.javasssit.accessor;
/**
* @author HyunGil Jeong
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntGetter.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntGetter.java
similarity index 86%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntGetter.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntGetter.java
index 98f6fe2a2..4e967151b 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntGetter.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntGetter.java
@@ -1,18 +1,20 @@
-/**
- * Copyright 2014 NAVER Corp.
+/*
+ * Copyright 2016 NAVER Corp.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
+ *
*/
-package com.navercorp.pinpoint.profiler.interceptor.bci;
+package com.navercorp.pinpoint.test.javasssit.accessor;
/**
* @author Jongho Moon
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntSetter.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntSetter.java
similarity index 88%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntSetter.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntSetter.java
index 96cc1ea10..4891b1c69 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntSetter.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntSetter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Naver Corp.
+ * Copyright 2016 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -12,9 +12,10 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
+ *
*/
-package com.navercorp.pinpoint.profiler.interceptor.bci;
+package com.navercorp.pinpoint.test.javasssit.accessor;
/**
* @author HyunGil Jeong
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntTraceValue.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntTraceValue.java
similarity index 88%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntTraceValue.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntTraceValue.java
index a00f77024..66f7685c7 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntTraceValue.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntTraceValue.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 NAVER Corp.
+ * Copyright 2016 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -12,9 +12,10 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
+ *
*/
-package com.navercorp.pinpoint.profiler.interceptor.bci;
+package com.navercorp.pinpoint.test.javasssit.accessor;
/**
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntegerArrayGetter.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntegerArrayGetter.java
similarity index 88%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntegerArrayGetter.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntegerArrayGetter.java
index 5984febcf..80a0ab3a6 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntegerArrayGetter.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntegerArrayGetter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Naver Corp.
+ * Copyright 2016 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -12,9 +12,10 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
+ *
*/
-package com.navercorp.pinpoint.profiler.interceptor.bci;
+package com.navercorp.pinpoint.test.javasssit.accessor;
/**
* @author HyunGil Jeong
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntegerArraySetter.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntegerArraySetter.java
similarity index 88%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntegerArraySetter.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntegerArraySetter.java
index b49308fcd..0e2af3b72 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntegerArraySetter.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntegerArraySetter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Naver Corp.
+ * Copyright 2016 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -12,9 +12,10 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
+ *
*/
-package com.navercorp.pinpoint.profiler.interceptor.bci;
+package com.navercorp.pinpoint.test.javasssit.accessor;
/**
* @author HyunGil Jeong
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntegerArrayTraceValue.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntegerArrayTraceValue.java
similarity index 89%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntegerArrayTraceValue.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntegerArrayTraceValue.java
index 0b69a32c4..fbba44947 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/IntegerArrayTraceValue.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/IntegerArrayTraceValue.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Naver Corp.
+ * Copyright 2016 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -12,9 +12,10 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
+ *
*/
-package com.navercorp.pinpoint.profiler.interceptor.bci;
+package com.navercorp.pinpoint.test.javasssit.accessor;
/**
* @author HyunGil Jeong
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/ObjectTraceValue.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/ObjectTraceValue.java
similarity index 89%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/ObjectTraceValue.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/ObjectTraceValue.java
index 35c82ae20..12cce89c0 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/ObjectTraceValue.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/ObjectTraceValue.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 NAVER Corp.
+ * Copyright 2016 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -12,9 +12,10 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
+ *
*/
-package com.navercorp.pinpoint.profiler.interceptor.bci;
+package com.navercorp.pinpoint.test.javasssit.accessor;
/**
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/StringGetter.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/StringGetter.java
similarity index 86%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/StringGetter.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/StringGetter.java
index cf1d62e58..a31b83506 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/StringGetter.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/accessor/StringGetter.java
@@ -1,18 +1,20 @@
-/**
- * Copyright 2014 NAVER Corp.
+/*
+ * Copyright 2016 NAVER Corp.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
+ *
*/
-package com.navercorp.pinpoint.profiler.interceptor.bci;
+package com.navercorp.pinpoint.test.javasssit.accessor;
/**
* @author Jongho Moon
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/ClassHierarchyTestMock.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/mock/ClassHierarchyTestMock.java
similarity index 93%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/ClassHierarchyTestMock.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/mock/ClassHierarchyTestMock.java
index 02b087322..de5f360f9 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/ClassHierarchyTestMock.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/mock/ClassHierarchyTestMock.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.navercorp.pinpoint.profiler.interceptor.bci;
+package com.navercorp.pinpoint.test.javasssit.mock;
import java.util.HashMap;
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/TestObject.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/mock/TestObject.java
similarity index 96%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/TestObject.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/mock/TestObject.java
index 494c7e585..4b15d7d69 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/TestObject.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/mock/TestObject.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.navercorp.pinpoint.profiler.interceptor.bci;
+package com.navercorp.pinpoint.test.javasssit.mock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/TestObject2.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/mock/TestObject2.java
similarity index 94%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/TestObject2.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/mock/TestObject2.java
index 0167f8a6c..e053cde13 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/TestObject2.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/mock/TestObject2.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.navercorp.pinpoint.profiler.interceptor.bci;
+package com.navercorp.pinpoint.test.javasssit.mock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/TestObject3.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/mock/TestObject3.java
similarity index 94%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/TestObject3.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/mock/TestObject3.java
index fb6549fe6..cc724da42 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/TestObject3.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/mock/TestObject3.java
@@ -1,18 +1,18 @@
-/**
+/*
* Copyright 2014 NAVER Corp.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.navercorp.pinpoint.profiler.interceptor.bci;
+package com.navercorp.pinpoint.test.javasssit.mock;
/**
* @author Jongho Moon
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/TestObject4.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/mock/TestObject4.java
similarity index 94%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/TestObject4.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/mock/TestObject4.java
index ffd244e45..d401defac 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/TestObject4.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/mock/TestObject4.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.navercorp.pinpoint.profiler.interceptor.bci;
+package com.navercorp.pinpoint.test.javasssit.mock;
/**
* @author HyunGil Jeong
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/TestObjectNestedClass.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/mock/TestObjectNestedClass.java
similarity index 96%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/TestObjectNestedClass.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/mock/TestObjectNestedClass.java
index f7317fdf2..a3f355ff1 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/TestObjectNestedClass.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/javasssit/mock/TestObjectNestedClass.java
@@ -1,18 +1,18 @@
-/**
+/*
* Copyright 2014 NAVER Corp.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.navercorp.pinpoint.profiler.interceptor.bci;
+package com.navercorp.pinpoint.test.javasssit.mock;
import java.util.concurrent.Callable;
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/monitor/AgentStatMonitorTest.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/monitor/AgentStatMonitorTest.java
similarity index 94%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/monitor/AgentStatMonitorTest.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/monitor/AgentStatMonitorTest.java
index 854cd9e0b..def4d44d3 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/monitor/AgentStatMonitorTest.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/monitor/AgentStatMonitorTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 NAVER Corp.
+ * Copyright 2016 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -12,13 +12,13 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
+ *
*/
-package com.navercorp.pinpoint.profiler.monitor;
-
-import static org.junit.Assert.*;
+package com.navercorp.pinpoint.test.monitor;
import com.navercorp.pinpoint.bootstrap.context.TraceContext;
+import com.navercorp.pinpoint.profiler.monitor.AgentStatMonitor;
import com.navercorp.pinpoint.profiler.monitor.codahale.AgentStatCollectorFactory;
import com.navercorp.pinpoint.profiler.sender.DataSender;
import com.navercorp.pinpoint.test.ListenableDataSender;
@@ -26,13 +26,14 @@ import com.navercorp.pinpoint.test.MockTraceContextFactory;
import com.navercorp.pinpoint.test.TBaseRecorder;
import com.navercorp.pinpoint.test.TBaseRecorderAdaptor;
import com.navercorp.pinpoint.thrift.dto.TAgentStatBatch;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.MockitoAnnotations;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.junit.Assert.assertTrue;
+
/**
* @author hyungil.jeong
*/
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/plugin/DefaultClassEditorBuilderTest.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/plugin/DefaultClassEditorBuilderTest.java
similarity index 96%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/plugin/DefaultClassEditorBuilderTest.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/plugin/DefaultClassEditorBuilderTest.java
index 745c01868..178e1a08c 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/plugin/DefaultClassEditorBuilderTest.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/plugin/DefaultClassEditorBuilderTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 NAVER Corp.
+ * Copyright 2016 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -12,14 +12,10 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
+ *
*/
-package com.navercorp.pinpoint.profiler.plugin;
-
-import static com.navercorp.pinpoint.common.util.VarArgs.va;
-import static org.mockito.Mockito.*;
-
-import org.junit.Test;
+package com.navercorp.pinpoint.test.plugin;
import com.navercorp.pinpoint.bootstrap.context.MethodDescriptor;
import com.navercorp.pinpoint.bootstrap.context.TraceContext;
@@ -27,8 +23,13 @@ import com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass;
import com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod;
import com.navercorp.pinpoint.profiler.DefaultAgent;
import com.navercorp.pinpoint.profiler.instrument.JavassistClassPool;
+import com.navercorp.pinpoint.profiler.plugin.DefaultProfilerPluginContext;
import com.navercorp.pinpoint.profiler.util.TypeUtils;
import com.navercorp.pinpoint.test.TestProfilerPluginClassLoader;
+import org.junit.Test;
+
+import static com.navercorp.pinpoint.common.util.VarArgs.va;
+import static org.mockito.Mockito.*;
public class DefaultClassEditorBuilderTest {
public static final String SCOPE_NAME = "test";
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/plugin/TestInterceptor.java b/profiler-test/src/test/java/com/navercorp/pinpoint/test/plugin/TestInterceptor.java
similarity index 93%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/plugin/TestInterceptor.java
rename to profiler-test/src/test/java/com/navercorp/pinpoint/test/plugin/TestInterceptor.java
index e2a2d1fb8..44e34ef55 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/plugin/TestInterceptor.java
+++ b/profiler-test/src/test/java/com/navercorp/pinpoint/test/plugin/TestInterceptor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 NAVER Corp.
+ * Copyright 2016 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -12,9 +12,10 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
+ *
*/
-package com.navercorp.pinpoint.profiler.plugin;
+package com.navercorp.pinpoint.test.plugin;
import com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor;
import com.navercorp.pinpoint.bootstrap.interceptor.annotation.Scope;
diff --git a/profiler/src/test/resources/log4j.xml b/profiler-test/src/test/resources/log4j.xml
similarity index 100%
rename from profiler/src/test/resources/log4j.xml
rename to profiler-test/src/test/resources/log4j.xml
diff --git a/profiler/pom.xml b/profiler/pom.xml
index 254a0aec8..edfcae595 100644
--- a/profiler/pom.xml
+++ b/profiler/pom.xml
@@ -26,17 +26,6 @@
-
- com.navercorp.pinpoint
- pinpoint-commons-server
- provided
-
-
- com.navercorp.pinpoint
- pinpoint-commons-hbase
-
-
-
com.navercorp.pinpoint
pinpoint-thrift
@@ -95,12 +84,6 @@
test
-
- io.netty
- netty-all
- provided
-
-
@@ -180,7 +163,7 @@
junit
junit
- compile
+ test
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/DefaultServerMetaDataHolderTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/DefaultServerMetaDataHolderTest.java
index bced0b1ee..533e56af4 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/DefaultServerMetaDataHolderTest.java
+++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/DefaultServerMetaDataHolderTest.java
@@ -35,7 +35,6 @@ import org.junit.Test;
import com.navercorp.pinpoint.bootstrap.context.ServerMetaData;
import com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder;
-import com.navercorp.pinpoint.test.TestableServerMetaDataListener;
/**
* @author hyungil.jeong
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/DefaultTraceContextTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/DefaultTraceContextTest.java
index 580ba8b96..165bcc640 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/DefaultTraceContextTest.java
+++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/DefaultTraceContextTest.java
@@ -22,14 +22,11 @@ import com.navercorp.pinpoint.bootstrap.sampler.Sampler;
import com.navercorp.pinpoint.common.util.TransactionId;
import com.navercorp.pinpoint.common.util.TransactionIdUtils;
import com.navercorp.pinpoint.profiler.AgentInformation;
-import com.navercorp.pinpoint.profiler.context.DefaultTraceContext;
-import com.navercorp.pinpoint.profiler.context.DefaultTraceId;
import com.navercorp.pinpoint.profiler.context.TransactionCounter.SamplingType;
import com.navercorp.pinpoint.profiler.context.storage.LogStorageFactory;
import com.navercorp.pinpoint.profiler.metadata.LRUCache;
import com.navercorp.pinpoint.profiler.sampler.SamplingRateSampler;
import com.navercorp.pinpoint.profiler.util.RuntimeMXBeanUtils;
-import com.navercorp.pinpoint.test.TestAgentInformation;
import org.junit.Assert;
import org.junit.Test;
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/DefaultTraceTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/DefaultTraceTest.java
index a3de8c5bb..6401c9de8 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/DefaultTraceTest.java
+++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/DefaultTraceTest.java
@@ -16,12 +16,9 @@
package com.navercorp.pinpoint.profiler.context;
-import com.navercorp.pinpoint.profiler.context.DefaultTrace;
-import com.navercorp.pinpoint.profiler.context.DefaultTraceContext;
import com.navercorp.pinpoint.profiler.context.storage.SpanStorage;
import com.navercorp.pinpoint.profiler.logging.Slf4jLoggerBinderInitializer;
import com.navercorp.pinpoint.profiler.sender.LoggingDataSender;
-import com.navercorp.pinpoint.test.TestAgentInformation;
import org.junit.*;
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/MockTraceContextFactory.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/MockTraceContextFactory.java
new file mode 100644
index 000000000..85d270aa6
--- /dev/null
+++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/MockTraceContextFactory.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2016 NAVER Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.navercorp.pinpoint.profiler.context;
+
+import com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig;
+import com.navercorp.pinpoint.bootstrap.config.ProfilerConfig;
+import com.navercorp.pinpoint.bootstrap.context.TraceContext;
+import com.navercorp.pinpoint.profiler.sender.EnhancedDataSender;
+import com.navercorp.pinpoint.profiler.sender.LoggingDataSender;
+
+/**
+ * @author emeroad
+ */
+public class MockTraceContextFactory {
+
+ private EnhancedDataSender priorityDataSender = new LoggingDataSender();
+
+ public void setPriorityDataSender(EnhancedDataSender priorityDataSender) {
+ if (priorityDataSender == null) {
+ throw new NullPointerException("priorityDataSender must not be null");
+ }
+ this.priorityDataSender = priorityDataSender;
+ }
+
+ public TraceContext create() {
+ DefaultTraceContext traceContext = new DefaultTraceContext(new TestAgentInformation()) ;
+ ProfilerConfig profilerConfig = new DefaultProfilerConfig();
+ traceContext.setProfilerConfig(profilerConfig);
+
+
+ traceContext.setPriorityDataSender(priorityDataSender);
+
+ return traceContext;
+ }
+}
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/TestAgentInformation.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/TestAgentInformation.java
new file mode 100644
index 000000000..aaf7f8565
--- /dev/null
+++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/TestAgentInformation.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2016 NAVER Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.navercorp.pinpoint.profiler.context;
+
+import com.navercorp.pinpoint.common.Version;
+import com.navercorp.pinpoint.common.trace.ServiceType;
+import com.navercorp.pinpoint.common.util.JvmUtils;
+import com.navercorp.pinpoint.common.util.SystemPropertyKey;
+import com.navercorp.pinpoint.profiler.AgentInformation;
+
+/**
+ * TODO duplicate com.navercorp.pinpoint.test.TestAgentInformation
+ * @author HyunGil Jeong
+ */
+public class TestAgentInformation extends AgentInformation {
+
+ private static final String AGENT_ID = "test-agent";
+ private static final String APPLICATION_NAME = "TEST_APPLICATION";
+ private static final int PID = 10;
+ private static final String MACHINE_NAME = "test-machine";
+ private static final String HOST_IP = "127.0.0.1";
+ private static final ServiceType SERVICE_TYPE = ServiceType.TEST_STAND_ALONE;
+ private static final String JVM_VERSION = JvmUtils.getSystemProperty(SystemPropertyKey.JAVA_VERSION);
+ private static final String AGENT_VERSION = Version.VERSION;
+
+ public TestAgentInformation() {
+ super(AGENT_ID, APPLICATION_NAME, System.currentTimeMillis(), PID, MACHINE_NAME, HOST_IP, SERVICE_TYPE, JVM_VERSION, AGENT_VERSION);
+ }
+}
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/TestClass.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/TestClass.java
new file mode 100644
index 000000000..bdca4115b
--- /dev/null
+++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/TestClass.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2016 NAVER Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.navercorp.pinpoint.profiler.context;
+
+import org.junit.Test;
+
+/**
+ * @author Woonduk Kang(emeroad)
+ */
+public class TestClass {
+ private int a;
+
+ @Override
+ public String toString() {
+ return "TestClass{" +
+ "a=" + a +
+ '}';
+ }
+}
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/TestableServerMetaDataListener.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/TestableServerMetaDataListener.java
new file mode 100644
index 000000000..ae4793af8
--- /dev/null
+++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/TestableServerMetaDataListener.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2016 NAVER Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.navercorp.pinpoint.profiler.context;
+
+import com.navercorp.pinpoint.bootstrap.context.ServerMetaData;
+import com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder.ServerMetaDataListener;
+
+/**
+ * @author HyunGil Jeong
+ */
+public class TestableServerMetaDataListener implements ServerMetaDataListener {
+
+ private volatile ServerMetaData serverMetaData;
+
+ @Override
+ public void publishServerMetaData(ServerMetaData serverMetaData) {
+ this.serverMetaData = serverMetaData;
+ }
+
+ public ServerMetaData getServerMetaData() {
+ return this.serverMetaData;
+ }
+
+}
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/TraceTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/TraceTest.java
index dc137426a..ecb451d48 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/TraceTest.java
+++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/TraceTest.java
@@ -23,7 +23,6 @@ import com.navercorp.pinpoint.profiler.sender.LoggingDataSender;
import com.navercorp.pinpoint.rpc.FutureListener;
import com.navercorp.pinpoint.rpc.ResponseMessage;
import com.navercorp.pinpoint.rpc.client.PinpointClientReconnectEventListener;
-import com.navercorp.pinpoint.test.TestAgentInformation;
import org.apache.thrift.TBase;
import org.junit.Test;
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/active/ActiveTraceRepositoryTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/active/ActiveTraceRepositoryTest.java
index 32053c733..959fdca6b 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/active/ActiveTraceRepositoryTest.java
+++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/active/ActiveTraceRepositoryTest.java
@@ -26,6 +26,7 @@ import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executors;
+import com.navercorp.pinpoint.profiler.context.TestAgentInformation;
import org.junit.Before;
import org.junit.Test;
@@ -44,7 +45,6 @@ import com.navercorp.pinpoint.profiler.context.storage.LogStorageFactory;
import com.navercorp.pinpoint.profiler.metadata.LRUCache;
import com.navercorp.pinpoint.profiler.sampler.SamplingRateSampler;
import com.navercorp.pinpoint.profiler.util.RuntimeMXBeanUtils;
-import com.navercorp.pinpoint.test.TestAgentInformation;
/**
* @author HyunGil Jeong
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/instrument/ASMBytecodeDisassemblerTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/instrument/ASMBytecodeDisassemblerTest.java
index 2705c6a4f..31a3f2295 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/instrument/ASMBytecodeDisassemblerTest.java
+++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/instrument/ASMBytecodeDisassemblerTest.java
@@ -16,7 +16,8 @@
package com.navercorp.pinpoint.profiler.instrument;
import com.navercorp.pinpoint.common.util.ClassLoaderUtils;
-import com.navercorp.pinpoint.test.util.BytecodeUtils;
+
+import com.navercorp.pinpoint.profiler.util.BytecodeUtils;
import org.junit.Test;
import static org.junit.Assert.*;
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/instrument/ASMMethodNodeAdapterAddInterceptorTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/instrument/ASMMethodNodeAdapterAddInterceptorTest.java
index 67aba2553..231cc2275 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/instrument/ASMMethodNodeAdapterAddInterceptorTest.java
+++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/instrument/ASMMethodNodeAdapterAddInterceptorTest.java
@@ -25,7 +25,7 @@ import com.navercorp.pinpoint.profiler.instrument.mock.BasicInterceptor;
import com.navercorp.pinpoint.profiler.instrument.mock.ExceptionInterceptor;
import com.navercorp.pinpoint.profiler.instrument.mock.StaticInterceptor;
import com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder;
-import com.navercorp.pinpoint.test.TestInterceptorRegistryBinder;
+import com.navercorp.pinpoint.profiler.util.TestInterceptorRegistryBinder;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/instrument/BytecodeDumpServiceTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/instrument/BytecodeDumpServiceTest.java
index cd70a7007..0e4bc8374 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/instrument/BytecodeDumpServiceTest.java
+++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/instrument/BytecodeDumpServiceTest.java
@@ -1,8 +1,9 @@
package com.navercorp.pinpoint.profiler.instrument;
import com.navercorp.pinpoint.common.util.ClassLoaderUtils;
+import com.navercorp.pinpoint.profiler.util.BytecodeUtils;
import com.navercorp.pinpoint.profiler.util.JavaAssistUtils;
-import com.navercorp.pinpoint.test.util.BytecodeUtils;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
@@ -20,7 +21,7 @@ import static org.mockito.Mockito.times;
@RunWith(MockitoJUnitRunner.class)
public class BytecodeDumpServiceTest {
- private final String jvmClassName = JavaAssistUtils.javaNameToJvmName("java.lang.String");;
+ private final String jvmClassName = JavaAssistUtils.javaNameToJvmName("java.lang.String");
@Mock
private ASMBytecodeDisassembler disassembler;
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/instrument/JavassistClassPoolTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/instrument/JavassistClassPoolTest.java
index bae0c36f1..f7369da7f 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/instrument/JavassistClassPoolTest.java
+++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/instrument/JavassistClassPoolTest.java
@@ -18,8 +18,9 @@ package com.navercorp.pinpoint.profiler.instrument;
import com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass;
import com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder;
-import com.navercorp.pinpoint.test.TestInterceptorRegistryBinder;
-import com.navercorp.pinpoint.test.util.BytecodeUtils;
+
+import com.navercorp.pinpoint.profiler.util.BytecodeUtils;
+import com.navercorp.pinpoint.profiler.util.TestInterceptorRegistryBinder;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtMethod;
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/instrument/classreading/SimpleClassMetadataReaderTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/instrument/classreading/SimpleClassMetadataReaderTest.java
index 628baa78b..46c78599a 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/instrument/classreading/SimpleClassMetadataReaderTest.java
+++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/instrument/classreading/SimpleClassMetadataReaderTest.java
@@ -20,7 +20,7 @@ package com.navercorp.pinpoint.profiler.instrument.classreading;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import com.navercorp.pinpoint.common.util.ClassLoaderUtils;
-import com.navercorp.pinpoint.test.util.BytecodeUtils;
+import com.navercorp.pinpoint.profiler.util.BytecodeUtils;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/InterceptorTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/InterceptorTest.java
index c060a211b..ae77d364b 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/InterceptorTest.java
+++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/InterceptorTest.java
@@ -19,8 +19,8 @@ package com.navercorp.pinpoint.profiler.interceptor;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.Arrays;
-import java.util.Map;
+import com.navercorp.pinpoint.profiler.util.LoaderUtils;
import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.CtClass;
@@ -31,13 +31,14 @@ import javassist.NotFoundException;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor;
import com.navercorp.pinpoint.bootstrap.interceptor.registry.DefaultInterceptorRegistryAdaptor;
import com.navercorp.pinpoint.bootstrap.interceptor.registry.InterceptorRegistry;
-import com.navercorp.pinpoint.test.util.LoaderUtils;
+
/**
* @author emeroad
@@ -59,27 +60,9 @@ public class InterceptorTest {
INTERCEPTOR_REGISTRY_ADAPTOR = null;
}
- // @Test
- public void methodName() throws NoSuchMethodException {
- Method[] toString = Map.class.getDeclaredMethods();
- for (Method m : toString) {
- logger.info("methodObject:{}", m);
- logger.info("methodObject:{}", m.toGenericString());
- }
- }
-
- // @Test
- public void ctClassName() throws NotFoundException {
- ClassPool pool = new ClassPool(true);
-
- CtClass ctClass = pool.get("java.lang.String");
- logger.info("ctClass:{}", ctClass);
- logger.info("ctClass:{}", ctClass.getName());
- logger.info("ctClass:{}", ctClass.getSimpleName());
- }
// @Deprecated
-// @Test
+ @Test
public void interceptor() throws NotFoundException, CannotCompileException, IllegalAccessException, InstantiationException, IOException, ClassNotFoundException, NoSuchMethodException {
AroundInterceptor aroundInterceptor = new AroundInterceptor() {
@@ -114,7 +97,7 @@ public class InterceptorTest {
// hello.insertBefore("{ System.out.println(\"BEFORE\"); }");
hello.insertBefore("{" +
- "interceptor = (" + interceptorClassName + ") " + InterceptorRegistry.class.getName() + ".getSimpleInterceptor(" + interceptorId + ");" +
+ "interceptor = (" + interceptorClassName + ") " + InterceptorRegistry.class.getName() + ".getInterceptor(" + interceptorId + ");" +
"interceptor.before(this, $args);" +
"}");
// hello.addCatch("{" +
@@ -179,46 +162,6 @@ public class InterceptorTest {
// o.hello();
}
- private String generatedAroundInterceptor(String className, String methodName) {
- StringBuilder sb = new StringBuilder();
- sb.append("{");
- sb.append(" ctx = new InterceptorContext();");
- sb.append(" ctx.setParameter($args);");
- sb.append(" ctx.setTarget(this);");
- sb.append(" ");
-// sb.append(" ctx.setMethodName(\"" + methodName + "\");");
-// sb.append(" System.out.println(\"args check : \" + $args );");
-// sb.append(" System.out.println(\"0 check : \" + $0 );");
-// sb.append(" System.out.println(\"1 check : \" + $1 );");
-// sb.append(" System.out.println(\"sig check : \" + $sig );");
-// sb.append(" System.out.println(\"class check : \" + $class );");
-// sb.append(" System.out.println(\" r check : \" + $r);");
-
- sb.append("}");
- sb.append("{");
- sb.append(" interceptor = (AroundInterceptor) " + InterceptorRegistry.class.getName() + ".getStaticInterceptor(\"a\");");
- sb.append(" interceptor.before(ctx);");
- sb.append(" result = null;");
-// println(sb, "BEFORE systemout \"ttt\"");
- sb.append("}");
- sb.append("try {");
- sb.append(" $_ = $proceed($$);");
- sb.append(" result = $_;");
- sb.append("}");
-// sb.append("catch(Throwable th) {");
-// sb.append(" System.out.println(\"test11\" + th);");
-// sb.append(" ctx.setErrCode(th);");
-// sb.append(" System.out.println(\"catch\");");
-// sb.append("}");
- sb.append("finally {");
-// sb.append(" System.out.println(\"finally\");");
- sb.append(" ctx.setReturnValue(result);");
- sb.append(" interceptor.after(ctx);");
- sb.append("}");
-// System.out.println(sb);
- return sb.toString();
- }
-
public void println(StringBuilder sb, String out) {
sb.append("System.out.println(\"" + out.replace("\"", "\\\"") + "\");");
}
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/AspectWeaverClassTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/AspectWeaverClassTest.java
index 59487831f..69e2eecef 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/AspectWeaverClassTest.java
+++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/AspectWeaverClassTest.java
@@ -17,8 +17,8 @@
package com.navercorp.pinpoint.profiler.interceptor.bci;
import com.navercorp.pinpoint.profiler.instrument.aspect.AspectWeaverClass;
-import com.navercorp.pinpoint.test.util.LoaderUtils;
+import com.navercorp.pinpoint.profiler.util.LoaderUtils;
import javassist.*;
import org.junit.Assert;
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/TestInterceptors.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/TestInterceptors.java
index b8c22f5bb..ca721065b 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/TestInterceptors.java
+++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/interceptor/bci/TestInterceptors.java
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2014 NAVER Corp.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
package com.navercorp.pinpoint.profiler.interceptor.bci;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import com.navercorp.pinpoint.bootstrap.interceptor.Interceptor;
@@ -24,16 +25,17 @@ import com.navercorp.pinpoint.bootstrap.interceptor.Interceptor;
*
*/
public class TestInterceptors {
- private static List interceptors = new ArrayList();
-
+
+ private static final List interceptors = Collections.synchronizedList(new ArrayList());
+
public static void clear() {
interceptors.clear();
}
-
+
public static void add(Interceptor interceptor) {
interceptors.add(interceptor);
}
-
+
public static Interceptor get(int index) {
return interceptors.get(index);
}
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/monitor/codahale/gc/GarbageCollectorFactoryTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/monitor/codahale/gc/GarbageCollectorFactoryTest.java
index 2ca284a40..1a6cd8d07 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/monitor/codahale/gc/GarbageCollectorFactoryTest.java
+++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/monitor/codahale/gc/GarbageCollectorFactoryTest.java
@@ -19,8 +19,9 @@ package com.navercorp.pinpoint.profiler.monitor.codahale.gc;
import com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig;
import com.navercorp.pinpoint.bootstrap.config.ProfilerConfig;
import com.navercorp.pinpoint.bootstrap.context.TraceContext;
+import com.navercorp.pinpoint.profiler.context.MockTraceContextFactory;
import com.navercorp.pinpoint.profiler.monitor.codahale.AgentStatCollectorFactory;
-import com.navercorp.pinpoint.test.MockTraceContextFactory;
+
import com.navercorp.pinpoint.thrift.dto.TJvmGc;
import org.junit.Test;
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/receiver/service/ActiveThreadServiceTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/receiver/service/ActiveThreadServiceTest.java
index 90d8e44eb..0fa22764e 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/receiver/service/ActiveThreadServiceTest.java
+++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/receiver/service/ActiveThreadServiceTest.java
@@ -22,8 +22,8 @@ package com.navercorp.pinpoint.profiler.receiver.service;
import com.navercorp.pinpoint.profiler.context.ActiveTrace;
import com.navercorp.pinpoint.profiler.context.DefaultTrace;
import com.navercorp.pinpoint.profiler.context.DefaultTraceContext;
+import com.navercorp.pinpoint.profiler.context.TestAgentInformation;
import com.navercorp.pinpoint.profiler.context.active.ActiveTraceRepository;
-import com.navercorp.pinpoint.test.TestAgentInformation;
import com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadCount;
import com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadCountRes;
@@ -35,7 +35,7 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
/**
- * @Author Taejin Koo
+ * @author Taejin Koo
*/
public class ActiveThreadServiceTest {
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/util/BytecodeUtils.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/util/BytecodeUtils.java
new file mode 100644
index 000000000..0bb34a1f1
--- /dev/null
+++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/util/BytecodeUtils.java
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2016 NAVER Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.navercorp.pinpoint.profiler.util;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Method;
+
+/**
+ * // TODO duplicate BytecodeUtils : com.navercorp.pinpoint.test.util.BytecodeUtils
+ */
+public final class BytecodeUtils {
+
+ private static final Method DEFINE_CLASS = getDefineClassMethod();
+
+ private BytecodeUtils() {
+ }
+
+
+ private static Method getDefineClassMethod() {
+ try {
+ final Method method = ClassLoader.class.getDeclaredMethod("defineClass", String.class, byte[].class, int.class, int.class);
+ method.setAccessible(true);
+ return method;
+ } catch (NoSuchMethodException e) {
+ // link error
+ throw new RuntimeException("defineClass not found. Error:" + e.getMessage(), e);
+ } catch (SecurityException e) {
+ // link error
+ throw new RuntimeException("defineClass error. Error:" + e.getMessage(), e);
+ }
+ }
+
+ public static Class> defineClass(ClassLoader classLoader, String className, byte[] classFile) {
+ try {
+ return (Class>) DEFINE_CLASS.invoke(classLoader, className, classFile, 0, classFile.length);
+ } catch (Throwable ex) {
+ throw new RuntimeException("defineClass error. Caused:" + ex.getMessage(), ex);
+ }
+ }
+
+ public static byte[] getClassFile(ClassLoader classLoader, String className) {
+ if (classLoader == null) {
+ classLoader = ClassLoader.getSystemClassLoader();
+ }
+ if (className == null) {
+ throw new NullPointerException("className must not be null");
+ }
+
+ final String jvmClassName = JavaAssistUtils.javaNameToJvmName(className);
+ final InputStream is = classLoader.getResourceAsStream(jvmClassName + ".class");
+ if (is == null) {
+ throw new RuntimeException("No such class file: " + className);
+ }
+
+ try {
+ return readClass(is, false);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } finally {
+ close(is);
+ }
+ }
+
+ /**
+ * COPY ASM method. reference : org.objectweb.asm.ClassReader
+ *
+ * Reads the bytecode of a class.
+ *
+ * @param is
+ * an input stream from which to read the class.
+ * @param close
+ * true to close the input stream after reading.
+ * @return the bytecode read from the given input stream.
+ * @throws IOException
+ * if a problem occurs during reading.
+ */
+ public static byte[] readClass(final InputStream is, boolean close)
+ throws IOException {
+ if (is == null) {
+ throw new IOException("Class not found");
+ }
+ try {
+ byte[] b = new byte[is.available()];
+ int len = 0;
+ while (true) {
+ int n = is.read(b, len, b.length - len);
+ if (n == -1) {
+ if (len < b.length) {
+ byte[] c = new byte[len];
+ System.arraycopy(b, 0, c, 0, len);
+ b = c;
+ }
+ return b;
+ }
+ len += n;
+ if (len == b.length) {
+ int last = is.read();
+ if (last < 0) {
+ return b;
+ }
+ byte[] c = new byte[b.length + 1000];
+ System.arraycopy(b, 0, c, 0, len);
+ c[len++] = (byte) last;
+ b = c;
+ }
+ }
+ } finally {
+ if (close) {
+ close(is);
+ }
+ }
+ }
+
+ private static void close(Closeable closeable) {
+ if (closeable != null) {
+ try {
+ closeable.close();
+ } catch (IOException ignore) {
+ // skip
+ }
+ }
+ }
+}
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/plugin/BytecodeUtilsTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/util/BytecodeUtilsTest.java
similarity index 89%
rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/plugin/BytecodeUtilsTest.java
rename to profiler/src/test/java/com/navercorp/pinpoint/profiler/util/BytecodeUtilsTest.java
index aeede65d7..bb3f6f37b 100644
--- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/plugin/BytecodeUtilsTest.java
+++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/util/BytecodeUtilsTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 NAVER Corp.
+ * Copyright 2016 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -12,15 +12,16 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
+ *
*/
-package com.navercorp.pinpoint.profiler.plugin;
+package com.navercorp.pinpoint.profiler.util;
import org.junit.Assert;
import org.junit.Test;
-import com.navercorp.pinpoint.test.util.BytecodeUtils;
+
public class BytecodeUtilsTest {
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/util/LoaderUtils.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/util/LoaderUtils.java
new file mode 100644
index 000000000..0ca903df4
--- /dev/null
+++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/util/LoaderUtils.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2016 NAVER Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.navercorp.pinpoint.profiler.util;
+
+import javassist.ClassPool;
+import javassist.Loader;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * TODO Duplicate : com.navercorp.pinpoint.test.util.LoaderUtils
+ * @author emeroad
+ */
+public final class LoaderUtils {
+
+ private static final SecurityManager SECURITY_MANAGER = System.getSecurityManager();
+
+ private LoaderUtils() {
+ }
+
+ public static Loader createLoader(final ClassPool classPool) {
+ if (classPool == null) {
+ throw new NullPointerException("classPool must not be null");
+ }
+ Loader loader;
+ if (SECURITY_MANAGER != null) {
+ loader = AccessController.doPrivileged(new LoaderCreateAction(classPool));
+ } else {
+ loader = new Loader(classPool);
+ }
+ loader.delegateLoadingOf("org.apache.log4j.");
+ return loader;
+ }
+
+ static class LoaderCreateAction implements PrivilegedAction {
+ private final ClassPool classPool;
+
+ public LoaderCreateAction(final ClassPool classPool) {
+ if (classPool == null) {
+ throw new NullPointerException("classPool must not be null");
+ }
+ this.classPool = classPool;
+ }
+
+ public Loader run() {
+ return new Loader(classPool);
+ }
+ }
+
+}
diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/util/TestInterceptorRegistryBinder.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/util/TestInterceptorRegistryBinder.java
new file mode 100644
index 000000000..07995f165
--- /dev/null
+++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/util/TestInterceptorRegistryBinder.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2016 NAVER Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.navercorp.pinpoint.profiler.util;
+
+import com.navercorp.pinpoint.bootstrap.interceptor.registry.DefaultInterceptorRegistryAdaptor;
+import com.navercorp.pinpoint.bootstrap.interceptor.registry.InterceptorRegistry;
+import com.navercorp.pinpoint.bootstrap.interceptor.registry.InterceptorRegistryAdaptor;
+import com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder;
+
+/**
+ * // TODO duplicate class : com.navercorp.pinpoint.test.TestInterceptorRegistryBinder
+ * @author emeroad
+ */
+public class TestInterceptorRegistryBinder implements InterceptorRegistryBinder {
+ private static final InterceptorRegistryAdaptor interceptorRegistryAdaptor = new DefaultInterceptorRegistryAdaptor();
+ private static final Object lock = new Object();
+
+ @Override
+ public void bind() {
+ try {
+ InterceptorRegistry.bind(interceptorRegistryAdaptor, lock);
+ } catch (IllegalStateException e) {
+ // ignore
+ }
+ }
+
+ @Override
+ public void unbind() {
+ try {
+ InterceptorRegistry.unbind(lock);
+ } catch (IllegalStateException e) {
+ // ignore
+ }
+ }
+
+ public InterceptorRegistryAdaptor getInterceptorRegistryAdaptor() {
+ return interceptorRegistryAdaptor;
+ }
+
+ @Override
+ public String getInterceptorRegistryClassName() {
+ return InterceptorRegistry.class.getName();
+ }
+}