/*
 * Copyright (c) 2013 Hal Hildebrand, all rights reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.hellblazer.tron;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import org.junit.Test;

import com.hellblazer.tron.examples.simpleProtocol.BufferHandler;
import com.hellblazer.tron.examples.simpleProtocol.SimpleFsm;
import com.hellblazer.tron.examples.simpleProtocol.SimpleProtocol;
import com.hellblazer.tron.examples.simpleProtocol.impl.SimpleProtocolImpl;
import com.hellblazer.tron.examples.simpleProtocol.stateMaps.Simple;
import com.hellblazer.tron.examples.simpleProtocol.stateMaps.SimpleClient;

/**
 * 
 * @author hhildebrand
 * 
 */
public class TestSimple {
    @Test
    public void testIt() {
        SimpleProtocol protocol = new SimpleProtocolImpl();
        Fsm<SimpleProtocol, SimpleFsm> fsm = Fsm.construct(protocol,
                                                           SimpleFsm.class,
                                                           Simple.INITIAL, true);
        assertNotNull(fsm);
        BufferHandler handler = new BufferHandler();
        fsm.getTransitions().connected(handler);
        assertEquals(handler, ((SimpleProtocolImpl) protocol).getHandler());
        assertEquals(SimpleClient.CONNECTED, fsm.getCurrentState());
        fsm.getTransitions().writeReady();
        assertEquals(SimpleClient.ESTABLISH_SESSION, fsm.getCurrentState());
        fsm.getTransitions().readReady();
        assertEquals(SimpleClient.SEND_MESSAGE, fsm.getCurrentState());
        fsm.getTransitions().sendGoodbye();
        assertEquals(SimpleClient.SEND_GOODBYE, fsm.getCurrentState());
        fsm.getTransitions().readReady();
        assertEquals(Simple.CLOSED, fsm.getCurrentState());
    }
}

@@ -1565,16 +1565,652 @@
  true);%0A
+        verifyFsmStates(fsm, protocol);%0A    %7D%0A    %0A    @Test%0A    public void testItWithCustomClassLoader() %7B%0A        SimpleProtocol protocol = new SimpleProtocolImpl();%0A        Fsm%3CSimpleProtocol, SimpleFsm%3E fsm = Fsm.construct(protocol,%0A                                                           SimpleFsm.class,%0A                                                           SimpleFsm.class.getClassLoader(),%0A                                                           Simple.INITIAL, true);%0A        verifyFsmStates(fsm, protocol);%0A    %7D%0A    %0A    private void verifyFsmStates(Fsm%3CSimpleProtocol, SimpleFsm%3E fsm, SimpleProtocol protocol) %7B%0A
         

Add test for custom ClassLoader