public void testVectorShouldRollbackStateForStatefulServerInCaseOfFailure() { InMemStateful stateful = conf.getInstance(InMemStateful.class); stateful.setVectorState("init"); // set init state InMemFailer failer = conf.getInstance(InMemFailer.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()); // check that state is == init state }
public void testRefShouldNotRollbackStateForStatefulServerInCaseOfSuccess() { InMemStateful stateful = conf.getInstance(InMemStateful.class); stateful.setRefState("init"); // set init state stateful.success( "testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state"); // transactionrequired assertEquals("new state", stateful.getRefState()); }
protected void setUp() { Config.config(); conf.configure( new RestartStrategy(new AllForOne(), 3, 5000), new Component[] { new Component( InMemStateful.class, new LifeCycle(new Permanent()), // new RestartCallbacks("preRestart", "postRestart")), 10000), new Component(InMemFailer.class, new LifeCycle(new Permanent()), 10000) }) .inject() .supervise(); InMemStateful stateful = conf.getInstance(InMemStateful.class); stateful.init(); }
protected void tearDown() { conf.stop(); }