fixed async bug in active object + added AllTests for scala tests

This commit is contained in:
Jonas Boner 2009-07-04 06:38:47 +02:00
parent 800f3bc917
commit d75d769351
14 changed files with 757 additions and 380 deletions

View file

@ -0,0 +1,38 @@
package se.scalablesolutions.akka.api;
import junit.framework.TestCase;
import junit.framework.Test;
import junit.framework.TestSuite;
public class AllTests extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite("All tests");
// Java tests
suite.addTestSuite(InMemoryStateTest.class);
suite.addTestSuite(InMemNestedStateTest.class);
suite.addTestSuite(PersistentStateTest.class);
suite.addTestSuite(PersistentNestedStateTest.class);
suite.addTestSuite(RemoteInMemoryStateTest.class);
suite.addTestSuite(RemotePersistentStateTest.class);
suite.addTestSuite(ActiveObjectGuiceConfiguratorTest.class);
suite.addTestSuite(RestTest.class);
// Scala tests
//suite.addTestSuite(se.scalablesolutions.akka.kernel.SupervisorSpec.class);
/*
suite.addTestSuite(se.scalablesolutions.akka.kernel.RemoteSupervisorSpec.class);
suite.addTestSuite(se.scalablesolutions.akka.kernel.reactor.EventBasedDispatcherTest.class);
suite.addTestSuite(se.scalablesolutions.akka.kernel.reactor.ThreadBasedDispatcherTest.class);
suite.addTestSuite(se.scalablesolutions.akka.kernel.actor.ActorSpec.class);
suite.addTestSuite(se.scalablesolutions.akka.kernel.actor.RemoteActorSpec.class);
suite.addTestSuite(se.scalablesolutions.akka.kernel.actor.InMemStatefulActor.class);
suite.addTestSuite(se.scalablesolutions.akka.kernel.actor.PersistentActor.class);
*/
return suite;
}
public static void main(String[] args) {
junit.textui.TestRunner.run(suite());
}
}

View file

@ -70,8 +70,8 @@ public class PersistentNestedStateTest extends TestCase {
PersistentStatefulNested nested = conf.getActiveObject(PersistentStatefulNested.class);
nested.setVectorState("init"); // set init state
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state", nested); // transactionrequired
assertEquals(3, stateful.getVectorLength()); // BAD: keeps one element since last test
assertEquals(3, nested.getVectorLength());
assertEquals(2, stateful.getVectorLength()); // BAD: keeps one element since last test
assertEquals(2, nested.getVectorLength());
}
public void testVectorShouldRollbackStateForStatefulServerInCaseOfFailure() {

View file

@ -15,8 +15,6 @@ public class RemotePersistentStateTest extends TestCase {
static String messageLog = "";
static {
se.scalablesolutions.akka.kernel.Kernel$.MODULE$.config();
System.setProperty("storage-config", "config");
Kernel.startCassandra();
Kernel.startRemoteService();
}
@ -28,8 +26,8 @@ public class RemotePersistentStateTest extends TestCase {
conf.configureActiveObjects(
new RestartStrategy(new AllForOne(), 3, 5000),
new Component[] {
new Component(PersistentStateful.class, new LifeCycle(new Permanent(), 1000), 1000, new RemoteAddress("localhost", 9999)),
new Component(PersistentFailer.class, new LifeCycle(new Permanent(), 1000), 1000, new RemoteAddress("localhost", 9999))
new Component(PersistentStateful.class, new LifeCycle(new Permanent(), 1000), 1000000, new RemoteAddress("localhost", 9999)),
new Component(PersistentFailer.class, new LifeCycle(new Permanent(), 1000), 1000000, new RemoteAddress("localhost", 9999))
}).supervise();
}
@ -43,13 +41,13 @@ public class RemotePersistentStateTest extends TestCase {
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state"); // transactionrequired
assertEquals("new state", stateful.getMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess"));
}
public void testMapShouldRollbackStateForStatefulServerInCaseOfFailure() {
PersistentStateful stateful = conf.getActiveObject(PersistentStateful.class);
stateful.setMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init"); // set init state
PersistentFailer failer = conf.getActiveObject(PersistentFailer.class);
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer); // call failing transactionrequired method
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "MapShouldRollBack", failer); // call failing transactionrequired method
fail("should have thrown an exception");
} catch (RuntimeException e) {
} // expected
@ -58,22 +56,21 @@ public class RemotePersistentStateTest extends TestCase {
public void testVectorShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
PersistentStateful stateful = conf.getActiveObject(PersistentStateful.class);
stateful.setVectorState("init"); // set init state
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state"); // transactionrequired
assertEquals("init", stateful.getVectorState(0));
assertEquals("new state", stateful.getVectorState(1));
int init = stateful.getVectorLength();
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "VectorShouldNotRollback"); // transactionrequired
assertEquals(init + 1, stateful.getVectorLength());
}
public void testVectorShouldRollbackStateForStatefulServerInCaseOfFailure() {
PersistentStateful stateful = conf.getActiveObject(PersistentStateful.class);
stateful.setVectorState("init"); // set init state
int init = stateful.getVectorLength();
PersistentFailer failer = conf.getActiveObject(PersistentFailer.class);
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer); // call failing transactionrequired method
fail("should have thrown an exception");
} catch (RuntimeException e) {
} // expected
assertEquals("init", stateful.getVectorState(0)); // check that state is == init state
assertEquals(init, stateful.getVectorLength());
}
public void testRefShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
@ -94,4 +91,5 @@ public class RemotePersistentStateTest extends TestCase {
} // expected
assertEquals("init", stateful.getRefState()); // check that state is == init state
}
}

View file

@ -16,6 +16,7 @@ import javax.ws.rs.core.UriBuilder;
import javax.servlet.Servlet;
import junit.framework.TestSuite;
import junit.framework.TestCase;
import org.junit.*;
import static org.junit.Assert.*;
@ -27,7 +28,7 @@ import java.util.HashMap;
import se.scalablesolutions.akka.kernel.config.*;
import static se.scalablesolutions.akka.kernel.config.JavaConfig.*;
public class RestTest extends TestSuite {
public class RestTest extends TestCase {
private static int PORT = 9998;
private static URI URI = UriBuilder.fromUri("http://localhost/").port(PORT).build();