@Test public void testAddCallbacksDeferring() throws Exception { Deferred<String> d = new Deferred<String>(); TestCallback cb = new TestCallback(); TestErrback eb = new TestErrback(); // Test normal callbacks. AsyncUtil.addCallbacksDeferring(d, cb, eb); final String testStr = "hello world"; d.callback(testStr); assertEquals(d.join(), "callback: " + testStr); d = new Deferred<String>(); AsyncUtil.addCallbacksDeferring(d, cb, eb); d.callback(new IllegalArgumentException()); assertEquals(d.join(), "illegal arg"); d = new Deferred<String>(); AsyncUtil.addCallbacksDeferring(d, cb, eb); d.callback(new IllegalStateException()); exception.expect(IllegalStateException.class); d.join(); }
Deferred<Master.GetTableLocationsResponsePB> returnedD = locateTablet(request.getTable(), partitionKey, FETCH_TABLETS_PER_POINT_LOOKUP, request); return AsyncUtil.addCallbacksDeferring(returnedD, cb, eb);