use of org.robolectric.internal.bytecode.SandboxClassLoader in project robolectric by robolectric.
the class SandboxTestRunner method getSandbox.
@NotNull
protected Sandbox getSandbox(FrameworkMethod method) {
InstrumentationConfiguration instrumentationConfiguration = createClassLoaderConfig(method);
URLClassLoader systemClassLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
ClassLoader sandboxClassLoader = new SandboxClassLoader(systemClassLoader, instrumentationConfiguration);
Sandbox sandbox = new Sandbox(sandboxClassLoader);
configureShadows(method, sandbox);
return sandbox;
}
use of org.robolectric.internal.bytecode.SandboxClassLoader in project robolectric by robolectric.
the class SandboxClassLoaderTest method shouldFixTypesInMethodArgsAndReturn.
@Test
public void shouldFixTypesInMethodArgsAndReturn() throws Exception {
setClassLoader(new SandboxClassLoader(createRemappingConfig()));
Class<?> theClass = loadClass(AClassThatRefersToAForgettableClassInMethodCalls.class);
assertNotNull(theClass.getDeclaredMethod("aMethod", int.class, loadClass(AClassToRemember.class), String.class));
}
use of org.robolectric.internal.bytecode.SandboxClassLoader in project robolectric by robolectric.
the class SandboxClassLoaderTest method shouldRemapClasses.
@Test
public void shouldRemapClasses() throws Exception {
setClassLoader(new SandboxClassLoader(createRemappingConfig()));
Class<?> theClass = loadClass(AClassThatRefersToAForgettableClass.class);
assertEquals(loadClass(AClassToRemember.class), theClass.getField("someField").getType());
assertEquals(Array.newInstance(loadClass(AClassToRemember.class), 0).getClass(), theClass.getField("someFields").getType());
}
Aggregations