use of org.robolectric.internal.bytecode.ShadowInvalidator in project robolectric by robolectric.
the class SandboxClassLoaderTest method loadClass.
private Class<?> loadClass(Class<?> clazz) throws ClassNotFoundException {
if (classLoader == null) {
classLoader = new SandboxClassLoader(configureBuilder().build());
}
setStaticField(classLoader.loadClass(InvokeDynamicSupport.class.getName()), "INTERCEPTORS", new Interceptors(Collections.<Interceptor>emptyList()));
setStaticField(classLoader.loadClass(Shadow.class.getName()), "SHADOW_IMPL", newInstance(classLoader.loadClass(ShadowImpl.class.getName())));
ShadowInvalidator invalidator = Mockito.mock(ShadowInvalidator.class);
when(invalidator.getSwitchPoint(any(Class.class))).thenReturn(new SwitchPoint());
String className = RobolectricInternals.class.getName();
Class<?> robolectricInternalsClass = ReflectionHelpers.loadClass(classLoader, className);
ReflectionHelpers.setStaticField(robolectricInternalsClass, "classHandler", classHandler);
ReflectionHelpers.setStaticField(robolectricInternalsClass, "shadowInvalidator", invalidator);
return classLoader.loadClass(clazz.getName());
}
Aggregations