Search in sources :

Example 6 with JavaModule

use of net.bytebuddy.utility.JavaModule 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 7 with JavaModule

use of net.bytebuddy.utility.JavaModule 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

JavaModule (net.bytebuddy.utility.JavaModule)7 Test (org.junit.Test)7 Instrumentation (java.lang.instrument.Instrumentation)6 TypeDescription (net.bytebuddy.description.type.TypeDescription)6 DynamicType (net.bytebuddy.dynamic.DynamicType)6 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1