diff options
| author | 2019-03-25 23:54:01 -0700 | |
|---|---|---|
| committer | 2019-03-25 23:54:01 -0700 | |
| commit | 1a48fc466da9ae88c11f3771c72a9089ac5f41df (patch) | |
| tree | bbbdf060b58beacd8a31c390605a2cc485be871f | |
| parent | 0e1e725bb59806f79c72f5b2b60d2c6337e00627 (diff) | |
| parent | bb8954df3bc4d8f0b04231add412942bd86e8f51 (diff) | |
Merge "Reveal the call trace of failed test cases which run in executors"
am: bb8954df3b
Change-Id: Ia0de9ac66ad2137c6d1147e2ad5c899ab7b33ece
| -rw-r--r-- | tests/net/java/com/android/server/ConnectivityServiceTest.java | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/tests/net/java/com/android/server/ConnectivityServiceTest.java b/tests/net/java/com/android/server/ConnectivityServiceTest.java index 92a865a3dc58..bda2cb6c6f98 100644 --- a/tests/net/java/com/android/server/ConnectivityServiceTest.java +++ b/tests/net/java/com/android/server/ConnectivityServiceTest.java @@ -212,7 +212,6 @@ import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.function.Consumer; import java.util.function.Predicate; /** @@ -4022,8 +4021,13 @@ public class ConnectivityServiceTest { callback3.expectStopped(); } + @FunctionalInterface + private interface ThrowingConsumer<T> { + void accept(T t) throws Exception; + } + // Helper method to prepare the executor and run test - private void runTestWithSerialExecutors(Consumer<Executor> functor) { + private void runTestWithSerialExecutors(ThrowingConsumer<Executor> functor) throws Exception { final ExecutorService executorSingleThread = Executors.newSingleThreadExecutor(); final Executor executorInline = (Runnable r) -> r.run(); functor.accept(executorSingleThread); @@ -4032,15 +4036,9 @@ public class ConnectivityServiceTest { } @Test - public void testNattSocketKeepalives() { - runTestWithSerialExecutors(executor -> { - try { - doTestNattSocketKeepalivesWithExecutor(executor); - doTestNattSocketKeepalivesFdWithExecutor(executor); - } catch (Exception e) { - fail(e.getMessage()); - } - }); + public void testNattSocketKeepalives() throws Exception { + runTestWithSerialExecutors(executor -> doTestNattSocketKeepalivesWithExecutor(executor)); + runTestWithSerialExecutors(executor -> doTestNattSocketKeepalivesFdWithExecutor(executor)); } private void doTestNattSocketKeepalivesWithExecutor(Executor executor) throws Exception { @@ -4210,14 +4208,8 @@ public class ConnectivityServiceTest { } @Test - public void testTcpSocketKeepalives() { - runTestWithSerialExecutors(executor -> { - try { - doTestTcpSocketKeepalivesWithExecutor(executor); - } catch (Exception e) { - fail(e.getMessage()); - } - }); + public void testTcpSocketKeepalives() throws Exception { + runTestWithSerialExecutors(executor -> doTestTcpSocketKeepalivesWithExecutor(executor)); } private void doTestTcpSocketKeepalivesWithExecutor(Executor executor) throws Exception { |