clean up and stabilization, getting ready for M1

This commit is contained in:
jboner 2009-07-12 23:08:17 +02:00
parent 6a65c67ca7
commit 95d598fb66
119 changed files with 1839 additions and 5140 deletions

View file

@ -4,28 +4,20 @@
package se.scalablesolutions.akka.api;
import se.scalablesolutions.akka.annotation.*;
import static se.scalablesolutions.akka.kernel.config.JavaConfig.*;
import se.scalablesolutions.akka.kernel.config.ActiveObjectGuiceConfiguratorForJava;
import se.scalablesolutions.akka.kernel.config.*;
import se.scalablesolutions.akka.kernel.reactor.*;
import se.scalablesolutions.akka.kernel.nio.RemoteServer;
import se.scalablesolutions.akka.kernel.state.TransactionalMap;
import se.scalablesolutions.akka.kernel.state.InMemoryTransactionalMap;
import com.google.inject.Inject;
import com.google.inject.AbstractModule;
import com.google.inject.Scopes;
import junit.framework.TestCase;
import java.util.concurrent.Executor;
import se.scalablesolutions.akka.kernel.reactor.EventBasedThreadPoolDispatcher;
import static se.scalablesolutions.akka.kernel.config.JavaConfig.*;
import java.util.concurrent.ThreadPoolExecutor;
public class ActiveObjectGuiceConfiguratorTest extends TestCase {
static String messageLog = "";
final private ActiveObjectGuiceConfiguratorForJava conf = new ActiveObjectGuiceConfiguratorForJava();
final private se.scalablesolutions.akka.kernel.config.ActiveObjectManager conf = new se.scalablesolutions.akka.kernel.config.ActiveObjectManager();
protected void setUp() {
se.scalablesolutions.akka.kernel.Kernel$.MODULE$.config();
@ -42,7 +34,7 @@ public class ActiveObjectGuiceConfiguratorTest extends TestCase {
protected void configure() {
bind(Ext.class).to(ExtImpl.class).in(Scopes.SINGLETON);
}
}).configureActiveObjects(
}).configure(
new RestartStrategy(new AllForOne(), 3, 5000), new Component[]{
new Component(
Foo.class,
@ -62,30 +54,30 @@ public class ActiveObjectGuiceConfiguratorTest extends TestCase {
public void testGuiceActiveObjectInjection() {
messageLog = "";
Foo foo = conf.getActiveObject(Foo.class);
Bar bar = conf.getActiveObject(Bar.class);
Foo foo = conf.getInstance(Foo.class);
Bar bar = conf.getInstance(Bar.class);
assertEquals(foo.getBar(), bar);
}
public void testGuiceExternalDependencyInjection() {
messageLog = "";
Bar bar = conf.getActiveObject(Bar.class);
Bar bar = conf.getInstance(Bar.class);
Ext ext = conf.getExternalDependency(Ext.class);
assertTrue(bar.getExt().toString().equals(ext.toString()));
}
public void testLookupNonSupervisedInstance() {
try {
String str = conf.getActiveObject(String.class);
String str = conf.getInstance(String.class);
fail("exception should have been thrown");
} catch (Exception e) {
assertEquals("Class [java.lang.String] has not been put under supervision (by passing in the config to the 'configureActiveObjects' and then invoking 'supervise') method", e.getMessage());
assertEquals("Class [java.lang.String] has not been put under supervision (by passing in the config to the 'configure' and then invoking 'supervise') method", e.getMessage());
}
}
public void testActiveObjectInvocation() throws InterruptedException {
messageLog = "";
Foo foo = conf.getActiveObject(Foo.class);
Foo foo = conf.getInstance(Foo.class);
messageLog += foo.foo("foo ");
foo.bar("bar ");
messageLog += "before_bar ";
@ -95,8 +87,8 @@ public class ActiveObjectGuiceConfiguratorTest extends TestCase {
public void testActiveObjectInvocationsInvocation() throws InterruptedException {
messageLog = "";
Foo foo = conf.getActiveObject(Foo.class);
Bar bar = conf.getActiveObject(Bar.class);
Foo foo = conf.getInstance(Foo.class);
Bar bar = conf.getInstance(Bar.class);
messageLog += foo.foo("foo ");
foo.bar("bar ");
messageLog += "before_bar ";
@ -107,7 +99,7 @@ public class ActiveObjectGuiceConfiguratorTest extends TestCase {
public void testForcedTimeout() {
messageLog = "";
Foo foo = conf.getActiveObject(Foo.class);
Foo foo = conf.getInstance(Foo.class);
try {
foo.longRunning();
fail("exception should have been thrown");
@ -117,7 +109,7 @@ public class ActiveObjectGuiceConfiguratorTest extends TestCase {
public void testForcedException() {
messageLog = "";
Foo foo = conf.getActiveObject(Foo.class);
Foo foo = conf.getInstance(Foo.class);
try {
foo.throwsException();
fail("exception should have been thrown");

View file

@ -13,11 +13,11 @@ import junit.framework.TestCase;
public class InMemNestedStateTest extends TestCase {
static String messageLog = "";
final private ActiveObjectGuiceConfiguratorForJava conf = new ActiveObjectGuiceConfiguratorForJava();
final private ActiveObjectManager conf = new ActiveObjectManager();
final private ActiveObjectFactory factory = new ActiveObjectFactory();
protected void setUp() {
conf.configureActiveObjects(
conf.configure(
new RestartStrategy(new AllForOne(), 3, 5000),
new Component[]{
// FIXME: remove string-name, add ctor to only accept target class
@ -34,9 +34,9 @@ public class InMemNestedStateTest extends TestCase {
}
public void testMapShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
InMemStateful stateful = conf.getActiveObject(InMemStateful.class);
InMemStateful stateful = conf.getInstance(InMemStateful.class);
stateful.setMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "init"); // set init state
InMemStatefulNested nested = conf.getActiveObject(InMemStatefulNested.class);
InMemStatefulNested nested = conf.getInstance(InMemStatefulNested.class);
nested.setMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "init"); // set init state
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state", nested); // transactionrequired
assertEquals("new state", stateful.getMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess"));
@ -44,11 +44,11 @@ public class InMemNestedStateTest extends TestCase {
}
public void testMapShouldRollbackStateForStatefulServerInCaseOfFailure() {
InMemStateful stateful = conf.getActiveObject(InMemStateful.class);
InMemStateful stateful = conf.getInstance(InMemStateful.class);
stateful.setMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init"); // set init state
InMemStatefulNested nested = conf.getActiveObject(InMemStatefulNested.class);
InMemStatefulNested nested = conf.getInstance(InMemStatefulNested.class);
nested.setMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init"); // set init state
InMemFailer failer = conf.getActiveObject(InMemFailer.class);
InMemFailer failer = conf.getInstance(InMemFailer.class);
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", nested, failer); // call failing transactionrequired method
fail("should have thrown an exception");
@ -59,9 +59,9 @@ public class InMemNestedStateTest extends TestCase {
}
public void testVectorShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
InMemStateful stateful = conf.getActiveObject(InMemStateful.class);
InMemStateful stateful = conf.getInstance(InMemStateful.class);
stateful.setVectorState("init"); // set init state
InMemStatefulNested nested = conf.getActiveObject(InMemStatefulNested.class);
InMemStatefulNested nested = conf.getInstance(InMemStatefulNested.class);
nested.setVectorState("init"); // set init state
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state", nested); // transactionrequired
assertEquals("new state", stateful.getVectorState());
@ -69,11 +69,11 @@ public class InMemNestedStateTest extends TestCase {
}
public void testVectorShouldRollbackStateForStatefulServerInCaseOfFailure() {
InMemStateful stateful = conf.getActiveObject(InMemStateful.class);
InMemStateful stateful = conf.getInstance(InMemStateful.class);
stateful.setVectorState("init"); // set init state
InMemStatefulNested nested = conf.getActiveObject(InMemStatefulNested.class);
InMemStatefulNested nested = conf.getInstance(InMemStatefulNested.class);
nested.setVectorState("init"); // set init state
InMemFailer failer = conf.getActiveObject(InMemFailer.class);
InMemFailer failer = conf.getInstance(InMemFailer.class);
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", nested, failer); // call failing transactionrequired method
fail("should have thrown an exception");
@ -84,8 +84,8 @@ public class InMemNestedStateTest extends TestCase {
}
public void testRefShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
InMemStateful stateful = conf.getActiveObject(InMemStateful.class);
InMemStatefulNested nested = conf.getActiveObject(InMemStatefulNested.class);
InMemStateful stateful = conf.getInstance(InMemStateful.class);
InMemStatefulNested nested = conf.getInstance(InMemStatefulNested.class);
stateful.setRefState("init"); // set init state
nested.setRefState("init"); // set init state
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state", nested); // transactionrequired
@ -94,11 +94,11 @@ public class InMemNestedStateTest extends TestCase {
}
public void testRefShouldRollbackStateForStatefulServerInCaseOfFailure() {
InMemStateful stateful = conf.getActiveObject(InMemStateful.class);
InMemStatefulNested nested = conf.getActiveObject(InMemStatefulNested.class);
InMemStateful stateful = conf.getInstance(InMemStateful.class);
InMemStatefulNested nested = conf.getInstance(InMemStatefulNested.class);
stateful.setRefState("init"); // set init state
nested.setRefState("init"); // set init state
InMemFailer failer = conf.getActiveObject(InMemFailer.class);
InMemFailer failer = conf.getInstance(InMemFailer.class);
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", nested, failer); // call failing transactionrequired method
fail("should have thrown an exception");

View file

@ -14,12 +14,12 @@ import se.scalablesolutions.akka.kernel.Kernel;
public class InMemoryStateTest extends TestCase {
static String messageLog = "";
final private ActiveObjectGuiceConfiguratorForJava conf = new ActiveObjectGuiceConfiguratorForJava();
final private ActiveObjectManager conf = new ActiveObjectManager();
protected void setUp() {
se.scalablesolutions.akka.kernel.Kernel$.MODULE$.config();
conf.configureActiveObjects(
conf.configure(
new RestartStrategy(new AllForOne(), 3, 5000),
new Component[]{
// FIXME: remove string-name, add ctor to only accept target class
@ -38,16 +38,16 @@ public class InMemoryStateTest extends TestCase {
}
public void testMapShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
InMemStateful stateful = conf.getActiveObject(InMemStateful.class);
InMemStateful stateful = conf.getInstance(InMemStateful.class);
stateful.setMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "init"); // set init state
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state"); // transactionrequired
assertEquals("new state", stateful.getMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess"));
}
public void testMapShouldRollbackStateForStatefulServerInCaseOfFailure() {
InMemStateful stateful = conf.getActiveObject(InMemStateful.class);
InMemStateful stateful = conf.getInstance(InMemStateful.class);
stateful.setMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init"); // set init state
InMemFailer failer = conf.getActiveObject(InMemFailer.class);
InMemFailer failer = conf.getInstance(InMemFailer.class);
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer); // call failing transactionrequired method
fail("should have thrown an exception");
@ -57,7 +57,7 @@ public class InMemoryStateTest extends TestCase {
}
public void testVectorShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
InMemStateful stateful = conf.getActiveObject(InMemStateful.class);
InMemStateful stateful = conf.getInstance(InMemStateful.class);
stateful.setVectorState("init"); // set init state
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state"); // transactionrequired
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state"); // to trigger commit
@ -65,9 +65,9 @@ public class InMemoryStateTest extends TestCase {
}
public void testVectorShouldRollbackStateForStatefulServerInCaseOfFailure() {
InMemStateful stateful = conf.getActiveObject(InMemStateful.class);
InMemStateful stateful = conf.getInstance(InMemStateful.class);
stateful.setVectorState("init"); // set init state
InMemFailer failer = conf.getActiveObject(InMemFailer.class);
InMemFailer failer = conf.getInstance(InMemFailer.class);
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer); // call failing transactionrequired method
fail("should have thrown an exception");
@ -77,7 +77,7 @@ public class InMemoryStateTest extends TestCase {
}
public void testRefShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
InMemStateful stateful = conf.getActiveObject(InMemStateful.class);
InMemStateful stateful = conf.getInstance(InMemStateful.class);
stateful.setRefState("init"); // set init state
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state"); // transactionrequired
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state"); // to trigger commit
@ -85,9 +85,9 @@ public class InMemoryStateTest extends TestCase {
}
public void testRefShouldRollbackStateForStatefulServerInCaseOfFailure() {
InMemStateful stateful = conf.getActiveObject(InMemStateful.class);
InMemStateful stateful = conf.getInstance(InMemStateful.class);
stateful.setRefState("init"); // set init state
InMemFailer failer = conf.getActiveObject(InMemFailer.class);
InMemFailer failer = conf.getInstance(InMemFailer.class);
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer); // call failing transactionrequired method
fail("should have thrown an exception");
@ -97,9 +97,9 @@ public class InMemoryStateTest extends TestCase {
}
/*
public void testNestedNonTransactionalMethodHangs() {
InMemStateful stateful = conf.getActiveObject(InMemStateful.class);
InMemStateful stateful = conf.getInstance(InMemStateful.class);
stateful.setMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init"); // set init state
InMemFailer failer = conf.getActiveObject(InMemFailer.class);
InMemFailer failer = conf.getInstance(InMemFailer.class);
try {
stateful.thisMethodHangs("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer); // call failing transactionrequired method
fail("should have thrown an exception");
@ -110,10 +110,10 @@ public class InMemoryStateTest extends TestCase {
*/
// public void testShouldRollbackStateForStatefulServerInCaseOfMessageClash()
// {
// InMemStateful stateful = conf.getActiveObject(InMemStateful.class);
// InMemStateful stateful = conf.getInstance(InMemStateful.class);
// stateful.setState("stateful", "init"); // set init state
//
// InMemClasher clasher = conf.getActiveObject(InMemClasher.class);
// InMemClasher clasher = conf.getInstance(InMemClasher.class);
// clasher.setState("clasher", "init"); // set init state
//
// // try {

View file

@ -14,12 +14,12 @@ import junit.framework.TestCase;
public class PersistentNestedStateTest extends TestCase {
static String messageLog = "";
final private ActiveObjectGuiceConfiguratorForJava conf = new ActiveObjectGuiceConfiguratorForJava();
final private ActiveObjectManager conf = new ActiveObjectManager();
final private ActiveObjectFactory factory = new ActiveObjectFactory();
protected void setUp() {
PersistenceManager.init();
conf.configureActiveObjects(
conf.configure(
new RestartStrategy(new AllForOne(), 3, 5000),
new Component[]{
// FIXME: remove string-name, add ctor to only accept target class
@ -35,8 +35,8 @@ public class PersistentNestedStateTest extends TestCase {
}
public void testMapShouldNotRollbackStateForStatefulServerInCaseOfSuccess() throws Exception {
PersistentStateful stateful = conf.getActiveObject(PersistentStateful.class);
PersistentStatefulNested nested = conf.getActiveObject(PersistentStatefulNested.class);
PersistentStateful stateful = conf.getInstance(PersistentStateful.class);
PersistentStatefulNested nested = conf.getInstance(PersistentStatefulNested.class);
stateful.setMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "init"); // set init state
nested.setMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "init"); // set init state
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state", nested); // transactional
@ -45,11 +45,11 @@ public class PersistentNestedStateTest extends TestCase {
}
public void testMapShouldRollbackStateForStatefulServerInCaseOfFailure() {
PersistentStateful stateful = conf.getActiveObject(PersistentStateful.class);
PersistentStateful stateful = conf.getInstance(PersistentStateful.class);
stateful.setMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init"); // set init state
PersistentStatefulNested nested = conf.getActiveObject(PersistentStatefulNested.class);
PersistentStatefulNested nested = conf.getInstance(PersistentStatefulNested.class);
nested.setMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init"); // set init state
PersistentFailer failer = conf.getActiveObject(PersistentFailer.class);
PersistentFailer failer = conf.getInstance(PersistentFailer.class);
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", nested, failer); // call failing transactional method
fail("should have thrown an exception");
@ -60,9 +60,9 @@ public class PersistentNestedStateTest extends TestCase {
}
public void testVectorShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
PersistentStateful stateful = conf.getActiveObject(PersistentStateful.class);
PersistentStateful stateful = conf.getInstance(PersistentStateful.class);
stateful.setVectorState("init"); // set init state
PersistentStatefulNested nested = conf.getActiveObject(PersistentStatefulNested.class);
PersistentStatefulNested nested = conf.getInstance(PersistentStatefulNested.class);
nested.setVectorState("init"); // set init state
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state", nested); // transactional
assertEquals(2, stateful.getVectorLength()); // BAD: keeps one element since last test
@ -70,11 +70,11 @@ public class PersistentNestedStateTest extends TestCase {
}
public void testVectorShouldRollbackStateForStatefulServerInCaseOfFailure() {
PersistentStateful stateful = conf.getActiveObject(PersistentStateful.class);
PersistentStateful stateful = conf.getInstance(PersistentStateful.class);
stateful.setVectorState("init"); // set init state
PersistentStatefulNested nested = conf.getActiveObject(PersistentStatefulNested.class);
PersistentStatefulNested nested = conf.getInstance(PersistentStatefulNested.class);
nested.setVectorState("init"); // set init state
PersistentFailer failer = conf.getActiveObject(PersistentFailer.class);
PersistentFailer failer = conf.getInstance(PersistentFailer.class);
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", nested, failer); // call failing transactional method
fail("should have thrown an exception");
@ -85,8 +85,8 @@ public class PersistentNestedStateTest extends TestCase {
}
public void testRefShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
PersistentStateful stateful = conf.getActiveObject(PersistentStateful.class);
PersistentStatefulNested nested = conf.getActiveObject(PersistentStatefulNested.class);
PersistentStateful stateful = conf.getInstance(PersistentStateful.class);
PersistentStatefulNested nested = conf.getInstance(PersistentStatefulNested.class);
stateful.setRefState("init"); // set init state
nested.setRefState("init"); // set init state
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state", nested); // transactional
@ -95,11 +95,11 @@ public class PersistentNestedStateTest extends TestCase {
}
public void testRefShouldRollbackStateForStatefulServerInCaseOfFailure() {
PersistentStateful stateful = conf.getActiveObject(PersistentStateful.class);
PersistentStatefulNested nested = conf.getActiveObject(PersistentStatefulNested.class);
PersistentStateful stateful = conf.getInstance(PersistentStateful.class);
PersistentStatefulNested nested = conf.getInstance(PersistentStatefulNested.class);
stateful.setRefState("init"); // set init state
nested.setRefState("init"); // set init state
PersistentFailer failer = conf.getActiveObject(PersistentFailer.class);
PersistentFailer failer = conf.getInstance(PersistentFailer.class);
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", nested, failer); // call failing transactional method
fail("should have thrown an exception");

View file

@ -14,11 +14,11 @@ import junit.framework.TestCase;
public class PersistentStateTest extends TestCase {
static String messageLog = "";
final private ActiveObjectGuiceConfiguratorForJava conf = new ActiveObjectGuiceConfiguratorForJava();
final private ActiveObjectManager conf = new ActiveObjectManager();
protected void setUp() {
PersistenceManager.init();
conf.configureActiveObjects(
conf.configure(
new RestartStrategy(new AllForOne(), 3, 5000),
new Component[] {
new Component(PersistentStateful.class, new LifeCycle(new Permanent(), 1000), 10000000),
@ -32,16 +32,16 @@ public class PersistentStateTest extends TestCase {
}
public void testShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
PersistentStateful stateful = conf.getActiveObject(PersistentStateful.class);
PersistentStateful stateful = conf.getInstance(PersistentStateful.class);
stateful.setMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "init"); // set init state
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state"); // transactionrequired
assertEquals("new state", stateful.getMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess"));
}
public void testMapShouldRollbackStateForStatefulServerInCaseOfFailure() {
PersistentStateful stateful = conf.getActiveObject(PersistentStateful.class);
PersistentStateful stateful = conf.getInstance(PersistentStateful.class);
stateful.setMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init"); // set init state
PersistentFailer failer = conf.getActiveObject(PersistentFailer.class);
PersistentFailer failer = conf.getInstance(PersistentFailer.class);
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer); // call failing transactionrequired method
fail("should have thrown an exception");
@ -51,7 +51,7 @@ public class PersistentStateTest extends TestCase {
}
public void testVectorShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
PersistentStateful stateful = conf.getActiveObject(PersistentStateful.class);
PersistentStateful stateful = conf.getInstance(PersistentStateful.class);
stateful.setVectorState("init"); // set init state
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state"); // transactionrequired
assertEquals("init", stateful.getVectorState(0));
@ -59,9 +59,9 @@ public class PersistentStateTest extends TestCase {
}
public void testVectorShouldRollbackStateForStatefulServerInCaseOfFailure() {
PersistentStateful stateful = conf.getActiveObject(PersistentStateful.class);
PersistentStateful stateful = conf.getInstance(PersistentStateful.class);
stateful.setVectorState("init"); // set init state
PersistentFailer failer = conf.getActiveObject(PersistentFailer.class);
PersistentFailer failer = conf.getInstance(PersistentFailer.class);
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer); // call failing transactionrequired method
fail("should have thrown an exception");
@ -71,16 +71,16 @@ public class PersistentStateTest extends TestCase {
}
public void testRefShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
PersistentStateful stateful = conf.getActiveObject(PersistentStateful.class);
PersistentStateful stateful = conf.getInstance(PersistentStateful.class);
stateful.setRefState("init"); // set init state
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state"); // transactionrequired
assertEquals("new state", stateful.getRefState());
}
public void testRefShouldRollbackStateForStatefulServerInCaseOfFailure() {
PersistentStateful stateful = conf.getActiveObject(PersistentStateful.class);
PersistentStateful stateful = conf.getInstance(PersistentStateful.class);
stateful.setRefState("init"); // set init state
PersistentFailer failer = conf.getActiveObject(PersistentFailer.class);
PersistentFailer failer = conf.getInstance(PersistentFailer.class);
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer); // call failing transactionrequired method
fail("should have thrown an exception");

View file

@ -5,7 +5,6 @@
package se.scalablesolutions.akka.api;
import se.scalablesolutions.akka.kernel.actor.ActiveObjectFactory;
import se.scalablesolutions.akka.kernel.config.ActiveObjectGuiceConfiguratorForJava;
import se.scalablesolutions.akka.kernel.nio.RemoteServer;
import junit.framework.TestCase;
@ -22,7 +21,7 @@ public class RemoteInMemoryStateTest extends TestCase {
try { Thread.currentThread().sleep(1000); } catch (Exception e) {}
se.scalablesolutions.akka.kernel.Kernel$.MODULE$.config();
}
final private ActiveObjectGuiceConfiguratorForJava conf = new ActiveObjectGuiceConfiguratorForJava();
final private se.scalablesolutions.akka.kernel.config.ActiveObjectManager conf = new se.scalablesolutions.akka.kernel.config.ActiveObjectManager();
final private ActiveObjectFactory factory = new ActiveObjectFactory();
protected void tearDown() {
@ -39,7 +38,7 @@ public class RemoteInMemoryStateTest extends TestCase {
public void testMapShouldRollbackStateForStatefulServerInCaseOfFailure() {
InMemStateful stateful = factory.newRemoteInstance(InMemStateful.class, 1000, "localhost", 9999);
stateful.setMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init"); // set init state
InMemFailer failer = factory.newRemoteInstance(InMemFailer.class, 1000, "localhost", 9999); //conf.getActiveObject(InMemFailer.class);
InMemFailer failer = factory.newRemoteInstance(InMemFailer.class, 1000, "localhost", 9999); //conf.getInstance(InMemFailer.class);
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer); // call failing transactionrequired method
fail("should have thrown an exception");
@ -58,7 +57,7 @@ public class RemoteInMemoryStateTest extends TestCase {
public void testVectorShouldRollbackStateForStatefulServerInCaseOfFailure() {
InMemStateful stateful = factory.newRemoteInstance(InMemStateful.class, 1000, "localhost", 9999);
stateful.setVectorState("init"); // set init state
InMemFailer failer = factory.newRemoteInstance(InMemFailer.class, 1000, "localhost", 9999); //conf.getActiveObject(InMemFailer.class);
InMemFailer failer = factory.newRemoteInstance(InMemFailer.class, 1000, "localhost", 9999); //conf.getInstance(InMemFailer.class);
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer); // call failing transactionrequired method
fail("should have thrown an exception");
@ -77,7 +76,7 @@ public class RemoteInMemoryStateTest extends TestCase {
public void testRefShouldRollbackStateForStatefulServerInCaseOfFailure() {
InMemStateful stateful = factory.newRemoteInstance(InMemStateful.class, 1000, "localhost", 9999);
stateful.setRefState("init"); // set init state
InMemFailer failer = factory.newRemoteInstance(InMemFailer.class, 1000, "localhost", 9999); //conf.getActiveObject(InMemFailer.class);
InMemFailer failer = factory.newRemoteInstance(InMemFailer.class, 1000, "localhost", 9999); //conf.getInstance(InMemFailer.class);
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer); // call failing transactionrequired method
fail("should have thrown an exception");
@ -87,9 +86,9 @@ public class RemoteInMemoryStateTest extends TestCase {
}
/*
public void testNestedNonTransactionalMethodHangs() {
InMemStateful stateful = conf.getActiveObject(InMemStateful.class);
InMemStateful stateful = conf.getInstance(InMemStateful.class);
stateful.setMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init"); // set init state
InMemFailer failer = conf.getActiveObject(InMemFailer.class);
InMemFailer failer = conf.getInstance(InMemFailer.class);
try {
stateful.thisMethodHangs("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer); // call failing transactionrequired method
fail("should have thrown an exception");
@ -100,10 +99,10 @@ public class RemoteInMemoryStateTest extends TestCase {
*/
// public void testShouldRollbackStateForStatefulServerInCaseOfMessageClash()
// {
// InMemStateful stateful = conf.getActiveObject(InMemStateful.class);
// InMemStateful stateful = conf.getInstance(InMemStateful.class);
// stateful.setState("stateful", "init"); // set init state
//
// InMemClasher clasher = conf.getActiveObject(InMemClasher.class);
// InMemClasher clasher = conf.getInstance(InMemClasher.class);
// clasher.setState("clasher", "init"); // set init state
//
// // try {

View file

@ -14,11 +14,11 @@ import junit.framework.TestCase;
public class RemotePersistentStateTest extends TestCase {
static String messageLog = "";
final private ActiveObjectGuiceConfiguratorForJava conf = new ActiveObjectGuiceConfiguratorForJava();
final private ActiveObjectManager conf = new ActiveObjectManager();
protected void setUp() {
PersistenceManager.init();
conf.configureActiveObjects(
conf.configure(
new RestartStrategy(new AllForOne(), 3, 5000),
new Component[] {
new Component(PersistentStateful.class, new LifeCycle(new Permanent(), 1000), 1000000, new RemoteAddress("localhost", 9999)),
@ -31,16 +31,16 @@ public class RemotePersistentStateTest extends TestCase {
}
public void testShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
PersistentStateful stateful = conf.getActiveObject(PersistentStateful.class);
PersistentStateful stateful = conf.getInstance(PersistentStateful.class);
stateful.setMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "init"); // set init state
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state"); // transactionrequired
assertEquals("new state", stateful.getMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess"));
}
public void testMapShouldRollbackStateForStatefulServerInCaseOfFailure() {
PersistentStateful stateful = conf.getActiveObject(PersistentStateful.class);
PersistentStateful stateful = conf.getInstance(PersistentStateful.class);
stateful.setMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init"); // set init state
PersistentFailer failer = conf.getActiveObject(PersistentFailer.class);
PersistentFailer failer = conf.getInstance(PersistentFailer.class);
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "MapShouldRollBack", failer); // call failing transactionrequired method
fail("should have thrown an exception");
@ -50,16 +50,16 @@ public class RemotePersistentStateTest extends TestCase {
}
public void testVectorShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
PersistentStateful stateful = conf.getActiveObject(PersistentStateful.class);
PersistentStateful stateful = conf.getInstance(PersistentStateful.class);
int init = stateful.getVectorLength();
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "VectorShouldNotRollback"); // transactionrequired
assertEquals(init + 1, stateful.getVectorLength());
}
public void testVectorShouldRollbackStateForStatefulServerInCaseOfFailure() {
PersistentStateful stateful = conf.getActiveObject(PersistentStateful.class);
PersistentStateful stateful = conf.getInstance(PersistentStateful.class);
int init = stateful.getVectorLength();
PersistentFailer failer = conf.getActiveObject(PersistentFailer.class);
PersistentFailer failer = conf.getInstance(PersistentFailer.class);
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer); // call failing transactionrequired method
fail("should have thrown an exception");
@ -69,16 +69,16 @@ public class RemotePersistentStateTest extends TestCase {
}
public void testRefShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
PersistentStateful stateful = conf.getActiveObject(PersistentStateful.class);
PersistentStateful stateful = conf.getInstance(PersistentStateful.class);
stateful.setRefState("init"); // set init state
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state"); // transactionrequired
assertEquals("new state", stateful.getRefState());
}
public void testRefShouldRollbackStateForStatefulServerInCaseOfFailure() {
PersistentStateful stateful = conf.getActiveObject(PersistentStateful.class);
PersistentStateful stateful = conf.getInstance(PersistentStateful.class);
stateful.setRefState("init"); // set init state
PersistentFailer failer = conf.getActiveObject(PersistentFailer.class);
PersistentFailer failer = conf.getInstance(PersistentFailer.class);
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer); // call failing transactionrequired method
fail("should have thrown an exception");

View file

@ -28,18 +28,17 @@ import java.util.HashMap;
import se.scalablesolutions.akka.kernel.config.*;
import static se.scalablesolutions.akka.kernel.config.JavaConfig.*;
/*
public class RestTest extends TestCase {
private static int PORT = 9998;
private static URI URI = UriBuilder.fromUri("http://localhost/").port(PORT).build();
private static SelectorThread selector = null;
private static ActiveObjectGuiceConfiguratorForJava conf = new ActiveObjectGuiceConfiguratorForJava();
private static ActiveObjectManager conf = new ActiveObjectManager();
@BeforeClass
protected void setUp() {
se.scalablesolutions.akka.kernel.Kernel$.MODULE$.config();
conf.configureActiveObjects(
conf.configure(
new RestartStrategy(new AllForOne(), 3, 5000),
new Component[] {
new Component(
@ -50,6 +49,12 @@ public class RestTest extends TestCase {
selector = startJersey();
}
public void testSimpleRequest() {
assertTrue(true);
}
/*
@Test
public void testSimpleRequest() throws IOException, InstantiationException {
selector.listen();
@ -59,11 +64,11 @@ public class RestTest extends TestCase {
assertEquals("hello foo", responseMsg);
selector.stopEndpoint();
}
*/
private static SelectorThread startJersey() {
try {
Servlet servlet = new se.scalablesolutions.akka.kernel.jersey.AkkaServlet();
ServletAdapter adapter = new ServletAdapter();
Servlet servlet = se.scalablesolutions.akka.kernel.jersey.AkkaServlet.class.newInstance();
adapter.setServletInstance(servlet);
adapter.setContextPath(URI.getPath());
return createGrizzlySelector(adapter, URI, PORT);
@ -83,4 +88,4 @@ public class RestTest extends TestCase {
return selectorThread;
}
}
*/