fixed tests to work with new transactional items

This commit is contained in:
Jonas Boner 2009-04-28 21:47:42 +02:00
parent 21e7a6f4b8
commit 49f433b012
7 changed files with 24 additions and 22 deletions

View file

@ -4,11 +4,6 @@
<classpathentry kind="src" path="src/test/java"/> <classpathentry kind="src" path="src/test/java"/>
<classpathentry kind="lib" path="dist/api-java.jar"/> <classpathentry kind="lib" path="dist/api-java.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/akka-kernel">
<attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="akka-kernel/target"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="/Users/jboner/src/scala/akka/lib/activation-1.1.jar"/> <classpathentry kind="lib" path="/Users/jboner/src/scala/akka/lib/activation-1.1.jar"/>
<classpathentry kind="lib" path="/Users/jboner/src/scala/akka/lib/akka-util-java.jar"/> <classpathentry kind="lib" path="/Users/jboner/src/scala/akka/lib/akka-util-java.jar"/>
<classpathentry kind="lib" path="/Users/jboner/src/scala/akka/lib/antlr-3.1.3.jar"/> <classpathentry kind="lib" path="/Users/jboner/src/scala/akka/lib/antlr-3.1.3.jar"/>

View file

@ -5,8 +5,12 @@
package se.scalablesolutions.akka.api; package se.scalablesolutions.akka.api;
import se.scalablesolutions.akka.annotation.*; import se.scalablesolutions.akka.annotation.*;
import se.scalablesolutions.akka.kernel.configuration.*; import se.scalablesolutions.akka.kernel.*;
import se.scalablesolutions.akka.kernel.InMemoryState; import se.scalablesolutions.akka.kernel.configuration.LifeCycle;
import se.scalablesolutions.akka.kernel.configuration.Permanent;
import se.scalablesolutions.akka.kernel.configuration.Component;
import se.scalablesolutions.akka.kernel.configuration.AllForOne;
import se.scalablesolutions.akka.kernel.configuration.RestartStrategy;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
@ -101,7 +105,7 @@ interface InMemStateful {
class InMemStatefulImpl implements InMemStateful { class InMemStatefulImpl implements InMemStateful {
@state @state
private InMemoryState<String, Object> state = new InMemoryState<String, Object>(); private TransactionalMap<String, Object> state = new InMemoryTransactionalMap<String, Object>();
public String getState(String key) { public String getState(String key) {
return (String) state.get(key); return (String) state.get(key);
@ -152,7 +156,7 @@ interface InMemClasher {
class InMemClasherImpl implements InMemClasher { class InMemClasherImpl implements InMemClasher {
@state @state
private InMemoryState<String, Object> state = new InMemoryState<String, Object>(); private TransactionalMap<String, Object> state = new InMemoryTransactionalMap<String, Object>();
public String getState(String key) { public String getState(String key) {
return (String) state.get(key); return (String) state.get(key);

View file

@ -5,8 +5,12 @@
package se.scalablesolutions.akka.api; package se.scalablesolutions.akka.api;
import se.scalablesolutions.akka.annotation.*; import se.scalablesolutions.akka.annotation.*;
import se.scalablesolutions.akka.kernel.configuration.*; import se.scalablesolutions.akka.kernel.*;
import se.scalablesolutions.akka.kernel.InMemoryState; import se.scalablesolutions.akka.kernel.configuration.LifeCycle;
import se.scalablesolutions.akka.kernel.configuration.Permanent;
import se.scalablesolutions.akka.kernel.configuration.Component;
import se.scalablesolutions.akka.kernel.configuration.AllForOne;
import se.scalablesolutions.akka.kernel.configuration.RestartStrategy;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
@ -18,7 +22,7 @@ public class PersistentStateTest extends TestCase {
static String messageLog = ""; static String messageLog = "";
final private ActiveObjectGuiceConfigurator conf = new ActiveObjectGuiceConfigurator(); final private ActiveObjectGuiceConfigurator conf = new ActiveObjectGuiceConfigurator();
protected void setUp() { protected void setUp() {
conf.configureActiveObjects( conf.configureActiveObjects(
new RestartStrategy(new AllForOne(), 3, 5000), new RestartStrategy(new AllForOne(), 3, 5000),
@ -59,8 +63,7 @@ interface PersistentStateful {
} }
class PersistentStatefulImpl implements PersistentStateful { class PersistentStatefulImpl implements PersistentStateful {
@state private TransactionalMap state = new CassandraPersistentTransactionalMap(this);
private InMemoryState<String, Object> state = new InMemoryState<String, Object>();
public String getState(String key) { public String getState(String key) {
return (String) state.get(key); return (String) state.get(key);
@ -110,8 +113,7 @@ interface PersistentClasher {
} }
class PersistentClasherImpl implements PersistentClasher { class PersistentClasherImpl implements PersistentClasher {
@state private TransactionalMap state = new CassandraPersistentTransactionalMap(this);
private InMemoryState<String, Object> state = new InMemoryState<String, Object>();
public String getState(String key) { public String getState(String key) {
return (String) state.get(key); return (String) state.get(key);

View file

@ -2,7 +2,7 @@
# and the pattern to %c instead of %l. (%l is slower.) # and the pattern to %c instead of %l. (%l is slower.)
# output messages into a rolling log file as well as stdout # output messages into a rolling log file as well as stdout
log4j.rootLogger=ERROR,stdout,R log4j.rootLogger=DEBUG,stdout,R
# stdout # stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout=org.apache.log4j.ConsoleAppender

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" path="src/main/scala"/>
<classpathentry kind="src" path="src/test/scala"/> <classpathentry kind="src" path="src/test/scala"/>
<classpathentry kind="src" path="src/main/scala"/>
<classpathentry kind="con" path="ch.epfl.lamp.sdt.launching.SCALA_CONTAINER"/> <classpathentry kind="con" path="ch.epfl.lamp.sdt.launching.SCALA_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="/Users/jboner/src/scala/akka/lib/activation-1.1.jar"/> <classpathentry kind="lib" path="/Users/jboner/src/scala/akka/lib/activation-1.1.jar"/>

View file

@ -103,7 +103,7 @@ class GenericServerContainer(
} }
// TX Maps // TX Maps
private[this] var _transactionalMaps: List[TransactionalMap[_, _]] = Nil private[kernel] var _transactionalMaps: List[TransactionalMap[_, _]] = Nil
private[kernel] def transactionalMaps_=(maps: List[TransactionalMap[_, _]]) = txItemsLock.withWriteLock { private[kernel] def transactionalMaps_=(maps: List[TransactionalMap[_, _]]) = txItemsLock.withWriteLock {
_transactionalMaps = maps _transactionalMaps = maps
} }
@ -112,7 +112,7 @@ class GenericServerContainer(
} }
// TX Vectors // TX Vectors
private[this] var _transactionalVectors: List[TransactionalVector[_]] = Nil private[kernel] var _transactionalVectors: List[TransactionalVector[_]] = Nil
private[kernel] def transactionalVectors_=(vectors: List[TransactionalVector[_]]) = txItemsLock.withWriteLock { private[kernel] def transactionalVectors_=(vectors: List[TransactionalVector[_]]) = txItemsLock.withWriteLock {
_transactionalVectors = vectors _transactionalVectors = vectors
} }
@ -121,7 +121,7 @@ class GenericServerContainer(
} }
// TX Refs // TX Refs
private[this] var _transactionalRefs: List[TransactionalRef[_]] = Nil private[kernel] var _transactionalRefs: List[TransactionalRef[_]] = Nil
private[kernel] def transactionalRefs_=(refs: List[TransactionalRef[_]]) = txItemsLock.withWriteLock { private[kernel] def transactionalRefs_=(refs: List[TransactionalRef[_]]) = txItemsLock.withWriteLock {
_transactionalRefs = refs _transactionalRefs = refs
} }

View file

@ -83,7 +83,8 @@ class InMemoryTransactionalMap[K, V] extends TransactionalMap[K, V] {
* *
* @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a> * @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a>
*/ */
class CassandraPersistentTransactionalMap(val actorName: String) extends PersistentTransactionalMap[String, String] { class CassandraPersistentTransactionalMap(actorNameInstance: AnyRef) extends PersistentTransactionalMap[String, String] {
val actorName = actorNameInstance.getClass.getName
override def begin = {} override def begin = {}
override def rollback = {} override def rollback = {}