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