Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | package org.mozilla.gecko.background.sync.helpers; |
michael@0 | 5 | |
michael@0 | 6 | import java.util.concurrent.ExecutorService; |
michael@0 | 7 | |
michael@0 | 8 | import junit.framework.AssertionFailedError; |
michael@0 | 9 | |
michael@0 | 10 | import org.mozilla.gecko.background.testhelpers.WaitHelper; |
michael@0 | 11 | |
michael@0 | 12 | public abstract class DefaultDelegate { |
michael@0 | 13 | protected ExecutorService executor; |
michael@0 | 14 | |
michael@0 | 15 | protected final WaitHelper waitHelper; |
michael@0 | 16 | |
michael@0 | 17 | public DefaultDelegate() { |
michael@0 | 18 | waitHelper = WaitHelper.getTestWaiter(); |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | public DefaultDelegate(WaitHelper waitHelper) { |
michael@0 | 22 | this.waitHelper = waitHelper; |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | protected WaitHelper getTestWaiter() { |
michael@0 | 26 | return waitHelper; |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | public void performWait(Runnable runnable) throws AssertionFailedError { |
michael@0 | 30 | getTestWaiter().performWait(runnable); |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | public void performNotify() { |
michael@0 | 34 | getTestWaiter().performNotify(); |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | public void performNotify(Throwable e) { |
michael@0 | 38 | getTestWaiter().performNotify(e); |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | public void performNotify(String reason, Throwable e) { |
michael@0 | 42 | String message = reason; |
michael@0 | 43 | if (e != null) { |
michael@0 | 44 | message += ": " + e.getMessage(); |
michael@0 | 45 | } |
michael@0 | 46 | AssertionFailedError ex = new AssertionFailedError(message); |
michael@0 | 47 | if (e != null) { |
michael@0 | 48 | ex.initCause(e); |
michael@0 | 49 | } |
michael@0 | 50 | getTestWaiter().performNotify(ex); |
michael@0 | 51 | } |
michael@0 | 52 | } |