use of net.bytebuddy.dynamic.ClassFileLocator in project byte-buddy by raphw.
the class TypePoolDefaultWithLazyResolutionTypeDescriptionTest method testNonGenericSuperClassHierarchyResolutionIsLazy.
@Test
public void testNonGenericSuperClassHierarchyResolutionIsLazy() throws Exception {
ClassFileLocator classFileLocator = spy(ClassFileLocator.ForClassLoader.ofClassPath());
assertThat(describe(NonGenericType.class, classFileLocator, new TypePool.CacheProvider.Simple()).getSuperClass().asErasure(), CoreMatchers.is((TypeDescription) new TypeDescription.ForLoadedType(SampleClass.class)));
verify(classFileLocator).locate(NonGenericType.class.getName());
verifyNoMoreInteractions(classFileLocator);
}
use of net.bytebuddy.dynamic.ClassFileLocator in project byte-buddy by raphw.
the class TypePoolDefaultWithLazyResolutionTypeDescriptionTest method testNonGenericSuperInterfaceNavigatedHierarchyResolutionIsLazy.
@Test
public void testNonGenericSuperInterfaceNavigatedHierarchyResolutionIsLazy() throws Exception {
ClassFileLocator classFileLocator = spy(ClassFileLocator.ForClassLoader.ofClassPath());
assertThat(describe(NonGenericType.class, classFileLocator, new TypePool.CacheProvider.Simple()).getInterfaces().getOnly().getInterfaces().getOnly().asErasure(), CoreMatchers.is((TypeDescription) new TypeDescription.ForLoadedType(SuperInterface.class)));
verify(classFileLocator).locate(NonGenericType.class.getName());
verify(classFileLocator).locate(SampleInterface.class.getName());
verifyNoMoreInteractions(classFileLocator);
}
use of net.bytebuddy.dynamic.ClassFileLocator in project byte-buddy by raphw.
the class TypePoolDefaultWithLazyResolutionTypeDescriptionTest method testNonGenericSuperClassNavigatedHierarchyResolutionIsLazy.
@Test
public void testNonGenericSuperClassNavigatedHierarchyResolutionIsLazy() throws Exception {
ClassFileLocator classFileLocator = spy(ClassFileLocator.ForClassLoader.ofClassPath());
assertThat(describe(NonGenericType.class, classFileLocator, new TypePool.CacheProvider.Simple()).getSuperClass().getSuperClass().asErasure(), CoreMatchers.is((TypeDescription) new TypeDescription.ForLoadedType(SuperClass.class)));
verify(classFileLocator).locate(NonGenericType.class.getName());
verify(classFileLocator).locate(SampleClass.class.getName());
verifyNoMoreInteractions(classFileLocator);
}
use of net.bytebuddy.dynamic.ClassFileLocator in project byte-buddy by raphw.
the class TypePoolDefaultWithLazyResolutionTypeDescriptionTest method testNonGenericResolutionIsLazyForSimpleCreation.
@Test
public void testNonGenericResolutionIsLazyForSimpleCreation() throws Exception {
ClassFileLocator classFileLocator = spy(ClassFileLocator.ForClassLoader.ofClassPath());
new ByteBuddy().with(TypeValidation.DISABLED).with(MethodGraph.Empty.INSTANCE).with(InstrumentedType.Factory.Default.FROZEN).redefine(describe(NonGenericType.class, classFileLocator, new TypePool.CacheProvider.Simple()), classFileLocator).make();
verify(classFileLocator, times(2)).locate(NonGenericType.class.getName());
verifyNoMoreInteractions(classFileLocator);
}
use of net.bytebuddy.dynamic.ClassFileLocator in project byte-buddy by raphw.
the class AgentBuilderDescriptionStrategyTest method testDescriptionHybridWithLoaded.
@Test
public void testDescriptionHybridWithLoaded() throws Exception {
ClassFileLocator classFileLocator = ClassFileLocator.ForClassLoader.of(Object.class.getClassLoader());
when(typePool.describe(Object.class.getName())).thenReturn(new TypePool.Resolution.Simple(typeDescription));
when(locationStrategy.classFileLocator(Object.class.getClassLoader(), JavaModule.ofType(Object.class))).thenReturn(classFileLocator);
TypeDescription typeDescription = AgentBuilder.DescriptionStrategy.Default.HYBRID.apply(Object.class.getName(), Object.class, typePool, mock(AgentBuilder.CircularityLock.class), Object.class.getClassLoader(), JavaModule.ofType(Object.class));
assertThat(typeDescription, is(TypeDescription.OBJECT));
assertThat(typeDescription, instanceOf(TypeDescription.ForLoadedType.class));
}
Aggregations