}
public static void testGetResultWithTimeoutAndResultSetter() {
final Promise p=new Promise();
Thread t=new Thread() {
public void run() {
Util.sleep(500);
System.out.println("-- setting promise to \"Bela\"");
p.setResult("Bela");
}
};
t.start();
long start=System.currentTimeMillis(), stop;
Object result=p.getResult(30000);
stop=System.currentTimeMillis();
System.out.println("-- waited for " + (stop-start) + "ms, result is " + result);
assert result != null;
Assert.assertEquals("Bela", result);
assert p.hasResult();
assert p.getResult().equals("Bela");
}