use of net.bytebuddy.dynamic.ClassFileLocator in project byte-buddy by raphw.
the class TypePoolDefaultWithLazyResolutionTypeDescriptionTest method testGenericResolutionIsLazyForSimpleCreation.
@Test
public void testGenericResolutionIsLazyForSimpleCreation() throws Exception {
ClassFileLocator classFileLocator = spy(ClassFileLocator.ForClassLoader.ofClassPath());
new ByteBuddy().with(TypeValidation.DISABLED).with(MethodGraph.Empty.INSTANCE).with(InstrumentedType.Factory.Default.FROZEN).redefine(describe(GenericType.class, classFileLocator, new TypePool.CacheProvider.Simple()), classFileLocator).make();
verify(classFileLocator, times(2)).locate(GenericType.class.getName());
verifyNoMoreInteractions(classFileLocator);
}
use of net.bytebuddy.dynamic.ClassFileLocator in project byte-buddy by raphw.
the class TypePoolDefaultWithLazyResolutionTypeDescriptionTest method testGenericSuperInterfaceNavigatedHierarchyResolutionIsLazy.
@Test
public void testGenericSuperInterfaceNavigatedHierarchyResolutionIsLazy() throws Exception {
ClassFileLocator classFileLocator = spy(ClassFileLocator.ForClassLoader.ofClassPath());
assertThat(describe(GenericType.class, classFileLocator, new TypePool.CacheProvider.Simple()).getInterfaces().getOnly().getInterfaces().getOnly().asErasure(), CoreMatchers.is((TypeDescription) new TypeDescription.ForLoadedType(SuperInterface.class)));
verify(classFileLocator).locate(GenericType.class.getName());
verify(classFileLocator).locate(SampleGenericInterface.class.getName());
verifyNoMoreInteractions(classFileLocator);
}
use of net.bytebuddy.dynamic.ClassFileLocator in project byte-buddy by raphw.
the class TypePoolDefaultWithLazyResolutionTypeDescriptionTest method testReferencedTypeIsCached.
@Test
public void testReferencedTypeIsCached() 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().getModifiers(), CoreMatchers.is(TypeDescription.STRING.getModifiers()));
TypeDescription superClass = resolution.resolve().getSuperClass().asErasure();
assertThat(superClass, CoreMatchers.is(TypeDescription.OBJECT));
assertThat(superClass.getModifiers(), CoreMatchers.is(TypeDescription.OBJECT.getModifiers()));
assertThat(superClass.getInterfaces(), CoreMatchers.is(TypeDescription.OBJECT.getInterfaces()));
assertThat(typePool.describe(String.class.getName()).resolve(), CoreMatchers.is(resolution.resolve()));
verify(classFileLocator).locate(String.class.getName());
verify(classFileLocator).locate(Object.class.getName());
verifyNoMoreInteractions(classFileLocator);
}
use of net.bytebuddy.dynamic.ClassFileLocator in project byte-buddy by raphw.
the class TypePoolDefaultWithLazyResolutionTypeDescriptionTest method testTypeIsLazy.
@Test
public void testTypeIsLazy() throws Exception {
ClassFileLocator classFileLocator = spy(ClassFileLocator.ForClassLoader.ofClassPath());
TypePool typePool = TypePool.Default.WithLazyResolution.of(classFileLocator);
TypePool.Resolution resolution = typePool.describe(Object.class.getName());
assertThat(resolution.resolve().getName(), CoreMatchers.is(TypeDescription.OBJECT.getName()));
verifyZeroInteractions(classFileLocator);
}
use of net.bytebuddy.dynamic.ClassFileLocator in project byte-buddy by raphw.
the class TypePoolDefaultWithLazyResolutionTypeDescriptionTest method testNonGenericResolutionIsLazyForSimpleCreationNonFrozen.
@Test
public void testNonGenericResolutionIsLazyForSimpleCreationNonFrozen() throws Exception {
ClassFileLocator classFileLocator = spy(ClassFileLocator.ForClassLoader.ofClassPath());
new ByteBuddy().with(TypeValidation.DISABLED).with(MethodGraph.Empty.INSTANCE).with(InstrumentedType.Factory.Default.MODIFIABLE).redefine(describe(NonGenericType.class, classFileLocator, new TypePool.CacheProvider.Simple()), classFileLocator).make();
verify(classFileLocator, times(2)).locate(NonGenericType.class.getName());
verifyNoMoreInteractions(classFileLocator);
}
Aggregations