summaryrefslogtreecommitdiffstats
path: root/luni/src/test/java/libcore/dalvik/system/PathClassLoaderTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'luni/src/test/java/libcore/dalvik/system/PathClassLoaderTest.java')
-rw-r--r--luni/src/test/java/libcore/dalvik/system/PathClassLoaderTest.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/luni/src/test/java/libcore/dalvik/system/PathClassLoaderTest.java b/luni/src/test/java/libcore/dalvik/system/PathClassLoaderTest.java
index 9e6d8d7..31e8fc7 100644
--- a/luni/src/test/java/libcore/dalvik/system/PathClassLoaderTest.java
+++ b/luni/src/test/java/libcore/dalvik/system/PathClassLoaderTest.java
@@ -17,9 +17,12 @@
package libcore.dalvik.system;
import dalvik.system.PathClassLoader;
+import java.lang.reflect.Method;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
+import libcore.io.Streams;
import junit.framework.TestCase;
public final class PathClassLoaderTest extends TestCase {
@@ -52,6 +55,26 @@ public final class PathClassLoaderTest extends TestCase {
return result;
}
+ public void testAppUseOfPathClassLoader() throws Exception {
+ // Extract loading-test.jar from the resource.
+ ClassLoader pcl = PathClassLoaderTest.class.getClassLoader();
+ File jar = File.createTempFile("loading-test", ".jar");
+ try (InputStream in = pcl.getResourceAsStream("dalvik/system/loading-test.jar");
+ FileOutputStream out = new FileOutputStream(jar)) {
+ Streams.copy(in, out);
+ }
+
+ // Execute code from the jar file using a PathClassLoader.
+ PathClassLoader cl = new PathClassLoader(jar.getPath(), pcl);
+ Class c = cl.loadClass("test.Test1");
+ Method m = c.getMethod("test", (Class[]) null);
+ String result = (String) m.invoke(null, (Object[]) null);
+ assertSame("blort", result);
+
+ // Clean up the extracted jar file.
+ assertTrue(jar.delete());
+ }
+
@Override protected void setUp() throws Exception {
super.setUp();
}