Re-adding runnable Active Object Java tests, which all pass
This commit is contained in:
parent
a35575177f
commit
02af674a96
28 changed files with 15 additions and 1047 deletions
|
|
@ -3,24 +3,28 @@
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<name>Akka Functional Tests in Java</name>
|
<name>Akka Active Object Tests in Java</name>
|
||||||
<artifactId>akka-fun-test-java</artifactId>
|
<artifactId>akka-active-object-test</artifactId>
|
||||||
<groupId>se.scalablesolutions.akka</groupId>
|
<groupId>se.scalablesolutions.akka</groupId>
|
||||||
<version>0.9</version>
|
<version>0.9</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<scala.version>2.8.0.RC3</scala.version>
|
<scala.version>2.8.0.RC3</scala.version>
|
||||||
<atmosphere.version>0.5.2</atmosphere.version>
|
|
||||||
<jersey.version>1.1.5</jersey.version>
|
|
||||||
<grizzly.version>1.9.18-i</grizzly.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>embedded-repo</id>
|
<id>embedded-repo</id>
|
||||||
<name>Embedded Repository</name>
|
<name>Embedded Repository</name>
|
||||||
<url>file://Users/jboner/src/scala/akka/embedded-repo</url>
|
<url>file:///Users/jboner/src/scala/akka/embedded-repo</url>
|
||||||
|
<snapshots />
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>jboss</id>
|
||||||
|
<name>JBoss Repository</name>
|
||||||
|
<url>https://repository.jboss.org/nexus/content/groups/public</url>
|
||||||
|
<snapshots />
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
|
|
@ -35,59 +39,9 @@
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>se.scalablesolutions.akka</groupId>
|
<groupId>se.scalablesolutions.akka</groupId>
|
||||||
<artifactId>akka-kernel_2.8.0.RC3</artifactId>
|
<artifactId>akka-core_2.8.0.RC3</artifactId>
|
||||||
<version>0.9</version>
|
<version>0.9</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>se.scalablesolutions.akka</groupId>
|
|
||||||
<artifactId>akka-persistence-cassandra_2.8.0.RC3</artifactId>
|
|
||||||
<version>0.9</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.protobuf</groupId>
|
|
||||||
<artifactId>protobuf-java</artifactId>
|
|
||||||
<version>2.3.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.codehaus.jackson</groupId>
|
|
||||||
<artifactId>jackson-core-asl</artifactId>
|
|
||||||
<version>1.2.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.codehaus.jackson</groupId>
|
|
||||||
<artifactId>jackson-mapper-asl</artifactId>
|
|
||||||
<version>1.2.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.sun.grizzly</groupId>
|
|
||||||
<artifactId>grizzly-servlet-webserver</artifactId>
|
|
||||||
<version>${grizzly.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.sun.jersey</groupId>
|
|
||||||
<artifactId>jersey-server</artifactId>
|
|
||||||
<version>${jersey.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.sun.jersey</groupId>
|
|
||||||
<artifactId>jersey-json</artifactId>
|
|
||||||
<version>${jersey.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.sun.jersey</groupId>
|
|
||||||
<artifactId>jersey-client</artifactId>
|
|
||||||
<version>${jersey.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.sun.jersey</groupId>
|
|
||||||
<artifactId>jersey-atom</artifactId>
|
|
||||||
<version>${jersey.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
|
|
@ -8,13 +8,9 @@ public class AllTest extends TestCase {
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
TestSuite suite = new TestSuite("All Java tests");
|
TestSuite suite = new TestSuite("All Java tests");
|
||||||
suite.addTestSuite(InMemoryStateTest.class);
|
suite.addTestSuite(InMemoryStateTest.class);
|
||||||
//suite.addTestSuite(InMemNestedStateTest.class);
|
suite.addTestSuite(InMemNestedStateTest.class);
|
||||||
suite.addTestSuite(RemoteInMemoryStateTest.class);
|
suite.addTestSuite(RemoteInMemoryStateTest.class);
|
||||||
suite.addTestSuite(ActiveObjectGuiceConfiguratorTest.class);
|
suite.addTestSuite(ActiveObjectGuiceConfiguratorTest.class);
|
||||||
//suite.addTestSuite(PersistentStateTest.class);
|
|
||||||
//suite.addTestSuite(PersistentNestedStateTest.class);
|
|
||||||
//suite.addTestSuite(RemotePersistentStateTest.class);
|
|
||||||
//suite.addTestSuite(RestTest.class);
|
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -9,7 +9,6 @@ import se.scalablesolutions.akka.config.Config;
|
||||||
import se.scalablesolutions.akka.config.ActiveObjectConfigurator;
|
import se.scalablesolutions.akka.config.ActiveObjectConfigurator;
|
||||||
import static se.scalablesolutions.akka.config.JavaConfig.*;
|
import static se.scalablesolutions.akka.config.JavaConfig.*;
|
||||||
import se.scalablesolutions.akka.actor.*;
|
import se.scalablesolutions.akka.actor.*;
|
||||||
import se.scalablesolutions.akka.kernel.Kernel;
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
public class InMemNestedStateTest extends TestCase {
|
public class InMemNestedStateTest extends TestCase {
|
||||||
|
|
@ -13,7 +13,6 @@ import se.scalablesolutions.akka.config.ActiveObjectConfigurator;
|
||||||
import static se.scalablesolutions.akka.config.JavaConfig.*;
|
import static se.scalablesolutions.akka.config.JavaConfig.*;
|
||||||
|
|
||||||
import se.scalablesolutions.akka.actor.*;
|
import se.scalablesolutions.akka.actor.*;
|
||||||
import se.scalablesolutions.akka.kernel.Kernel;
|
|
||||||
|
|
||||||
public class InMemoryStateTest extends TestCase {
|
public class InMemoryStateTest extends TestCase {
|
||||||
static String messageLog = "";
|
static String messageLog = "";
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
package se.scalablesolutions.akka.api;
|
|
||||||
|
|
||||||
import javax.ws.rs.Path;
|
|
||||||
import javax.ws.rs.GET;
|
|
||||||
import javax.ws.rs.Produces;
|
|
||||||
|
|
||||||
@Path("/foo")
|
|
||||||
public class JerseyFoo {
|
|
||||||
@GET
|
|
||||||
@Produces({"application/json"})
|
|
||||||
public String foo() {
|
|
||||||
return "hello foo";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
package se.scalablesolutions.akka.api;
|
|
||||||
|
|
||||||
public class PersistenceManager {
|
|
||||||
private static volatile boolean isRunning = false;
|
|
||||||
public static void init() {
|
|
||||||
if (!isRunning) {
|
|
||||||
se.scalablesolutions.akka.kernel.Kernel$.MODULE$.startRemoteService();
|
|
||||||
isRunning = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
package se.scalablesolutions.akka.api;
|
|
||||||
|
|
||||||
import se.scalablesolutions.akka.persistence.common.*;
|
|
||||||
import se.scalablesolutions.akka.persistence.cassandra.*;
|
|
||||||
import se.scalablesolutions.akka.actor.annotation.inittransactionalstate;
|
|
||||||
|
|
||||||
public class PersistentClasher {
|
|
||||||
private PersistentMap state;
|
|
||||||
|
|
||||||
@inittransactionalstate
|
|
||||||
public void init() {
|
|
||||||
state = CassandraStorage.newMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getState(String key) {
|
|
||||||
return (String)state.get(key).get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setState(String key, String msg) {
|
|
||||||
state.put(key, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clash() {
|
|
||||||
state.put("clasher", "was here");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
package se.scalablesolutions.akka.api;
|
|
||||||
|
|
||||||
public class PersistentFailer implements java.io.Serializable {
|
|
||||||
public int fail() {
|
|
||||||
throw new RuntimeException("expected");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,110 +0,0 @@
|
||||||
/**
|
|
||||||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
|
||||||
*/
|
|
||||||
|
|
||||||
package se.scalablesolutions.akka.api;
|
|
||||||
|
|
||||||
import se.scalablesolutions.akka.config.*;
|
|
||||||
import se.scalablesolutions.akka.config.ActiveObjectConfigurator;
|
|
||||||
import static se.scalablesolutions.akka.config.JavaConfig.*;
|
|
||||||
import se.scalablesolutions.akka.actor.*;
|
|
||||||
import se.scalablesolutions.akka.kernel.Kernel;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
public class PersistentNestedStateTest extends TestCase {
|
|
||||||
static String messageLog = "";
|
|
||||||
|
|
||||||
final private ActiveObjectConfigurator conf = new ActiveObjectConfigurator();
|
|
||||||
|
|
||||||
protected void setUp() {
|
|
||||||
PersistenceManager.init();
|
|
||||||
conf.configure(
|
|
||||||
new RestartStrategy(new AllForOne(), 3, 5000, new Class[] {Exception.class}),
|
|
||||||
new Component[]{
|
|
||||||
new Component(PersistentStateful.class, new LifeCycle(new Permanent()), 10000000),
|
|
||||||
new Component(PersistentStatefulNested.class, new LifeCycle(new Permanent()), 10000000),
|
|
||||||
new Component(PersistentFailer.class, new LifeCycle(new Permanent()), 1000)
|
|
||||||
//new Component("inmem-clasher", InMemClasher.class, InMemClasherImpl.class, new LifeCycle(new Permanent()), 100000)
|
|
||||||
}).inject().supervise();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void tearDown() {
|
|
||||||
conf.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testMapShouldNotRollbackStateForStatefulServerInCaseOfSuccess() throws Exception {
|
|
||||||
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
|
|
||||||
assertEquals("new state", nested.getMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess"));
|
|
||||||
assertEquals("new state", stateful.getMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testMapShouldRollbackStateForStatefulServerInCaseOfFailure() {
|
|
||||||
PersistentStateful stateful = conf.getInstance(PersistentStateful.class);
|
|
||||||
stateful.setMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init"); // set init state
|
|
||||||
PersistentStatefulNested nested = conf.getInstance(PersistentStatefulNested.class);
|
|
||||||
nested.setMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init"); // set init state
|
|
||||||
PersistentFailer failer = conf.getInstance(PersistentFailer.class);
|
|
||||||
try {
|
|
||||||
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", nested, failer); // call failing transactional method
|
|
||||||
fail("should have thrown an exception");
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
} // expected
|
|
||||||
assertEquals("init", stateful.getMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure")); // check that state is == init state
|
|
||||||
assertEquals("init", nested.getMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure")); // check that state is == init state
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testVectorShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
|
|
||||||
PersistentStateful stateful = conf.getInstance(PersistentStateful.class);
|
|
||||||
stateful.setVectorState("init"); // set init state
|
|
||||||
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
|
|
||||||
assertEquals(2, nested.getVectorLength());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testVectorShouldRollbackStateForStatefulServerInCaseOfFailure() {
|
|
||||||
PersistentStateful stateful = conf.getInstance(PersistentStateful.class);
|
|
||||||
stateful.setVectorState("init"); // set init state
|
|
||||||
PersistentStatefulNested nested = conf.getInstance(PersistentStatefulNested.class);
|
|
||||||
nested.setVectorState("init"); // set init state
|
|
||||||
PersistentFailer failer = conf.getInstance(PersistentFailer.class);
|
|
||||||
try {
|
|
||||||
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", nested, failer); // call failing transactional method
|
|
||||||
fail("should have thrown an exception");
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
} // expected
|
|
||||||
assertEquals(1, stateful.getVectorLength());
|
|
||||||
assertEquals(1, nested.getVectorLength());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testRefShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
|
|
||||||
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
|
|
||||||
assertEquals("new state", stateful.getRefState());
|
|
||||||
assertEquals("new state", nested.getRefState());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testRefShouldRollbackStateForStatefulServerInCaseOfFailure() {
|
|
||||||
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.getInstance(PersistentFailer.class);
|
|
||||||
try {
|
|
||||||
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", nested, failer); // call failing transactional method
|
|
||||||
fail("should have thrown an exception");
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
} // expected
|
|
||||||
assertEquals("init", stateful.getRefState()); // check that state is == init state
|
|
||||||
assertEquals("init", nested.getRefState()); // check that state is == init state
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,89 +0,0 @@
|
||||||
/**
|
|
||||||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
|
||||||
*/
|
|
||||||
|
|
||||||
package se.scalablesolutions.akka.api;
|
|
||||||
|
|
||||||
import se.scalablesolutions.akka.config.*;
|
|
||||||
import static se.scalablesolutions.akka.config.JavaConfig.*;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
public class PersistentStateTest extends TestCase {
|
|
||||||
static String messageLog = "";
|
|
||||||
|
|
||||||
final private ActiveObjectConfigurator conf = new ActiveObjectConfigurator();
|
|
||||||
|
|
||||||
protected void setUp() {
|
|
||||||
PersistenceManager.init();
|
|
||||||
conf.configure(
|
|
||||||
new RestartStrategy(new AllForOne(), 3, 5000, new Class[] {Exception.class}),
|
|
||||||
new Component[] {
|
|
||||||
new Component(PersistentStateful.class, new LifeCycle(new Permanent()), 10000000),
|
|
||||||
new Component(PersistentFailer.class, new LifeCycle(new Permanent()), 1000)
|
|
||||||
//new Component(PersistentClasher.class, new LifeCycle(new Permanent()), 100000)
|
|
||||||
}).supervise();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void tearDown() {
|
|
||||||
conf.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
|
|
||||||
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.getInstance(PersistentStateful.class);
|
|
||||||
stateful.setMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init"); // set init state
|
|
||||||
PersistentFailer failer = conf.getInstance(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.getMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure")); // check that state is == init state
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testVectorShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
|
|
||||||
PersistentStateful stateful = conf.getInstance(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));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testVectorShouldRollbackStateForStatefulServerInCaseOfFailure() {
|
|
||||||
PersistentStateful stateful = conf.getInstance(PersistentStateful.class);
|
|
||||||
stateful.setVectorState("init"); // set init state
|
|
||||||
PersistentFailer failer = conf.getInstance(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
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testRefShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
|
|
||||||
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.getInstance(PersistentStateful.class);
|
|
||||||
stateful.setRefState("init"); // set init state
|
|
||||||
PersistentFailer failer = conf.getInstance(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.getRefState()); // check that state is == init state
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,84 +0,0 @@
|
||||||
package se.scalablesolutions.akka.api;
|
|
||||||
|
|
||||||
import se.scalablesolutions.akka.actor.annotation.inittransactionalstate;
|
|
||||||
import se.scalablesolutions.akka.actor.annotation.transactionrequired;
|
|
||||||
import se.scalablesolutions.akka.persistence.common.*;
|
|
||||||
import se.scalablesolutions.akka.persistence.cassandra.*;
|
|
||||||
|
|
||||||
@transactionrequired
|
|
||||||
public class PersistentStateful {
|
|
||||||
private PersistentMap mapState;
|
|
||||||
private PersistentVector vectorState;
|
|
||||||
private PersistentRef refState;
|
|
||||||
|
|
||||||
@inittransactionalstate
|
|
||||||
public void init() {
|
|
||||||
mapState = CassandraStorage.newMap();
|
|
||||||
vectorState = CassandraStorage.newVector();
|
|
||||||
refState = CassandraStorage.newRef();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMapState(String key) {
|
|
||||||
byte[] bytes = (byte[]) mapState.get(key.getBytes()).get();
|
|
||||||
return new String(bytes, 0, bytes.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getVectorState(int index) {
|
|
||||||
byte[] bytes = (byte[]) vectorState.get(index);
|
|
||||||
return new String(bytes, 0, bytes.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getVectorLength() {
|
|
||||||
return vectorState.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRefState() {
|
|
||||||
if (refState.isDefined()) {
|
|
||||||
byte[] bytes = (byte[]) refState.get().get();
|
|
||||||
return new String(bytes, 0, bytes.length);
|
|
||||||
} else throw new IllegalStateException("No such element");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMapState(String key, String msg) {
|
|
||||||
mapState.put(key.getBytes(), msg.getBytes());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVectorState(String msg) {
|
|
||||||
vectorState.add(msg.getBytes());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRefState(String msg) {
|
|
||||||
refState.swap(msg.getBytes());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void success(String key, String msg) {
|
|
||||||
mapState.put(key.getBytes(), msg.getBytes());
|
|
||||||
vectorState.add(msg.getBytes());
|
|
||||||
refState.swap(msg.getBytes());
|
|
||||||
}
|
|
||||||
|
|
||||||
public String failure(String key, String msg, PersistentFailer failer) {
|
|
||||||
mapState.put(key.getBytes(), msg.getBytes());
|
|
||||||
vectorState.add(msg.getBytes());
|
|
||||||
refState.swap(msg.getBytes());
|
|
||||||
failer.fail();
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String success(String key, String msg, PersistentStatefulNested nested) {
|
|
||||||
mapState.put(key.getBytes(), msg.getBytes());
|
|
||||||
vectorState.add(msg.getBytes());
|
|
||||||
refState.swap(msg.getBytes());
|
|
||||||
nested.success(key, msg);
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String failure(String key, String msg, PersistentStatefulNested nested, PersistentFailer failer) {
|
|
||||||
mapState.put(key.getBytes(), msg.getBytes());
|
|
||||||
vectorState.add(msg.getBytes());
|
|
||||||
refState.swap(msg.getBytes());
|
|
||||||
nested.failure(key, msg, failer);
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
||||||
package se.scalablesolutions.akka.api;
|
|
||||||
|
|
||||||
import se.scalablesolutions.akka.actor.annotation.inittransactionalstate;
|
|
||||||
import se.scalablesolutions.akka.actor.annotation.transactionrequired;
|
|
||||||
import se.scalablesolutions.akka.persistence.common.*;
|
|
||||||
import se.scalablesolutions.akka.persistence.cassandra.*;
|
|
||||||
|
|
||||||
@transactionrequired
|
|
||||||
public class PersistentStatefulNested {
|
|
||||||
private PersistentMap mapState;
|
|
||||||
private PersistentVector vectorState;
|
|
||||||
private PersistentRef refState;
|
|
||||||
|
|
||||||
@inittransactionalstate
|
|
||||||
public void init() {
|
|
||||||
mapState = CassandraStorage.newMap();
|
|
||||||
vectorState = CassandraStorage.newVector();
|
|
||||||
refState = CassandraStorage.newRef();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMapState(String key) {
|
|
||||||
byte[] bytes = (byte[]) mapState.get(key.getBytes()).get();
|
|
||||||
return new String(bytes, 0, bytes.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getVectorState(int index) {
|
|
||||||
byte[] bytes = (byte[]) vectorState.get(index);
|
|
||||||
return new String(bytes, 0, bytes.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getVectorLength() {
|
|
||||||
return vectorState.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRefState() {
|
|
||||||
if (refState.isDefined()) {
|
|
||||||
byte[] bytes = (byte[]) refState.get().get();
|
|
||||||
return new String(bytes, 0, bytes.length);
|
|
||||||
} else throw new IllegalStateException("No such element");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMapState(String key, String msg) {
|
|
||||||
mapState.put(key.getBytes(), msg.getBytes());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVectorState(String msg) {
|
|
||||||
vectorState.add(msg.getBytes());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRefState(String msg) {
|
|
||||||
refState.swap(msg.getBytes());
|
|
||||||
}
|
|
||||||
|
|
||||||
public String success(String key, String msg) {
|
|
||||||
mapState.put(key.getBytes(), msg.getBytes());
|
|
||||||
vectorState.add(msg.getBytes());
|
|
||||||
refState.swap(msg.getBytes());
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String failure(String key, String msg, PersistentFailer failer) {
|
|
||||||
mapState.put(key.getBytes(), msg.getBytes());
|
|
||||||
vectorState.add(msg.getBytes());
|
|
||||||
refState.swap(msg.getBytes());
|
|
||||||
failer.fail();
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,403 +0,0 @@
|
||||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
||||||
|
|
||||||
package se.scalablesolutions.akka.api;
|
|
||||||
|
|
||||||
public final class ProtobufProtocol {
|
|
||||||
private ProtobufProtocol() {}
|
|
||||||
public static void registerAllExtensions(
|
|
||||||
com.google.protobuf.ExtensionRegistry registry) {
|
|
||||||
}
|
|
||||||
public static final class ProtobufPOJO extends
|
|
||||||
com.google.protobuf.GeneratedMessage {
|
|
||||||
// Use ProtobufPOJO.newBuilder() to construct.
|
|
||||||
private ProtobufPOJO() {}
|
|
||||||
|
|
||||||
private static final ProtobufPOJO defaultInstance = new ProtobufPOJO();
|
|
||||||
public static ProtobufPOJO getDefaultInstance() {
|
|
||||||
return defaultInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProtobufPOJO getDefaultInstanceForType() {
|
|
||||||
return defaultInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final com.google.protobuf.Descriptors.Descriptor
|
|
||||||
getDescriptor() {
|
|
||||||
return se.scalablesolutions.akka.api.ProtobufProtocol.internal_static_se_scalablesolutions_akka_api_ProtobufPOJO_descriptor;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
|
|
||||||
internalGetFieldAccessorTable() {
|
|
||||||
return se.scalablesolutions.akka.api.ProtobufProtocol.internal_static_se_scalablesolutions_akka_api_ProtobufPOJO_fieldAccessorTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
// required uint64 id = 1;
|
|
||||||
public static final int ID_FIELD_NUMBER = 1;
|
|
||||||
private boolean hasId;
|
|
||||||
private long id_ = 0L;
|
|
||||||
public boolean hasId() { return hasId; }
|
|
||||||
public long getId() { return id_; }
|
|
||||||
|
|
||||||
// required string name = 2;
|
|
||||||
public static final int NAME_FIELD_NUMBER = 2;
|
|
||||||
private boolean hasName;
|
|
||||||
private java.lang.String name_ = "";
|
|
||||||
public boolean hasName() { return hasName; }
|
|
||||||
public java.lang.String getName() { return name_; }
|
|
||||||
|
|
||||||
// required bool status = 3;
|
|
||||||
public static final int STATUS_FIELD_NUMBER = 3;
|
|
||||||
private boolean hasStatus;
|
|
||||||
private boolean status_ = false;
|
|
||||||
public boolean hasStatus() { return hasStatus; }
|
|
||||||
public boolean getStatus() { return status_; }
|
|
||||||
|
|
||||||
public final boolean isInitialized() {
|
|
||||||
if (!hasId) return false;
|
|
||||||
if (!hasName) return false;
|
|
||||||
if (!hasStatus) return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeTo(com.google.protobuf.CodedOutputStream output)
|
|
||||||
throws java.io.IOException {
|
|
||||||
if (hasId()) {
|
|
||||||
output.writeUInt64(1, getId());
|
|
||||||
}
|
|
||||||
if (hasName()) {
|
|
||||||
output.writeString(2, getName());
|
|
||||||
}
|
|
||||||
if (hasStatus()) {
|
|
||||||
output.writeBool(3, getStatus());
|
|
||||||
}
|
|
||||||
getUnknownFields().writeTo(output);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int memoizedSerializedSize = -1;
|
|
||||||
public int getSerializedSize() {
|
|
||||||
int size = memoizedSerializedSize;
|
|
||||||
if (size != -1) return size;
|
|
||||||
|
|
||||||
size = 0;
|
|
||||||
if (hasId()) {
|
|
||||||
size += com.google.protobuf.CodedOutputStream
|
|
||||||
.computeUInt64Size(1, getId());
|
|
||||||
}
|
|
||||||
if (hasName()) {
|
|
||||||
size += com.google.protobuf.CodedOutputStream
|
|
||||||
.computeStringSize(2, getName());
|
|
||||||
}
|
|
||||||
if (hasStatus()) {
|
|
||||||
size += com.google.protobuf.CodedOutputStream
|
|
||||||
.computeBoolSize(3, getStatus());
|
|
||||||
}
|
|
||||||
size += getUnknownFields().getSerializedSize();
|
|
||||||
memoizedSerializedSize = size;
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO parseFrom(
|
|
||||||
com.google.protobuf.ByteString data)
|
|
||||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
|
||||||
return newBuilder().mergeFrom(data).buildParsed();
|
|
||||||
}
|
|
||||||
public static se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO parseFrom(
|
|
||||||
com.google.protobuf.ByteString data,
|
|
||||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
|
||||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
|
||||||
return newBuilder().mergeFrom(data, extensionRegistry)
|
|
||||||
.buildParsed();
|
|
||||||
}
|
|
||||||
public static se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO parseFrom(byte[] data)
|
|
||||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
|
||||||
return newBuilder().mergeFrom(data).buildParsed();
|
|
||||||
}
|
|
||||||
public static se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO parseFrom(
|
|
||||||
byte[] data,
|
|
||||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
|
||||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
|
||||||
return newBuilder().mergeFrom(data, extensionRegistry)
|
|
||||||
.buildParsed();
|
|
||||||
}
|
|
||||||
public static se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO parseFrom(java.io.InputStream input)
|
|
||||||
throws java.io.IOException {
|
|
||||||
return newBuilder().mergeFrom(input).buildParsed();
|
|
||||||
}
|
|
||||||
public static se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO parseFrom(
|
|
||||||
java.io.InputStream input,
|
|
||||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
|
||||||
throws java.io.IOException {
|
|
||||||
return newBuilder().mergeFrom(input, extensionRegistry)
|
|
||||||
.buildParsed();
|
|
||||||
}
|
|
||||||
public static se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO parseDelimitedFrom(java.io.InputStream input)
|
|
||||||
throws java.io.IOException {
|
|
||||||
return newBuilder().mergeDelimitedFrom(input).buildParsed();
|
|
||||||
}
|
|
||||||
public static se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO parseDelimitedFrom(
|
|
||||||
java.io.InputStream input,
|
|
||||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
|
||||||
throws java.io.IOException {
|
|
||||||
return newBuilder().mergeDelimitedFrom(input, extensionRegistry)
|
|
||||||
.buildParsed();
|
|
||||||
}
|
|
||||||
public static se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO parseFrom(
|
|
||||||
com.google.protobuf.CodedInputStream input)
|
|
||||||
throws java.io.IOException {
|
|
||||||
return newBuilder().mergeFrom(input).buildParsed();
|
|
||||||
}
|
|
||||||
public static se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO parseFrom(
|
|
||||||
com.google.protobuf.CodedInputStream input,
|
|
||||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
|
||||||
throws java.io.IOException {
|
|
||||||
return newBuilder().mergeFrom(input, extensionRegistry)
|
|
||||||
.buildParsed();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Builder newBuilder() { return Builder.create(); }
|
|
||||||
public Builder newBuilderForType() { return newBuilder(); }
|
|
||||||
public static Builder newBuilder(se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO prototype) {
|
|
||||||
return newBuilder().mergeFrom(prototype);
|
|
||||||
}
|
|
||||||
public Builder toBuilder() { return newBuilder(this); }
|
|
||||||
|
|
||||||
public static final class Builder extends
|
|
||||||
com.google.protobuf.GeneratedMessage.Builder<Builder> {
|
|
||||||
private se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO result;
|
|
||||||
|
|
||||||
// Construct using se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO.newBuilder()
|
|
||||||
private Builder() {}
|
|
||||||
|
|
||||||
private static Builder create() {
|
|
||||||
Builder builder = new Builder();
|
|
||||||
builder.result = new se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO();
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO internalGetResult() {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder clear() {
|
|
||||||
if (result == null) {
|
|
||||||
throw new IllegalStateException(
|
|
||||||
"Cannot call clear() after build().");
|
|
||||||
}
|
|
||||||
result = new se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder clone() {
|
|
||||||
return create().mergeFrom(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
public com.google.protobuf.Descriptors.Descriptor
|
|
||||||
getDescriptorForType() {
|
|
||||||
return se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO.getDescriptor();
|
|
||||||
}
|
|
||||||
|
|
||||||
public se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO getDefaultInstanceForType() {
|
|
||||||
return se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO.getDefaultInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isInitialized() {
|
|
||||||
return result.isInitialized();
|
|
||||||
}
|
|
||||||
public se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO build() {
|
|
||||||
if (result != null && !isInitialized()) {
|
|
||||||
throw newUninitializedMessageException(result);
|
|
||||||
}
|
|
||||||
return buildPartial();
|
|
||||||
}
|
|
||||||
|
|
||||||
private se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO buildParsed()
|
|
||||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
|
||||||
if (!isInitialized()) {
|
|
||||||
throw newUninitializedMessageException(
|
|
||||||
result).asInvalidProtocolBufferException();
|
|
||||||
}
|
|
||||||
return buildPartial();
|
|
||||||
}
|
|
||||||
|
|
||||||
public se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO buildPartial() {
|
|
||||||
if (result == null) {
|
|
||||||
throw new IllegalStateException(
|
|
||||||
"build() has already been called on this Builder.");
|
|
||||||
}
|
|
||||||
se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO returnMe = result;
|
|
||||||
result = null;
|
|
||||||
return returnMe;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder mergeFrom(com.google.protobuf.Message other) {
|
|
||||||
if (other instanceof se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO) {
|
|
||||||
return mergeFrom((se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO)other);
|
|
||||||
} else {
|
|
||||||
super.mergeFrom(other);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder mergeFrom(se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO other) {
|
|
||||||
if (other == se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO.getDefaultInstance()) return this;
|
|
||||||
if (other.hasId()) {
|
|
||||||
setId(other.getId());
|
|
||||||
}
|
|
||||||
if (other.hasName()) {
|
|
||||||
setName(other.getName());
|
|
||||||
}
|
|
||||||
if (other.hasStatus()) {
|
|
||||||
setStatus(other.getStatus());
|
|
||||||
}
|
|
||||||
this.mergeUnknownFields(other.getUnknownFields());
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder mergeFrom(
|
|
||||||
com.google.protobuf.CodedInputStream input,
|
|
||||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
|
||||||
throws java.io.IOException {
|
|
||||||
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
|
|
||||||
com.google.protobuf.UnknownFieldSet.newBuilder(
|
|
||||||
this.getUnknownFields());
|
|
||||||
while (true) {
|
|
||||||
int tag = input.readTag();
|
|
||||||
switch (tag) {
|
|
||||||
case 0:
|
|
||||||
this.setUnknownFields(unknownFields.build());
|
|
||||||
return this;
|
|
||||||
default: {
|
|
||||||
if (!parseUnknownField(input, unknownFields,
|
|
||||||
extensionRegistry, tag)) {
|
|
||||||
this.setUnknownFields(unknownFields.build());
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 8: {
|
|
||||||
setId(input.readUInt64());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 18: {
|
|
||||||
setName(input.readString());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 24: {
|
|
||||||
setStatus(input.readBool());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// required uint64 id = 1;
|
|
||||||
public boolean hasId() {
|
|
||||||
return result.hasId();
|
|
||||||
}
|
|
||||||
public long getId() {
|
|
||||||
return result.getId();
|
|
||||||
}
|
|
||||||
public Builder setId(long value) {
|
|
||||||
result.hasId = true;
|
|
||||||
result.id_ = value;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public Builder clearId() {
|
|
||||||
result.hasId = false;
|
|
||||||
result.id_ = 0L;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// required string name = 2;
|
|
||||||
public boolean hasName() {
|
|
||||||
return result.hasName();
|
|
||||||
}
|
|
||||||
public java.lang.String getName() {
|
|
||||||
return result.getName();
|
|
||||||
}
|
|
||||||
public Builder setName(java.lang.String value) {
|
|
||||||
if (value == null) {
|
|
||||||
throw new NullPointerException();
|
|
||||||
}
|
|
||||||
result.hasName = true;
|
|
||||||
result.name_ = value;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public Builder clearName() {
|
|
||||||
result.hasName = false;
|
|
||||||
result.name_ = getDefaultInstance().getName();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// required bool status = 3;
|
|
||||||
public boolean hasStatus() {
|
|
||||||
return result.hasStatus();
|
|
||||||
}
|
|
||||||
public boolean getStatus() {
|
|
||||||
return result.getStatus();
|
|
||||||
}
|
|
||||||
public Builder setStatus(boolean value) {
|
|
||||||
result.hasStatus = true;
|
|
||||||
result.status_ = value;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public Builder clearStatus() {
|
|
||||||
result.hasStatus = false;
|
|
||||||
result.status_ = false;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
|
||||||
se.scalablesolutions.akka.api.ProtobufProtocol.getDescriptor();
|
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
|
||||||
se.scalablesolutions.akka.api.ProtobufProtocol.internalForceInit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static com.google.protobuf.Descriptors.Descriptor
|
|
||||||
internal_static_se_scalablesolutions_akka_api_ProtobufPOJO_descriptor;
|
|
||||||
private static
|
|
||||||
com.google.protobuf.GeneratedMessage.FieldAccessorTable
|
|
||||||
internal_static_se_scalablesolutions_akka_api_ProtobufPOJO_fieldAccessorTable;
|
|
||||||
|
|
||||||
public static com.google.protobuf.Descriptors.FileDescriptor
|
|
||||||
getDescriptor() {
|
|
||||||
return descriptor;
|
|
||||||
}
|
|
||||||
private static com.google.protobuf.Descriptors.FileDescriptor
|
|
||||||
descriptor;
|
|
||||||
static {
|
|
||||||
java.lang.String[] descriptorData = {
|
|
||||||
"\n4se/scalablesolutions/akka/api/Protobuf" +
|
|
||||||
"Protocol.proto\022\035se.scalablesolutions.akk" +
|
|
||||||
"a.api\"8\n\014ProtobufPOJO\022\n\n\002id\030\001 \002(\004\022\014\n\004nam" +
|
|
||||||
"e\030\002 \002(\t\022\016\n\006status\030\003 \002(\010"
|
|
||||||
};
|
|
||||||
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
|
|
||||||
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
|
|
||||||
public com.google.protobuf.ExtensionRegistry assignDescriptors(
|
|
||||||
com.google.protobuf.Descriptors.FileDescriptor root) {
|
|
||||||
descriptor = root;
|
|
||||||
internal_static_se_scalablesolutions_akka_api_ProtobufPOJO_descriptor =
|
|
||||||
getDescriptor().getMessageTypes().get(0);
|
|
||||||
internal_static_se_scalablesolutions_akka_api_ProtobufPOJO_fieldAccessorTable = new
|
|
||||||
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
|
|
||||||
internal_static_se_scalablesolutions_akka_api_ProtobufPOJO_descriptor,
|
|
||||||
new java.lang.String[] { "Id", "Name", "Status", },
|
|
||||||
se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO.class,
|
|
||||||
se.scalablesolutions.akka.api.ProtobufProtocol.ProtobufPOJO.Builder.class);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
com.google.protobuf.Descriptors.FileDescriptor
|
|
||||||
.internalBuildGeneratedFileFrom(descriptorData,
|
|
||||||
new com.google.protobuf.Descriptors.FileDescriptor[] {
|
|
||||||
}, assigner);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void internalForceInit() {}
|
|
||||||
}
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
/**
|
|
||||||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
|
||||||
*/
|
|
||||||
|
|
||||||
package se.scalablesolutions.akka.api;
|
|
||||||
|
|
||||||
/*
|
|
||||||
Compile with:
|
|
||||||
cd ./akka-fun-test-java/src/test/java
|
|
||||||
protoc se/scalablesolutions/akka/api/ProtobufProtocol.proto --java_out .
|
|
||||||
*/
|
|
||||||
|
|
||||||
message ProtobufPOJO {
|
|
||||||
required uint64 id = 1;
|
|
||||||
required string name = 2;
|
|
||||||
required bool status = 3;
|
|
||||||
}
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
/**
|
|
||||||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
|
||||||
*/
|
|
||||||
|
|
||||||
package se.scalablesolutions.akka.api;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
import se.scalablesolutions.akka.serialization.SerializerFactory;
|
|
||||||
|
|
||||||
public class ProtobufSerializationTest extends TestCase {
|
|
||||||
public void testOutIn() throws Exception {
|
|
||||||
SerializerFactory factory = new SerializerFactory();
|
|
||||||
ProtobufProtocol.ProtobufPOJO pojo1 = ProtobufProtocol.ProtobufPOJO.getDefaultInstance().toBuilder().setId(1).setName("protobuf").setStatus(true).build();
|
|
||||||
|
|
||||||
byte[] bytes = factory.getProtobuf().out(pojo1);
|
|
||||||
Object obj = factory.getProtobuf().in(bytes, pojo1.getClass());
|
|
||||||
|
|
||||||
assertTrue(obj instanceof ProtobufProtocol.ProtobufPOJO);
|
|
||||||
ProtobufProtocol.ProtobufPOJO pojo2 = (ProtobufProtocol.ProtobufPOJO)obj;
|
|
||||||
assertEquals(pojo1.getId(), pojo2.getId());
|
|
||||||
assertEquals(pojo1.getName(), pojo2.getName());
|
|
||||||
assertEquals(pojo1.getStatus(), pojo2.getStatus());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testDeepClone() throws Exception {
|
|
||||||
SerializerFactory factory = new SerializerFactory();
|
|
||||||
ProtobufProtocol.ProtobufPOJO pojo1 = ProtobufProtocol.ProtobufPOJO.getDefaultInstance().toBuilder().setId(1).setName("protobuf").setStatus(true).build();
|
|
||||||
|
|
||||||
Object obj = factory.getProtobuf().deepClone(pojo1);
|
|
||||||
|
|
||||||
assertTrue(obj instanceof ProtobufProtocol.ProtobufPOJO);
|
|
||||||
ProtobufProtocol.ProtobufPOJO pojo2 = (ProtobufProtocol.ProtobufPOJO)obj;
|
|
||||||
assertEquals(pojo1.getId(), pojo2.getId());
|
|
||||||
assertEquals(pojo1.getName(), pojo2.getName());
|
|
||||||
assertEquals(pojo1.getStatus(), pojo2.getStatus());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,88 +0,0 @@
|
||||||
/**
|
|
||||||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
|
||||||
*/
|
|
||||||
|
|
||||||
package se.scalablesolutions.akka.api;
|
|
||||||
|
|
||||||
import se.scalablesolutions.akka.config.*;
|
|
||||||
import static se.scalablesolutions.akka.config.JavaConfig.*;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
public class RemotePersistentStateTest extends TestCase {
|
|
||||||
static String messageLog = "";
|
|
||||||
|
|
||||||
final private ActiveObjectConfigurator conf = new ActiveObjectConfigurator();
|
|
||||||
|
|
||||||
protected void setUp() {
|
|
||||||
PersistenceManager.init();
|
|
||||||
conf.configure(
|
|
||||||
new RestartStrategy(new AllForOne(), 3, 5000, new Class[]{Exception.class}),
|
|
||||||
new Component[] {
|
|
||||||
new Component(PersistentStateful.class, new LifeCycle(new Permanent()), 1000000, new RemoteAddress("localhost", 9999)),
|
|
||||||
new Component(PersistentFailer.class, new LifeCycle(new Permanent()), 1000000, new RemoteAddress("localhost", 9999))
|
|
||||||
}).supervise();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void tearDown() {
|
|
||||||
conf.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
|
|
||||||
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.getInstance(PersistentStateful.class);
|
|
||||||
stateful.setMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init"); // set init state
|
|
||||||
PersistentFailer failer = conf.getInstance(PersistentFailer.class);
|
|
||||||
try {
|
|
||||||
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "MapShouldRollBack", failer); // call failing transactionrequired method
|
|
||||||
fail("should have thrown an exception");
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
} // expected
|
|
||||||
assertEquals("init", stateful.getMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure")); // check that state is == init state
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testVectorShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
|
|
||||||
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.getInstance(PersistentStateful.class);
|
|
||||||
int init = stateful.getVectorLength();
|
|
||||||
PersistentFailer failer = conf.getInstance(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.getVectorLength());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testRefShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
|
|
||||||
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.getInstance(PersistentStateful.class);
|
|
||||||
stateful.setRefState("init"); // set init state
|
|
||||||
PersistentFailer failer = conf.getInstance(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.getRefState()); // check that state is == init state
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
|
|
||||||
|
|
||||||
<suite name="Tests for Akka Java API module" verbose="1">
|
|
||||||
<test name="core">
|
|
||||||
<groups>
|
|
||||||
<run>
|
|
||||||
<include name="functional"/>
|
|
||||||
<include name="unit"/>
|
|
||||||
<exclude name="broken"/>
|
|
||||||
</run>
|
|
||||||
</groups>
|
|
||||||
<packages>
|
|
||||||
<package name="com.scalablesolutions.akka.api.*" />
|
|
||||||
</packages>
|
|
||||||
</test>
|
|
||||||
</suite>
|
|
||||||
|
|
@ -78,8 +78,8 @@ class AkkaParent(info: ProjectInfo) extends DefaultProject(info) {
|
||||||
lazy val akka_kernel = project("akka-kernel", "akka-kernel", new AkkaKernelProject(_),
|
lazy val akka_kernel = project("akka-kernel", "akka-kernel", new AkkaKernelProject(_),
|
||||||
akka_core, akka_http, akka_spring, akka_camel, akka_persistence, akka_amqp)
|
akka_core, akka_http, akka_spring, akka_camel, akka_persistence, akka_amqp)
|
||||||
|
|
||||||
// functional tests in java
|
// active object tests in java
|
||||||
lazy val akka_fun_test = project("akka-fun-test-java", "akka-fun-test-java", new AkkaFunTestProject(_), akka_kernel)
|
lazy val akka_active_object_test = project("akka-active-object-test", "akka-active-object-test", new AkkaActiveObjectTestProject(_), akka_kernel)
|
||||||
|
|
||||||
// examples
|
// examples
|
||||||
lazy val akka_samples = project("akka-samples", "akka-samples", new AkkaSamplesParentProject(_))
|
lazy val akka_samples = project("akka-samples", "akka-samples", new AkkaSamplesParentProject(_))
|
||||||
|
|
@ -290,14 +290,7 @@ class AkkaParent(info: ProjectInfo) extends DefaultProject(info) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= TEST ==================
|
// ================= TEST ==================
|
||||||
class AkkaFunTestProject(info: ProjectInfo) extends DefaultProject(info) {
|
class AkkaActiveObjectTestProject(info: ProjectInfo) extends DefaultProject(info) {
|
||||||
val jackson_core_asl = "org.codehaus.jackson" % "jackson-core-asl" % "1.2.1" % "compile"
|
|
||||||
val stax_api = "javax.xml.stream" % "stax-api" % "1.0-2" % "compile"
|
|
||||||
val protobuf = "com.google.protobuf" % "protobuf-java" % "2.2.0" % "compile"
|
|
||||||
val grizzly = "com.sun.grizzly" % "grizzly-comet-webserver" % "1.9.18-i" % "compile"
|
|
||||||
val jersey_server = "com.sun.jersey" % "jersey-server" % JERSEY_VERSION % "compile"
|
|
||||||
val jersey_json = "com.sun.jersey" % "jersey-json" % JERSEY_VERSION % "compile"
|
|
||||||
val jersey_atom = "com.sun.jersey" % "jersey-atom" % JERSEY_VERSION % "compile"
|
|
||||||
// testing
|
// testing
|
||||||
val junit = "junit" % "junit" % "4.5" % "test"
|
val junit = "junit" % "junit" % "4.5" % "test"
|
||||||
val jmock = "org.jmock" % "jmock" % "2.4.0" % "test"
|
val jmock = "org.jmock" % "jmock" % "2.4.0" % "test"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue