@@ -0,0 +1,2262 @@
+package com.couchbase.cblite.testapp.ektorp.tests;%0A%0Aimport android.util.Log;%0A%0Aimport com.couchbase.cblite.ektorp.CBLiteHttpClient;%0A%0Aimport org.ektorp.CouchDbConnector;%0Aimport org.ektorp.CouchDbInstance;%0Aimport org.ektorp.DbAccessException;%0Aimport org.ektorp.android.util.ChangesFeedAsyncTask;%0Aimport org.ektorp.android.util.EktorpAsyncTask;%0Aimport org.ektorp.changes.ChangesCommand;%0Aimport org.ektorp.changes.DocumentChange;%0Aimport org.ektorp.http.HttpClient;%0Aimport org.ektorp.impl.StdCouchDbInstance;%0A%0Aimport java.util.concurrent.CountDownLatch;%0Aimport java.util.concurrent.TimeUnit;%0A%0Apublic class EktorpAsyncTaskTest extends CBLiteEktorpTestCase %7B%0A%0A    // Regression test for https://github.com/couchbaselabs/TouchDB-Android/issues/71%0A    public void testWedgedAsyncTasks() %7B%0A%0A        final CountDownLatch doneSignal = new CountDownLatch(1);%0A        HttpClient httpClient = new CBLiteHttpClient(server);%0A        CouchDbInstance dbInstance = new StdCouchDbInstance(httpClient);%0A%0A        // create a local database%0A        CouchDbConnector couchDbConnector = dbInstance.createConnector(DEFAULT_TEST_DB, true);%0A%0A        //create an ansyc task to get updates%0A        ChangesCommand changesCmd = new ChangesCommand.Builder().since(0)%0A                .includeDocs(false)%0A                .continuous(true)%0A                .heartbeat(5000)%0A                .build();%0A%0A        ChangesFeedAsyncTask couchChangesAsyncTask = new ChangesFeedAsyncTask(couchDbConnector, changesCmd) %7B%0A            @Override%0A            protected void handleDocumentChange(DocumentChange documentChange) %7B%0A                Log.d(TAG, %22handleDocumentChange called%22);%0A            %7D%0A        %7D;%0A        couchChangesAsyncTask.execute();%0A%0A        EktorpAsyncTask asyncTask = new EktorpAsyncTask() %7B%0A            @Override%0A            protected void doInBackground() %7B%0A                Log.d(TAG, %22doInBackground() called%22);%0A                doneSignal.countDown();%0A            %7D%0A        %7D;%0A        asyncTask.execute();%0A%0A        try %7B%0A            boolean wasSignalled = doneSignal.await(500, TimeUnit.MILLISECONDS);%0A            assertTrue(%22The async task was wedged by the changes feed task%22, wasSignalled);%0A        %7D catch (InterruptedException e) %7B%0A            e.printStackTrace();%0A        %7D%0A%0A    %7D%0A%0A%7D%0A

Test case which detects https://github.com/couchbaselabs/TouchDB-Android/issues/71