Search in sources :

Example 31 with ClassFileLocator

use of net.bytebuddy.dynamic.ClassFileLocator in project byte-buddy by raphw.

the class TypePoolDefaultWithLazyResolutionTypeDescriptionTest method testReferencedTypeIsLazy.

@Test
public void testReferencedTypeIsLazy() throws Exception {
    ClassFileLocator classFileLocator = spy(ClassFileLocator.ForClassLoader.ofClassPath());
    TypePool typePool = TypePool.Default.WithLazyResolution.of(classFileLocator);
    TypePool.Resolution resolution = typePool.describe(String.class.getName());
    assertThat(resolution.resolve().getName(), CoreMatchers.is(TypeDescription.STRING.getName()));
    assertThat(resolution.resolve().getSuperClass().asErasure().getName(), CoreMatchers.is(TypeDescription.OBJECT.getName()));
    verify(classFileLocator).locate(String.class.getName());
    verifyNoMoreInteractions(classFileLocator);
}
Also used : ClassFileLocator(net.bytebuddy.dynamic.ClassFileLocator) Test(org.junit.Test) AbstractTypeDescriptionTest(net.bytebuddy.description.type.AbstractTypeDescriptionTest)

Aggregations

ClassFileLocator (net.bytebuddy.dynamic.ClassFileLocator)31 Test (org.junit.Test)29 TypeDescription (net.bytebuddy.description.type.TypeDescription)17 AbstractTypeDescriptionTest (net.bytebuddy.description.type.AbstractTypeDescriptionTest)15 List (java.util.List)7 InvocationOnMock (org.mockito.invocation.InvocationOnMock)7 ByteBuddy (net.bytebuddy.ByteBuddy)6 File (java.io.File)2 Instrumentation (java.lang.instrument.Instrumentation)2 ArrayList (java.util.ArrayList)2 TypePool (net.bytebuddy.pool.TypePool)2 IOException (java.io.IOException)1 ClassDefinition (java.lang.instrument.ClassDefinition)1 Callable (java.util.concurrent.Callable)1 RandomString (net.bytebuddy.utility.RandomString)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 GradleException (org.gradle.api.GradleException)1 BaseMatcher (org.hamcrest.BaseMatcher)1 Description (org.hamcrest.Description)1