fixed cassandra persistenc STM tests + added generic Map and Seq traits to Transactional datastructures
This commit is contained in:
parent
1a06a67cfc
commit
9349bc3ad8
18 changed files with 689 additions and 439 deletions
|
|
@ -51,7 +51,10 @@
|
|||
<classpathentry kind="var" path="M2_REPO/com/facebook/thrift/1.0/thrift-1.0.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/util-java"/>
|
||||
<classpathentry kind="lib" path="/akka-kernel/target/akka-kernel-0.1.jar"/>
|
||||
<classpathentry kind="lib" path="/akka-kernel/target/akka-kernel-0.1.jar" sourcepath="/akka-kernel/src/main/scala"/>
|
||||
<classpathentry kind="lib" path="/util-java/target/akka-util-java-0.1.jar"/>
|
||||
<classpathentry kind="lib" path="/Users/jboner/src/scala/akka/lib/commons-collections-3.2.1.jar"/>
|
||||
<classpathentry kind="lib" path="/Users/jboner/src/scala/akka/lib/commons-lang-2.4.jar"/>
|
||||
<classpathentry kind="lib" path="/Users/jboner/src/scala/akka/lib/high-scale-lib.jar"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
|
|
|||
5
api-java/.settings/org.eclipse.jdt.core.prefs
Normal file
5
api-java/.settings/org.eclipse.jdt.core.prefs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#Wed May 13 10:49:41 CEST 2009
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
org.eclipse.jdt.core.compiler.source=1.5
|
||||
|
|
@ -57,6 +57,16 @@
|
|||
<orderEntry type="library" name="Maven: org.jmock:jmock:2.4.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-library:1.1" level="project" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="file://$MODULE_DIR$/../config" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="library" name="Akka Runtime Libs" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ public class ActiveObjectGuiceConfiguratorTest extends TestCase {
|
|||
String str = conf.getActiveObject("string");
|
||||
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 supervise() method", e.getMessage());
|
||||
assertEquals("Class string has not been put under supervision (by passing in the config to the supervise() method", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ class InMemStatefulImpl implements InMemStateful {
|
|||
private TransactionalMap<String, String> state = new InMemoryTransactionalMap<String, String>();
|
||||
|
||||
public String getState(String key) {
|
||||
return state.get(key);
|
||||
return state.get(key).get();
|
||||
}
|
||||
|
||||
public void setState(String key, String msg) {
|
||||
|
|
@ -158,7 +158,7 @@ class InMemClasherImpl implements InMemClasher {
|
|||
private TransactionalMap<String, Object> state = new InMemoryTransactionalMap<String, Object>();
|
||||
|
||||
public String getState(String key) {
|
||||
return (String) state.get(key);
|
||||
return (String) state.get(key).get();
|
||||
}
|
||||
|
||||
public void setState(String key, String msg) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,13 @@ package se.scalablesolutions.akka.api;
|
|||
|
||||
import se.scalablesolutions.akka.annotation.*;
|
||||
import se.scalablesolutions.akka.kernel.config.*;
|
||||
import se.scalablesolutions.akka.kernel.config.JavaConfig.AllForOne;
|
||||
import se.scalablesolutions.akka.kernel.config.JavaConfig.Component;
|
||||
import se.scalablesolutions.akka.kernel.config.JavaConfig.LifeCycle;
|
||||
import se.scalablesolutions.akka.kernel.config.JavaConfig.Permanent;
|
||||
import se.scalablesolutions.akka.kernel.config.JavaConfig.RestartStrategy;
|
||||
import static se.scalablesolutions.akka.kernel.config.JavaConfig.*;
|
||||
import se.scalablesolutions.akka.kernel.Kernel;
|
||||
import se.scalablesolutions.akka.kernel.TransactionalMap;
|
||||
import se.scalablesolutions.akka.kernel.CassandraPersistentTransactionalMap;
|
||||
|
||||
|
|
@ -15,26 +21,43 @@ import junit.framework.TestCase;
|
|||
public class PersistentStateTest extends TestCase {
|
||||
static String messageLog = "";
|
||||
|
||||
static {
|
||||
Kernel.startCassandra();
|
||||
}
|
||||
final private ActiveObjectGuiceConfiguratorForJava conf = new ActiveObjectGuiceConfiguratorForJava();
|
||||
|
||||
|
||||
protected void setUp() {
|
||||
conf.configureActiveObjects(
|
||||
new JavaConfig.RestartStrategy(new JavaConfig.AllForOne(), 3, 5000),
|
||||
new Component[] {
|
||||
new Component[] {
|
||||
new Component("persistent-stateful", PersistentStateful.class, PersistentStatefulImpl.class, new LifeCycle(new Permanent(), 1000), 10000000),
|
||||
new Component("persistent-failer", PersistentFailer.class, PersistentFailerImpl.class, new LifeCycle(new Permanent(), 1000), 1000),
|
||||
new Component("persistent-clasher", PersistentClasher.class, PersistentClasherImpl.class, new LifeCycle(new Permanent(), 1000), 100000)
|
||||
}).inject().supervise();
|
||||
}).supervise();
|
||||
}
|
||||
|
||||
protected void tearDown() {
|
||||
conf.stop();
|
||||
}
|
||||
|
||||
public void testShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
|
||||
/*
|
||||
PersistentStateful stateful = conf.getActiveObject(PersistentStateful.class);
|
||||
stateful.setState("stateful", "init"); // set init state
|
||||
stateful.success("stateful", "new state"); // transactional
|
||||
assertEquals("new state", stateful.getState("stateful"));
|
||||
*/
|
||||
assertTrue(true);
|
||||
PersistentStateful stateful = conf.getActiveObject("persistent-stateful");
|
||||
stateful.setState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "init"); // set init state
|
||||
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state"); // transactional
|
||||
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state"); // to trigger commit
|
||||
assertEquals("new state", stateful.getState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess"));
|
||||
}
|
||||
|
||||
public void testShouldRollbackStateForStatefulServerInCaseOfFailure() {
|
||||
PersistentStateful stateful = conf.getActiveObject("persistent-stateful");
|
||||
stateful.setState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init"); // set init state
|
||||
PersistentFailer failer = conf.getActiveObject("persistent-failer");
|
||||
try {
|
||||
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer); // call failing transactional method
|
||||
fail("should have thrown an exception");
|
||||
} catch (RuntimeException e) {
|
||||
} // expected
|
||||
assertEquals("init", stateful.getState("testShouldRollbackStateForStatefulServerInCaseOfFailure")); // check that state is == init state
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -60,7 +83,7 @@ class PersistentStatefulImpl implements PersistentStateful {
|
|||
private TransactionalMap state = new CassandraPersistentTransactionalMap(this);
|
||||
|
||||
public String getState(String key) {
|
||||
return (String)state.get(key);
|
||||
return (String)state.get(key).get();
|
||||
}
|
||||
|
||||
public void setState(String key, String msg) {
|
||||
|
|
@ -110,7 +133,7 @@ class PersistentClasherImpl implements PersistentClasher {
|
|||
private TransactionalMap state = new CassandraPersistentTransactionalMap(this);
|
||||
|
||||
public String getState(String key) {
|
||||
return (String)state.get(key);
|
||||
return (String)state.get(key).get();
|
||||
}
|
||||
|
||||
public void setState(String key, String msg) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue