changed oneway to be defined by void in AO + added restart callback def in config

This commit is contained in:
Jonas Boner 2009-07-07 22:11:27 +02:00
parent ff969047cc
commit 6a65c67ca7
11 changed files with 675 additions and 270 deletions

View file

@ -12,17 +12,18 @@ public class Foo {
public String foo(String msg) {
return msg + "return_foo ";
}
@oneway
public void bar(String msg) {
bar.bar(msg);
}
public void longRunning() {
public String longRunning() {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
}
return "test";
}
public void throwsException() {
throw new RuntimeException("expected");
public String throwsException() {
if (true) throw new RuntimeException("expected");
return "test";
}
}

View file

@ -23,9 +23,13 @@ public class InMemoryStateTest extends TestCase {
new RestartStrategy(new AllForOne(), 3, 5000),
new Component[]{
// FIXME: remove string-name, add ctor to only accept target class
new Component(InMemStateful.class, new LifeCycle(new Permanent(), 1000), 10000000),
new Component(InMemFailer.class, new LifeCycle(new Permanent(), 1000), 1000)
//new Component("inmem-clasher", InMemClasher.class, InMemClasherImpl.class, new LifeCycle(new Permanent(), 1000), 100000)
new Component(InMemStateful.class,
new LifeCycle(new Permanent(), 1000),
//new RestartCallbacks("preRestart", "postRestart")),
10000),
new Component(InMemFailer.class,
new LifeCycle(new Permanent(), 1000),
10000)
}).inject().supervise();
}

View file

@ -34,12 +34,12 @@ public class PersistentNestedStateTest extends TestCase {
conf.stop();
}
public void testMapShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
public void testMapShouldNotRollbackStateForStatefulServerInCaseOfSuccess() throws Exception {
PersistentStateful stateful = conf.getActiveObject(PersistentStateful.class);
PersistentStatefulNested nested = conf.getActiveObject(PersistentStatefulNested.class);
stateful.setMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "init"); // set init state
nested.setMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "init"); // set init state
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state", nested); // transactionrequired
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state", nested); // transactional
assertEquals("new state", nested.getMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess"));
assertEquals("new state", stateful.getMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess"));
}
@ -51,7 +51,7 @@ public class PersistentNestedStateTest extends TestCase {
nested.setMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init"); // set init state
PersistentFailer failer = conf.getActiveObject(PersistentFailer.class);
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", nested, failer); // call failing transactionrequired method
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", nested, failer); // call failing transactional method
fail("should have thrown an exception");
} catch (RuntimeException e) {
} // expected
@ -64,7 +64,7 @@ public class PersistentNestedStateTest extends TestCase {
stateful.setVectorState("init"); // set init state
PersistentStatefulNested nested = conf.getActiveObject(PersistentStatefulNested.class);
nested.setVectorState("init"); // set init state
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state", nested); // transactionrequired
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state", nested); // transactional
assertEquals(2, stateful.getVectorLength()); // BAD: keeps one element since last test
assertEquals(2, nested.getVectorLength());
}
@ -76,7 +76,7 @@ public class PersistentNestedStateTest extends TestCase {
nested.setVectorState("init"); // set init state
PersistentFailer failer = conf.getActiveObject(PersistentFailer.class);
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", nested, failer); // call failing transactionrequired method
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", nested, failer); // call failing transactional method
fail("should have thrown an exception");
} catch (RuntimeException e) {
} // expected
@ -89,7 +89,7 @@ public class PersistentNestedStateTest extends TestCase {
PersistentStatefulNested nested = conf.getActiveObject(PersistentStatefulNested.class);
stateful.setRefState("init"); // set init state
nested.setRefState("init"); // set init state
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state", nested); // transactionrequired
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state", nested); // transactional
assertEquals("new state", stateful.getRefState());
assertEquals("new state", nested.getRefState());
}
@ -101,7 +101,7 @@ public class PersistentNestedStateTest extends TestCase {
nested.setRefState("init"); // set init state
PersistentFailer failer = conf.getActiveObject(PersistentFailer.class);
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", nested, failer); // call failing transactionrequired method
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", nested, failer); // call failing transactional method
fail("should have thrown an exception");
} catch (RuntimeException e) {
} // expected

View file

@ -61,11 +61,12 @@ public class PersistentStateful {
return msg;
}
public void success(String key, String msg, PersistentStatefulNested nested) {
public String success(String key, String msg, PersistentStatefulNested nested) {
mapState.put(key, msg);
vectorState.add(msg);
refState.swap(msg);
nested.success(key, msg);
return msg;
}

View file

@ -46,10 +46,11 @@ public class PersistentStatefulNested {
}
public void success(String key, String msg) {
public String success(String key, String msg) {
mapState.put(key, msg);
vectorState.add(msg);
refState.swap(msg);
return msg;
}