mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-15 15:55:54 +10:00
[#49] Created arcus plugin project
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package com.nhn.pinpoint.test.interceptor;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLoggerFactory;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.context.TraceContext;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.ByteCodeMethodDescriptorSupport;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.Interceptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.MethodDescriptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.TraceContextSupport;
|
||||
import com.nhn.pinpoint.profiler.logging.Slf4jLoggerBinder;
|
||||
import com.nhn.pinpoint.test.mock.MockTraceContextFactory;
|
||||
|
||||
public class BaseInterceptorTest {
|
||||
|
||||
Interceptor interceptor;
|
||||
MethodDescriptor descriptor;
|
||||
|
||||
public void setInterceptor(Interceptor interceptor) {
|
||||
this.interceptor = interceptor;
|
||||
}
|
||||
|
||||
public void setMethodDescriptor(MethodDescriptor methodDescriptor) {
|
||||
this.descriptor = methodDescriptor;
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void before() {
|
||||
PLoggerFactory.initialize(new Slf4jLoggerBinder());
|
||||
}
|
||||
|
||||
@Before
|
||||
public void beforeEach() {
|
||||
if (interceptor == null) {
|
||||
Assert.fail("set the interceptor first.");
|
||||
}
|
||||
|
||||
if (interceptor instanceof TraceContextSupport) {
|
||||
// sampler
|
||||
|
||||
// trace context
|
||||
TraceContext traceContext = new MockTraceContextFactory().create();
|
||||
((TraceContextSupport) interceptor).setTraceContext(traceContext);
|
||||
}
|
||||
|
||||
if (interceptor instanceof ByteCodeMethodDescriptorSupport) {
|
||||
if (descriptor != null) {
|
||||
((ByteCodeMethodDescriptorSupport)interceptor).setMethodDescriptor(descriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.nhn.pinpoint.test.mock;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.config.ProfilerConfig;
|
||||
import com.nhn.pinpoint.bootstrap.context.TraceContext;
|
||||
import com.nhn.pinpoint.profiler.context.DefaultTraceContext;
|
||||
|
||||
/**
|
||||
* @author emeroad
|
||||
*/
|
||||
public class MockTraceContextFactory {
|
||||
public TraceContext create() {
|
||||
DefaultTraceContext traceContext = new DefaultTraceContext() ;
|
||||
ProfilerConfig profilerConfig = new ProfilerConfig();
|
||||
traceContext.setProfilerConfig(profilerConfig);
|
||||
return traceContext;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user