Bug 1207714 - Pre: Expose synchronous executor to product code. r=rnewman

MozReview-Commit-ID: 3eDVh0nk7Nc
This commit is contained in:
Nick Alexander 2016-02-25 09:30:28 -08:00
parent 5c844cf44f
commit c1d6f977a4
4 changed files with 14 additions and 13 deletions

View File

@ -23,6 +23,7 @@ import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.Executor;
import org.json.simple.JSONArray;
import org.mozilla.apache.commons.codec.binary.Base32;
@ -562,4 +563,13 @@ public class Utils {
}
}
}
public static Executor newSynchronousExecutor() {
return new Executor() {
@Override
public void execute(Runnable runnable) {
runnable.run();
}
};
}
}

View File

@ -169,14 +169,4 @@ public class WaitHelper {
public boolean isIdle() {
return queue.isEmpty();
}
public static Executor newSynchronousExecutor() {
return new Executor() {
@Override
public void execute(Runnable runnable) {
runnable.run();
}
};
}
}

View File

@ -10,20 +10,21 @@ import org.mozilla.gecko.background.testhelpers.TestRunner;
import org.mozilla.gecko.background.testhelpers.WaitHelper;
import org.mozilla.gecko.push.autopush.AutopushClient;
import org.mozilla.gecko.push.autopush.AutopushClientException;
import org.mozilla.gecko.sync.Utils;
@RunWith(TestRunner.class)
public class TestAutopushClient {
@Test
public void testGetSenderID() throws Exception {
final AutopushClient client = new AutopushClient("https://updates-autopush-dev.stage.mozaws.net/v1/gcm/829133274407",
WaitHelper.newSynchronousExecutor());
Utils.newSynchronousExecutor());
Assert.assertEquals("829133274407", client.getSenderIDFromServerURI());
}
@Test(expected=AutopushClientException.class)
public void testGetNoSenderID() throws Exception {
final AutopushClient client = new AutopushClient("https://updates-autopush-dev.stage.mozaws.net/v1/gcm",
WaitHelper.newSynchronousExecutor());
Utils.newSynchronousExecutor());
client.getSenderIDFromServerURI();
}
}

View File

@ -42,7 +42,7 @@ public class TestLiveAutopushClient {
@Before
public void setUp() throws Exception {
BaseResource.rewriteLocalhost = false;
client = new AutopushClient(serverURL, WaitHelper.newSynchronousExecutor());
client = new AutopushClient(serverURL, Utils.newSynchronousExecutor());
}
protected <T> T assertSuccess(RequestDelegate<T> delegate, Class<T> klass) {