<?xml version="1.0" encoding="UTF-8"?>
<ccxml xmlns="http://www.w3.org/2002/09/ccxml" xmlns:conf="http://www.w3.org/2005/ccxml-conformance" version="1.0">
    <!--
      <conf:fail reason="'Unexpected Event ' + event$.name"/>
-->
    <conf:docsetup/>
    <var name="chld_reason"/>
    <var name="general_connid"/>
    <script>
	   function GetMilliseconds() {
     var d = new Date();
     return d.getTime();  // ms from midnight on Jan 1, 2000.
   }

var t_start, t_end, t_delay = 2000, t_delta, t_delta_e = 0.05 * t_delay;
		   </script>
    <script>

var i=0;
assertions[i++] = init_assertion('962');

add_2_assert_trace('962');


var assert_last = i - 1;
var assert_index = -1;
//
// out of the loop assertions (children?)
//
//
s_ASSERTIONS_LEFT = show_remained_assertions();
var b_in_test = false;


</script>
    <eventprocessor statevariable="current_state">
        <conf:setup type="noconnection"/>
        
        <transition event="ccxml.loaded">
	        <send targettype="'ccxml'" target="session.id" name="'user.timeout'" delay="TEST_LONG_TIMEOUT"/>
            <send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>     
        </transition>
        
        <transition event="connection.alerting" state="init">

            <accept connectionid="event$.connectionid"/>
        </transition>
        
        <transition event="connection.connected" state="init">
            <send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
        </transition>
        
        <transition event="user.PREPARE_NEW">
            <conf:comment expr="'Event: ' + event$.name"/>
            <if cond="assert_index >= 0">
                <assign name="ASSERTION_NUM" expr="assertions[assert_index].number"/>
                <assign name="t_ASSERT_RESULT" expr="assertions[assert_index].P_F"/>
                <script>t_ASSERT_REASON = assertions[assert_index].reason</script>
                <if cond="t_ASSERT_RESULT == s_PASS">
                    <conf:pass reason="t_ASSERT_REASON"/>
                    <elseif cond="t_ASSERT_RESULT == s_FAIL"/>
                    <conf:fail reason="t_ASSERT_REASON"/>
                    <else/>
                    <conf:not_exec reason="t_ASSERT_REASON"/>
                </if>
            </if>
            <assign name="assert_index" expr="assert_index + 1"/>
            <if cond="assert_index > assert_last">
                <log label="s_TA" expr="s_ASSERTIONS_LEFT"/>
                <conf:uncond_exit expr="'DONE'"/>
                <else/>
                <log label="s_TA" expr="s_ASSERTIONS_LEFT"/>
                <assign name="ASSERTION_NUM" expr=" assertions[assert_index].number"/>
                <assign name="t_ASSERT_REASON" expr="''"/>
                <script>assertions[assert_index].P_F = s_FAIL;</script>
                <assign name="current_state" expr="state_prefix + ASSERTION_NUM"/>
                <send targettype="'ccxml'" target="session.id" name="start_name_prefix + ASSERTION_NUM" sendid="cur_event_ID"/>
                <log label="s_TA" expr="'Loop event: SendID=' + cur_event_ID"/>
            </if>
        </transition>
        
        <transition event="user.START_ASSERTION_962" state="ASSERTION_NMBR_962">
<!--
962  	
10.5.7.1  	
Any Connections or Dialogs referenced by the 'id1' and 'id2' attributes of join MUST be owned by the session performing the join.  	
rachel.muller@aspect.com  	Accepted
-->      
            <createcall dest="TEST_CREATECALL_DEST_ANSWER_AND_STAY_ACTIVE[0]" connectionid="general_connid"/>
        </transition>

        <transition event="connection.connected" state="ASSERTION_NMBR_962">
            <conf:comment expr="'Event: ' + event$.name"/>
            <join id1="session.values.sessionOneConnID" id2="general_connid"/>
        </transition>
        
        <transition event="conference.joined" state="ASSERTION_NMBR_962">
            <conf:comment expr="'Event: ' + event$.name"/>
            <script>assertions[assert_index].P_F = s_FAIL;
                    assertions[assert_index].reason = 'join used with illegal connection values; expecting error...';</script>
            <disconnect connectionid="general_connid"/>
        </transition>
        
        <transition event="error.conference.join" state="ASSERTION_NMBR_962">
            <script>assertions[assert_index].P_F = s_PASS;</script>
            <disconnect connectionid="general_connid"/>
        </transition>

        <transition event="connection.disconnected" state="ASSERTION_NMBR_962">
            <send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
        </transition>
        
<!--======================================================== All-purpose handlers ========================================================-->		
        <transition event="connection.progressing">
            <conf:comment expr="'Event: ' + event$.name"/>
        </transition>

		<transition event="conference.created">
            <conf:comment expr="'Event: ' + event$.name"/>
        </transition>

        <transition event="conference.destroyed">
            <conf:comment expr="'Event: ' + event$.name"/>
        </transition>

        <transition event="conference.unjoined">
            <conf:comment expr="'Event: ' + event$.name"/>
        </transition>

        <transition event="error.conference.destroy">
            <conf:comment expr="'Event: ' + event$.name"/>
        </transition>

        <transition event="user.timeout">
            <assign name="current_state" expr="'GEN'"/>
            <conf:uncond_exit expr="'TEST-TIMEOUT.' + show_remained_assertions()"/>
        </transition>

        <transition event="send.successful">
        </transition>

        <transition event="cancel.successful">
            <conf:comment expr="'Event: ' + event$.name + ' (generic handler) state=' + current_state"/>
        </transition>

        <transition event="*">
            <assign name="t_ASSERT_REASON" expr="'UNEXPECTED EVENT ' + event$.name + ' IN STATE ' + current_state"/>
            <conf:comment expr="t_ASSERT_REASON + ' : ' + event$.reason"/>
            <if cond="current_state == 'init'">
                <conf:uncond_exit expr="'Did not come out from init state.'"/>
                <else/>
                <if cond="current_state != 'GEN'">
                    <send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
                </if>
            </if>
        </transition>
    </eventprocessor>
    
</ccxml>
