Search in sources :

Example 21 with Instrumentation

use of java.lang.instrument.Instrumentation in project byte-buddy by raphw.

the class AgentBuilderRedefinitionStrategyTest method testRetransformationStrategyIsChecked.

@Test
public void testRetransformationStrategyIsChecked() throws Exception {
    Instrumentation instrumentation = mock(Instrumentation.class);
    when(instrumentation.isRetransformClassesSupported()).thenReturn(true);
    AgentBuilder.RedefinitionStrategy.RETRANSFORMATION.check(instrumentation);
}
Also used : Instrumentation(java.lang.instrument.Instrumentation) Test(org.junit.Test)

Example 22 with Instrumentation

use of java.lang.instrument.Instrumentation in project byte-buddy by raphw.

the class AgentBuilderLambdaInstrumentationStrategyTest method testDisabledStrategyIsNoOp.

@Test
public void testDisabledStrategyIsNoOp() throws Exception {
    ByteBuddy byteBuddy = mock(ByteBuddy.class);
    Instrumentation instrumentation = mock(Instrumentation.class);
    ClassFileTransformer classFileTransformer = mock(ClassFileTransformer.class);
    AgentBuilder.Default.LambdaInstrumentationStrategy.DISABLED.apply(byteBuddy, instrumentation, classFileTransformer);
    verifyZeroInteractions(byteBuddy);
    verifyZeroInteractions(instrumentation);
    verifyZeroInteractions(classFileTransformer);
}
Also used : ClassFileTransformer(java.lang.instrument.ClassFileTransformer) ByteBuddy(net.bytebuddy.ByteBuddy) Instrumentation(java.lang.instrument.Instrumentation) Test(org.junit.Test)

Example 23 with Instrumentation

use of java.lang.instrument.Instrumentation in project byte-buddy by raphw.

the class AgentBuilderListenerTest method testReadEdgeAddingListenerDuplexUnnamed.

@Test
public void testReadEdgeAddingListenerDuplexUnnamed() throws Exception {
    Instrumentation instrumentation = mock(Instrumentation.class);
    JavaModule source = mock(JavaModule.class), target = mock(JavaModule.class);
    AgentBuilder.Listener listener = new AgentBuilder.Listener.ModuleReadEdgeCompleting(instrumentation, true, Collections.singleton(target));
    listener.onTransformation(mock(TypeDescription.class), mock(ClassLoader.class), source, LOADED, mock(DynamicType.class));
    verify(source).isNamed();
    verifyNoMoreInteractions(source);
    verifyZeroInteractions(target);
}
Also used : DynamicType(net.bytebuddy.dynamic.DynamicType) Instrumentation(java.lang.instrument.Instrumentation) TypeDescription(net.bytebuddy.description.type.TypeDescription) JavaModule(net.bytebuddy.utility.JavaModule) Test(org.junit.Test)

Example 24 with Instrumentation

use of java.lang.instrument.Instrumentation in project byte-buddy by raphw.

the class AgentBuilderListenerTest method testReadEdgeAddingListenerNotSupported.

@Test
public void testReadEdgeAddingListenerNotSupported() throws Exception {
    Instrumentation instrumentation = mock(Instrumentation.class);
    AgentBuilder.Listener listener = new AgentBuilder.Listener.ModuleReadEdgeCompleting(instrumentation, false, Collections.<JavaModule>emptySet());
    listener.onTransformation(mock(TypeDescription.class), mock(ClassLoader.class), JavaModule.UNSUPPORTED, LOADED, mock(DynamicType.class));
}
Also used : DynamicType(net.bytebuddy.dynamic.DynamicType) Instrumentation(java.lang.instrument.Instrumentation) TypeDescription(net.bytebuddy.description.type.TypeDescription) Test(org.junit.Test)

Example 25 with Instrumentation

use of java.lang.instrument.Instrumentation in project byte-buddy by raphw.

the class AgentBuilderListenerTest method testReadEdgeAddingListenerDuplexCanRead.

@Test
public void testReadEdgeAddingListenerDuplexCanRead() throws Exception {
    Instrumentation instrumentation = mock(Instrumentation.class);
    JavaModule source = mock(JavaModule.class), target = mock(JavaModule.class);
    when(source.isNamed()).thenReturn(true);
    when(source.canRead(target)).thenReturn(true);
    when(target.canRead(source)).thenReturn(true);
    AgentBuilder.Listener listener = new AgentBuilder.Listener.ModuleReadEdgeCompleting(instrumentation, true, Collections.singleton(target));
    listener.onTransformation(mock(TypeDescription.class), mock(ClassLoader.class), source, LOADED, mock(DynamicType.class));
    verify(source).isNamed();
    verify(source).canRead(target);
    verifyNoMoreInteractions(source);
    verify(target).canRead(source);
    verifyNoMoreInteractions(target);
}
Also used : DynamicType(net.bytebuddy.dynamic.DynamicType) Instrumentation(java.lang.instrument.Instrumentation) TypeDescription(net.bytebuddy.description.type.TypeDescription) JavaModule(net.bytebuddy.utility.JavaModule) Test(org.junit.Test)

Aggregations

Instrumentation (java.lang.instrument.Instrumentation)31 Test (org.junit.Test)21 TypeDescription (net.bytebuddy.description.type.TypeDescription)8 DynamicType (net.bytebuddy.dynamic.DynamicType)8 JavaModule (net.bytebuddy.utility.JavaModule)6 ClassFileTransformer (java.lang.instrument.ClassFileTransformer)4 InterceptorRegistryBinder (com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder)3 TestInterceptorRegistryBinder (com.navercorp.pinpoint.profiler.util.TestInterceptorRegistryBinder)3 ByteBuddy (net.bytebuddy.ByteBuddy)3 AgentOption (com.navercorp.pinpoint.bootstrap.AgentOption)2 DefaultAgentOption (com.navercorp.pinpoint.bootstrap.DefaultAgentOption)2 DefaultProfilerConfig (com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig)2 ProfilerConfig (com.navercorp.pinpoint.bootstrap.config.ProfilerConfig)2 DefaultAnnotationKeyRegistryService (com.navercorp.pinpoint.common.service.DefaultAnnotationKeyRegistryService)2 DefaultServiceTypeRegistryService (com.navercorp.pinpoint.common.service.DefaultServiceTypeRegistryService)2 ApiMetaDataService (com.navercorp.pinpoint.profiler.metadata.ApiMetaDataService)2 ObjectBinderFactory (com.navercorp.pinpoint.profiler.objectfactory.ObjectBinderFactory)2 Properties (java.util.Properties)2 Callable (java.util.concurrent.Callable)2 JarFile (java.util.jar.JarFile)2