}
@Test
public void testMultiMethod() throws Exception
{
MultiMethod bean = new MultiMethod() {
public String method1(int i)
{
return "1:" + i;
}
public String method2(int i)
{
return "2:" + i;
}
};
MultiMethod asyncBean = AsyncUtils.mixinAsync(bean);
{
asyncBean.method1(3);
Future<?> futureResult = AsyncUtils.getFutureResult(asyncBean);
String actual = (String) futureResult.get(2, TimeUnit.SECONDS);
assertEquals("1:3", actual);
}
// invoke another async method on the same reference
{
asyncBean.method2(4);
Future<?> futureResult = AsyncUtils.getFutureResult(asyncBean);
String actual = (String) futureResult.get(2, TimeUnit.SECONDS);