Add first test of Future in Java
This commit is contained in:
parent
fbd3bd635c
commit
03809572f8
2 changed files with 33 additions and 2 deletions
29
akka-actor/src/test/java/akka/dispatch/JavaFutureTests.java
Normal file
29
akka-actor/src/test/java/akka/dispatch/JavaFutureTests.java
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
package akka.dispatch;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
import java.util.concurrent.Callable;
|
||||
import scala.runtime.AbstractFunction1;
|
||||
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";
|
||||
}
|
||||
});
|
||||
|
||||
Future f2 = f1.map(new AbstractFunction1<String, String>() {
|
||||
public String apply(String s) {
|
||||
return s + " World";
|
||||
}
|
||||
});
|
||||
|
||||
assertEquals(new Some(new Right("Hello World")), f2.await().value());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package akka.actor
|
||||
package akka.dispatch
|
||||
|
||||
import org.scalatest.junit.JUnitSuite
|
||||
import org.junit.Test
|
||||
import akka.actor.{ Actor, ActorRef }
|
||||
import Actor._
|
||||
import org.multiverse.api.latches.StandardLatch
|
||||
import akka.dispatch. {Future, Futures}
|
||||
import java.util.concurrent. {TimeUnit, CountDownLatch}
|
||||
|
||||
object FutureSpec {
|
||||
|
|
@ -31,6 +31,8 @@ object FutureSpec {
|
|||
}
|
||||
}
|
||||
|
||||
class JavaFutureSpec extends JavaFutureTests with JUnitSuite
|
||||
|
||||
class FutureSpec extends JUnitSuite {
|
||||
import FutureSpec._
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue