Package org.apache.mina.statemachine

Examples of org.apache.mina.statemachine.State


    Transition transition2;
    Transition transition3;

    @BeforeClass
    protected void setUp() throws Exception {
        state = new State("test");
        transition1 = (Transition) mock(Transition.class);
        transition2 = transition1; //(Transition) mock(Transition.class);
        transition3 = transition1; //(Transition) mock(Transition.class);
    }
View Full Code Here


    Object[] args;
   
    protected void setUp() throws Exception {
        super.setUp();
       
        currentState = new State( "current" );
        nextState = new State( "next" );
        target = (Target) mock(Target.class);
        subsetAllArgsMethod1 = Target.class.getMethod("subsetAllArgs", new Class[] {
                TestStateContext.class, B.class, A.class, Integer.TYPE
        });
        subsetAllArgsMethod2 = Target.class.getMethod("subsetAllArgs", new Class[] {
View Full Code Here

    public void testCreate() throws Exception {
        States states = new States();
        StateMachine sm = StateMachineFactory.getInstance(Transition.class).create(States.A, states);

        State a = sm.getState(States.A);
        State b = sm.getState(States.B);
        State c = sm.getState(States.C);
        State d = sm.getState(States.D);

        assertEquals(States.A, a.getId());
        assertNull(a.getParent());
        assertEquals(States.B, b.getId());
        assertSame(a, b.getParent());
        assertEquals(States.C, c.getId());
        assertSame(b, c.getParent());
        assertEquals(States.D, d.getId());
        assertSame(a, d.getParent());

        List<org.apache.mina.statemachine.transition.Transition> trans = null;

        trans = a.getTransitions();
        assertEquals(3, trans.size());
        assertEquals(new MethodTransition("bar", barInA, states), trans.get(0));
        assertEquals(new MethodTransition("*", error, states), trans.get(1));
        assertEquals(new MethodTransition("foo", b, fooInA, states), trans.get(2));
       
        trans = b.getTransitions();
        assertEquals(1, trans.size());
        assertEquals(new MethodTransition("foo", c, fooInB, states), trans.get(0));

        trans = c.getTransitions();
        assertEquals(3, trans.size());
        assertEquals(new MethodTransition("bar", a, barInC, states), trans.get(0));
        assertEquals(new MethodTransition("foo", d, fooOrBarInCOrFooInD, states), trans.get(1));
        assertEquals(new MethodTransition("bar", d, fooOrBarInCOrFooInD, states), trans.get(2));

        trans = d.getTransitions();
        assertEquals(1, trans.size());
        assertEquals(new MethodTransition("foo", fooOrBarInCOrFooInD, states), trans.get(0));
    }
View Full Code Here

    public void testCreate() throws Exception {
        States states = new States();
        StateMachine sm = StateMachineFactory.getInstance(Transition.class).create(States.A, states);

        State a = sm.getState(States.A);
        State b = sm.getState(States.B);
        State c = sm.getState(States.C);
        State d = sm.getState(States.D);

        assertEquals(States.A, a.getId());
        assertNull(a.getParent());
        assertEquals(States.B, b.getId());
        assertSame(a, b.getParent());
        assertEquals(States.C, c.getId());
        assertSame(b, c.getParent());
        assertEquals(States.D, d.getId());
        assertSame(a, d.getParent());

        List<org.apache.mina.statemachine.transition.Transition> trans = null;

        trans = a.getTransitions();
        assertEquals(3, trans.size());
        assertEquals(new MethodTransition("bar", barInA, states), trans.get(0));
        assertEquals(new MethodTransition("*", error, states), trans.get(1));
        assertEquals(new MethodTransition("foo", b, fooInA, states), trans.get(2));
       
        trans = b.getTransitions();
        assertEquals(1, trans.size());
        assertEquals(new MethodTransition("foo", c, fooInB, states), trans.get(0));

        trans = c.getTransitions();
        assertEquals(3, trans.size());
        assertEquals(new MethodTransition("bar", a, barInC, states), trans.get(0));
        assertEquals(new MethodTransition("foo", d, fooOrBarInCOrFooInD, states), trans.get(1));
        assertEquals(new MethodTransition("bar", d, fooOrBarInCOrFooInD, states), trans.get(2));

        trans = d.getTransitions();
        assertEquals(1, trans.size());
        assertEquals(new MethodTransition("foo", fooOrBarInCOrFooInD, states), trans.get(0));
    }
View Full Code Here

* @author <a href="http://mina.apache.org">Apache MINA Project</a>
*/
public class StateMachineTest extends TestCase {

    public void testBreakAndContinue() throws Exception {
        State s1 = new State("s1");
        s1.addTransition(new BreakAndContinueTransition("foo"));
        s1.addTransition(new SuccessTransition("foo"));

        StateContext context = new DefaultStateContext();
        StateMachine sm = new StateMachine(new State[] { s1 }, "s1");
        sm.handle(new Event("foo", context));
        assertEquals(true, context.getAttribute("success"));
View Full Code Here

        sm.handle(new Event("foo", context));
        assertEquals(true, context.getAttribute("success"));
    }
   
    public void testBreakAndGotoNow() throws Exception {
        State s1 = new State("s1");
        State s2 = new State("s2");
        s1.addTransition(new BreakAndGotoNowTransition("foo", "s2"));
        s2.addTransition(new SuccessTransition("foo"));

        StateContext context = new DefaultStateContext();
        StateMachine sm = new StateMachine(new State[] { s1, s2 }, "s1");
        sm.handle(new Event("foo", context));
        assertEquals(true, context.getAttribute("success"));
View Full Code Here

        sm.handle(new Event("foo", context));
        assertEquals(true, context.getAttribute("success"));
    }
   
    public void testBreakAndGotoNext() throws Exception {
        State s1 = new State("s1");
        State s2 = new State("s2");
        s1.addTransition(new BreakAndGotoNextTransition("foo", "s2"));
        s2.addTransition(new SuccessTransition("foo"));

        StateContext context = new DefaultStateContext();
        StateMachine sm = new StateMachine(new State[] { s1, s2 }, "s1");
        sm.handle(new Event("foo", context));
        assertSame(s2, context.getCurrentState());
View Full Code Here

    Transition transition2;
    Transition transition3;

    @BeforeClass
    protected void setUp() throws Exception {
        state = new State("test");
        transition1 = (Transition) mock(Transition.class);
        transition2 = transition1; //(Transition) mock(Transition.class);
        transition3 = transition1; //(Transition) mock(Transition.class);
    }
View Full Code Here

* @version $Rev: 586090 $, $Date: 2007-10-18 21:12:08 +0200 (Thu, 18 Oct 2007) $
*/
public class StateMachineTest extends TestCase {

    public void testBreakAndContinue() throws Exception {
        State s1 = new State("s1");
        s1.addTransition(new BreakAndContinueTransition("foo"));
        s1.addTransition(new SuccessTransition("foo"));

        StateContext context = new DefaultStateContext();
        StateMachine sm = new StateMachine(new State[] { s1 }, "s1");
        sm.handle(new Event("foo", context));
        assertEquals(true, context.getAttribute("success"));
View Full Code Here

        sm.handle(new Event("foo", context));
        assertEquals(true, context.getAttribute("success"));
    }
   
    public void testBreakAndGotoNow() throws Exception {
        State s1 = new State("s1");
        State s2 = new State("s2");
        s1.addTransition(new BreakAndGotoNowTransition("foo", "s2"));
        s2.addTransition(new SuccessTransition("foo"));

        StateContext context = new DefaultStateContext();
        StateMachine sm = new StateMachine(new State[] { s1, s2 }, "s1");
        sm.handle(new Event("foo", context));
        assertEquals(true, context.getAttribute("success"));
View Full Code Here

TOP

Related Classes of org.apache.mina.statemachine.State

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.