!act,doc,rem,tes 3823 remove deprecated Props methods
- rewrite deprecated usages to their recommended counterparts - TestActorRef now verifies mailbox requirements - CallingThreadMailbox now exposes proper messageQueue type for inspection
This commit is contained in:
parent
780831469c
commit
5bcb750441
17 changed files with 68 additions and 229 deletions
|
|
@ -11,14 +11,17 @@ import static akka.pattern.Patterns.pipe;
|
|||
import static akka.pattern.Patterns.gracefulStop;
|
||||
//#import-gracefulStop
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import akka.testkit.AkkaJUnitActorSystemResource;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
//#import-gracefulStop
|
||||
import scala.concurrent.Await;
|
||||
//#import-ask
|
||||
|
|
@ -119,43 +122,6 @@ public class UntypedActorDocTest {
|
|||
}
|
||||
//#parametric-creator
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void createPropsDeprecated() {
|
||||
//#creating-props-deprecated
|
||||
// DEPRECATED: encourages to close over enclosing class
|
||||
final Props props1 = new Props(new UntypedActorFactory() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override
|
||||
public UntypedActor create() throws Exception {
|
||||
return new MyUntypedActor();
|
||||
}
|
||||
});
|
||||
|
||||
// DEPRECATED: encourages to close over enclosing class
|
||||
final Props props2 = new Props().withCreator(new UntypedActorFactory() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override
|
||||
public UntypedActor create() throws Exception {
|
||||
return new MyUntypedActor();
|
||||
}
|
||||
});
|
||||
|
||||
// these are DEPRECATED due to duplicate functionality with Props.create()
|
||||
final Props props3 = new Props(MyUntypedActor.class);
|
||||
final Props props4 = new Props().withCreator(MyUntypedActor.class);
|
||||
//#creating-props-deprecated
|
||||
new JavaTestKit(system) {
|
||||
{
|
||||
for (Props props : new Props[] { props1, props2, props3, props4 }) {
|
||||
final ActorRef a = system.actorOf(props);
|
||||
a.tell("hello", getRef());
|
||||
expectMsgEquals("hello");
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void systemActorOf() {
|
||||
//#system-actorOf
|
||||
|
|
@ -538,8 +504,15 @@ public class UntypedActorDocTest {
|
|||
* @return a Props for creating this actor, which can then be further configured
|
||||
* (e.g. calling `.withDispatcher()` on it)
|
||||
*/
|
||||
public static Props props(int magicNumber) {
|
||||
return Props.create(DemoActor.class, magicNumber);
|
||||
public static Props props(final int magicNumber) {
|
||||
return Props.create(new Creator<DemoActor>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public DemoActor create() throws Exception {
|
||||
return new DemoActor(magicNumber);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
final int magicNumber;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue