2011-03-01 15:23:29 -07:00
|
|
|
package akka.dispatch;
|
|
|
|
|
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
|
import java.util.concurrent.Callable;
|
2011-03-11 10:46:36 -07:00
|
|
|
import akka.japi.Function;
|
|
|
|
|
import akka.japi.Procedure;
|
2011-03-01 15:23:29 -07:00
|
|
|
import scala.Some;
|
|
|
|
|
import scala.Right;
|
|
|
|
|
import static akka.dispatch.Futures.future;
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked") public class JavaFutureTests {
|
|
|
|
|
|
|
|
|
|
@Test public void mustBeAbleToMapAFuture() {
|
|
|
|
|
Future f1 = future(new Callable<String>() {
|
|
|
|
|
public String call() {
|
|
|
|
|
return "Hello";
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2011-03-11 10:46:36 -07:00
|
|
|
Future f2 = f1.map(new Function<String, String>() {
|
2011-03-01 15:23:29 -07:00
|
|
|
public String apply(String s) {
|
|
|
|
|
return s + " World";
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
assertEquals(new Some(new Right("Hello World")), f2.await().value());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|