2010-06-23 09:50:55 +02:00
|
|
|
package se.scalablesolutions.akka.api;
|
|
|
|
|
|
2010-07-26 18:47:25 +02:00
|
|
|
import static se.scalablesolutions.akka.actor.TypedActor.link;
|
|
|
|
|
import static se.scalablesolutions.akka.actor.TypedActor.newInstance;
|
2010-06-23 09:50:55 +02:00
|
|
|
|
|
|
|
|
import org.junit.Assert;
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
|
|
import se.scalablesolutions.akka.config.OneForOneStrategy;
|
|
|
|
|
import junit.framework.TestCase;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <p>Small misc tests that do not fit anywhere else and does not require a separate testcase</p>
|
|
|
|
|
*
|
|
|
|
|
* @author johanrask
|
|
|
|
|
*
|
|
|
|
|
*/
|
2010-07-26 18:47:25 +02:00
|
|
|
public class MiscTypedActorTest extends TestCase {
|
2010-06-23 09:50:55 +02:00
|
|
|
|
2010-06-30 16:20:20 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Verifies that both preRestart and postRestart methods are invoked when
|
|
|
|
|
* an actor is restarted
|
|
|
|
|
*/
|
|
|
|
|
public void testFailingPostRestartInvocation() throws InterruptedException {
|
|
|
|
|
SimpleJavaPojo pojo = newInstance(SimpleJavaPojo.class,500);
|
|
|
|
|
SimpleJavaPojo supervisor = newInstance(SimpleJavaPojo.class,500);
|
|
|
|
|
link(supervisor,pojo,new OneForOneStrategy(3, 2000),new Class[]{Throwable.class});
|
|
|
|
|
pojo.throwException();
|
|
|
|
|
Thread.sleep(500);
|
|
|
|
|
Assert.assertTrue(pojo.pre);
|
|
|
|
|
Assert.assertTrue(pojo.post);
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-23 09:50:55 +02:00
|
|
|
}
|