diff options
author | Narayan Kamath <narayan@google.com> | 2015-04-30 10:36:15 +0100 |
---|---|---|
committer | Narayan Kamath <narayan@google.com> | 2015-04-30 12:00:24 +0100 |
commit | 05fd64ae4c92b1787a4cfa632ea1e6b3ceeeff91 (patch) | |
tree | b4a61d3f40ec45b8783f2fb2cd51622546db4548 /jsr166-tests/src/test/java/jsr166 | |
parent | 8e9a0e92906742b17eb08d7fb83cca91965f9b8e (diff) | |
download | libcore-05fd64ae4c92b1787a4cfa632ea1e6b3ceeeff91.zip libcore-05fd64ae4c92b1787a4cfa632ea1e6b3ceeeff91.tar.gz libcore-05fd64ae4c92b1787a4cfa632ea1e6b3ceeeff91.tar.bz2 |
Fix JSR-166 tests.
- Remove calls to setSecurityManager, which throws unconditionally
on android.
- Remove an unsupported AccessController check.
- Remove an assertion that the default uncaught exception handler is
null. Regular android processes always have one installed.
bug: 20628776
(cherry picked from commit 151f344e88956741c0b8e4018df845d85d4eef25)
Change-Id: Ida7499c74586d007b8381522bec45f9a0c8fa7b4
Diffstat (limited to 'jsr166-tests/src/test/java/jsr166')
-rw-r--r-- | jsr166-tests/src/test/java/jsr166/ExecutorsTest.java | 5 | ||||
-rw-r--r-- | jsr166-tests/src/test/java/jsr166/JSR166TestCase.java | 30 | ||||
-rw-r--r-- | jsr166-tests/src/test/java/jsr166/ThreadTest.java | 6 |
3 files changed, 10 insertions, 31 deletions
diff --git a/jsr166-tests/src/test/java/jsr166/ExecutorsTest.java b/jsr166-tests/src/test/java/jsr166/ExecutorsTest.java index 2518e63..ae475f1 100644 --- a/jsr166-tests/src/test/java/jsr166/ExecutorsTest.java +++ b/jsr166-tests/src/test/java/jsr166/ExecutorsTest.java @@ -350,7 +350,8 @@ public class ExecutorsTest extends JSR166TestCase { public void realRun() throws Exception { final ThreadGroup egroup = Thread.currentThread().getThreadGroup(); final ClassLoader thisccl = Thread.currentThread().getContextClassLoader(); - final AccessControlContext thisacc = AccessController.getContext(); + // android-note: Removed unsupported access controller check. + // final AccessControlContext thisacc = AccessController.getContext(); Runnable r = new CheckedRunnable() { public void realRun() { Thread current = Thread.currentThread(); @@ -365,7 +366,7 @@ public class ExecutorsTest extends JSR166TestCase { String name = current.getName(); assertTrue(name.endsWith("thread-1")); assertSame(thisccl, current.getContextClassLoader()); - assertEquals(thisacc, AccessController.getContext()); + // assertEquals(thisacc, AccessController.getContext()); done.countDown(); }}; ExecutorService e = Executors.newSingleThreadExecutor(Executors.privilegedThreadFactory()); diff --git a/jsr166-tests/src/test/java/jsr166/JSR166TestCase.java b/jsr166-tests/src/test/java/jsr166/JSR166TestCase.java index d07d936..61fa66d 100644 --- a/jsr166-tests/src/test/java/jsr166/JSR166TestCase.java +++ b/jsr166-tests/src/test/java/jsr166/JSR166TestCase.java @@ -532,11 +532,7 @@ public class JSR166TestCase extends TestCase { * getPolicy/setPolicy. */ public void runWithPermissions(Runnable r, Permission... permissions) { - SecurityManager sm = System.getSecurityManager(); - if (sm == null) { - r.run(); - } - runWithSecurityManagerWithPermissions(r, permissions); + r.run(); } /** @@ -548,29 +544,7 @@ public class JSR166TestCase extends TestCase { */ public void runWithSecurityManagerWithPermissions(Runnable r, Permission... permissions) { - SecurityManager sm = System.getSecurityManager(); - if (sm == null) { - Policy savedPolicy = Policy.getPolicy(); - try { - Policy.setPolicy(permissivePolicy()); - System.setSecurityManager(new SecurityManager()); - runWithSecurityManagerWithPermissions(r, permissions); - } finally { - System.setSecurityManager(null); - Policy.setPolicy(savedPolicy); - } - } else { - Policy savedPolicy = Policy.getPolicy(); - AdjustablePolicy policy = new AdjustablePolicy(permissions); - Policy.setPolicy(policy); - - try { - r.run(); - } finally { - policy.addPermission(new SecurityPermission("setPolicy")); - Policy.setPolicy(savedPolicy); - } - } + r.run(); } /** diff --git a/jsr166-tests/src/test/java/jsr166/ThreadTest.java b/jsr166-tests/src/test/java/jsr166/ThreadTest.java index 2652201..27f22ca 100644 --- a/jsr166-tests/src/test/java/jsr166/ThreadTest.java +++ b/jsr166-tests/src/test/java/jsr166/ThreadTest.java @@ -53,7 +53,11 @@ public class ThreadTest extends JSR166TestCase { * setDefaultUncaughtExceptionHandler. */ public void testGetAndSetDefaultUncaughtExceptionHandler() { - assertEquals(null, Thread.getDefaultUncaughtExceptionHandler()); + // android-note: Removed assertion; all "normal" android apps (including CTS tests) have a + // default uncaught exception handler installed by the framework. + // + // assertEquals(null, Thread.getDefaultUncaughtExceptionHandler()); + // failure due to securityException is OK. // Would be nice to explicitly test both ways, but cannot yet. Thread.UncaughtExceptionHandler defaultHandler |