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);
}
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);
}
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);
}
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));
}
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);
}
Aggregations