@@ -0,0 +1,3364 @@
+//%0A// Copyright (c) 2019 Couchbase, Inc All rights reserved.%0A//%0A// Licensed under the Apache License, Version 2.0 (the %22License%22);%0A// you may not use this file except in compliance with the License.%0A// You may obtain a copy of the License at%0A//%0A// http://www.apache.org/licenses/LICENSE-2.0%0A//%0A// Unless required by applicable law or agreed to in writing, software%0A// distributed under the License is distributed on an %22AS IS%22 BASIS,%0A// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A// See the License for the specific language governing permissions and%0A// limitations under the License.%0A//%0Apackage com.couchbase.lite;%0A%0Aimport java.util.concurrent.CountDownLatch;%0Aimport java.util.concurrent.Executor;%0Aimport java.util.concurrent.RejectedExecutionException;%0Aimport java.util.concurrent.ThreadPoolExecutor;%0Aimport java.util.concurrent.TimeUnit;%0A%0Aimport org.junit.Ignore;%0Aimport org.junit.Test;%0A%0Aimport com.couchbase.lite.internal.AbstractExecutionService;%0Aimport com.couchbase.lite.internal.AndroidExecutionService;%0A%0A%0Apublic class AndroidConcurrencyTest %7B%0A%0A    @Ignore(%22This is not actually a test.  Use it to verify logcat output%22)%0A    @Test(expected = RejectedExecutionException.class)%0A    public void testSerialExecutorFailure() %7B%0A        AndroidExecutionService execSvc = new AndroidExecutionService();%0A        ThreadPoolExecutor exec = execSvc.getBaseExecutor();%0A        Executor serialExcecutor = execSvc.getSerialExecutor();%0A%0A        // hang the queue%0A        final CountDownLatch latch = new CountDownLatch(1);%0A        serialExcecutor.execute(() -%3E %7B%0A            try %7B latch.await(2, TimeUnit.SECONDS); %7D%0A            catch (InterruptedException ignore) %7B %7D%0A        %7D);%0A%0A        // put some stuff in the serial executor queue%0A        for (int i = 1; i %3C 10; i++) %7B serialExcecutor.execute(() -%3E %7B%7D); %7D%0A%0A        // fill the base executor.%0A        try %7B%0A            while (true) %7B%0A                exec.execute(%0A                    new AbstractExecutionService.InstrumentedTask(%0A                        () -%3E %7B%0A                            try %7B Thread.sleep(10 * 1000); %7D%0A                            catch (InterruptedException ignore) %7B%7D%0A                        %7D,%0A                        () -%3E %7B%7D));%0A            %7D%0A        %7D%0A        catch (RejectedExecutionException ignore) %7B %7D%0A%0A        // this should free the running serial job,%0A        // which should fail trying to start the next job%0A        latch.countDown();%0A    %7D%0A%0A    @Ignore(%22This is not actually a test.  Use it to verify logcat output%22)%0A    @Test(expected = RejectedExecutionException.class)%0A    public void testConcurrentExecutorFailure() %7B%0A        AndroidExecutionService execSvc = new AndroidExecutionService();%0A        ThreadPoolExecutor exec = execSvc.getBaseExecutor();%0A%0A        // fill the executor%0A        try %7B%0A            while (true) %7B%0A                exec.execute(%0A                    new AndroidExecutionService.InstrumentedTask(%0A                        () -%3E %7B%0A                            try %7B Thread.sleep(10 * 1000); %7D%0A                            catch (InterruptedException ignore) %7B%7D%0A                        %7D,%0A                        () -%3E %7B%7D));%0A            %7D%0A        %7D%0A        catch (RejectedExecutionException ignore) %7B %7D%0A%0A        // this should fail because the executor is full%0A        execSvc.getConcurrentExecutor().execute(() -%3E %7B%7D);%0A    %7D%0A%7D%0A%0A

Move non-shared tests out of pure java