Rewrote new executor based event-driven dispatcher to use actor-specific mailboxes
This commit is contained in:
parent
2b2f03729e
commit
7ea53e1c44
21 changed files with 511 additions and 622 deletions
|
|
@ -12,8 +12,7 @@ import junit.framework.TestCase;
|
|||
import se.scalablesolutions.akka.Config;
|
||||
import se.scalablesolutions.akka.config.ActiveObjectConfigurator;
|
||||
import static se.scalablesolutions.akka.config.JavaConfig.*;
|
||||
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import se.scalablesolutions.akka.dispatch.*;
|
||||
|
||||
public class ActiveObjectGuiceConfiguratorTest extends TestCase {
|
||||
static String messageLog = "";
|
||||
|
|
@ -22,14 +21,7 @@ public class ActiveObjectGuiceConfiguratorTest extends TestCase {
|
|||
|
||||
protected void setUp() {
|
||||
Config.config();
|
||||
se.scalablesolutions.akka.dispatch.ReactorBasedThreadPoolDispatcher dispatcher = new se.scalablesolutions.akka.dispatch.ReactorBasedThreadPoolDispatcher("name");
|
||||
dispatcher
|
||||
.withNewThreadPoolWithBoundedBlockingQueue(100)
|
||||
.setCorePoolSize(16)
|
||||
.setMaxPoolSize(128)
|
||||
.setKeepAliveTimeInMillis(60000)
|
||||
.setRejectionPolicy(new ThreadPoolExecutor.CallerRunsPolicy())
|
||||
.buildThreadPool();
|
||||
MessageDispatcher dispatcher = Dispatchers.newExecutorBasedEventDrivenDispatcher("test");
|
||||
|
||||
conf.addExternalGuiceModule(new AbstractModule() {
|
||||
protected void configure() {
|
||||
|
|
|
|||
|
|
@ -37,10 +37,14 @@ public class InMemNestedStateTest extends TestCase {
|
|||
public void testMapShouldNotRollbackStateForStatefulServerInCaseOfSuccess() throws Exception {
|
||||
InMemStateful stateful = conf.getInstance(InMemStateful.class);
|
||||
stateful.setMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "init"); // set init state
|
||||
Thread.sleep(100);
|
||||
InMemStatefulNested nested = conf.getInstance(InMemStatefulNested.class);
|
||||
nested.setMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "init"); // set init state
|
||||
Thread.sleep(100);
|
||||
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state", nested); // transactionrequired
|
||||
Thread.sleep(100);
|
||||
assertEquals("new state", stateful.getMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess"));
|
||||
Thread.sleep(100);
|
||||
assertEquals("new state", nested.getMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess"));
|
||||
}
|
||||
|
||||
|
|
@ -66,10 +70,15 @@ public class InMemNestedStateTest extends TestCase {
|
|||
public void testVectorShouldNotRollbackStateForStatefulServerInCaseOfSuccess() throws Exception {
|
||||
InMemStateful stateful = conf.getInstance(InMemStateful.class);
|
||||
stateful.setVectorState("init"); // set init state
|
||||
Thread.sleep(100);
|
||||
InMemStatefulNested nested = conf.getInstance(InMemStatefulNested.class);
|
||||
Thread.sleep(100);
|
||||
nested.setVectorState("init"); // set init state
|
||||
Thread.sleep(100);
|
||||
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state", nested); // transactionrequired
|
||||
Thread.sleep(100);
|
||||
assertEquals("new state", stateful.getVectorState());
|
||||
Thread.sleep(100);
|
||||
assertEquals("new state", nested.getVectorState());
|
||||
}
|
||||
|
||||
|
|
@ -96,9 +105,13 @@ public class InMemNestedStateTest extends TestCase {
|
|||
InMemStateful stateful = conf.getInstance(InMemStateful.class);
|
||||
InMemStatefulNested nested = conf.getInstance(InMemStatefulNested.class);
|
||||
stateful.setRefState("init"); // set init state
|
||||
Thread.sleep(100);
|
||||
nested.setRefState("init"); // set init state
|
||||
Thread.sleep(100);
|
||||
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state", nested); // transactionrequired
|
||||
Thread.sleep(100);
|
||||
assertEquals("new state", stateful.getRefState());
|
||||
Thread.sleep(100);
|
||||
assertEquals("new state", nested.getRefState());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue