<?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">

<!--
Release 1.1 - 2010-06-17
FIXED: 

ISSUE 690 - deleted TA #852 (rejected)
-->

    <conf:docsetup/>
    <var name="chld_reason"/>
    <var name="general_connid"/>
    <var name="general_connid2"/>
	<var name="confid"/>
	<var name="confName" expr="'an_awesome_conference'"/>

	<var name="A56_timer_event"/>
    <var name="A61_confid2"/>
	<var name="conf_MAX_PART" expr="1000000000"/>

    <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('56');
assertions[i++] = init_assertion('58');
assertions[i++] = init_assertion('59');
assertions[i++] = init_assertion('61');
assertions[i++] = init_assertion('62');
assertions[i++] = init_assertion('65');
assertions[i++] = init_assertion('68');
assertions[i++] = init_assertion('1112');

add_2_assert_trace('55');
add_2_assert_trace('60');
add_2_assert_trace('63');
add_2_assert_trace('66');


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="alerting"/>
        
        <transition event="connection.alerting" state="init">
            <conf:comment expr="'Event: ' + event$.name"/>
            <send targettype="'ccxml'" target="session.id" name="'user.timeout'" delay="TEST_LONG_TIMEOUT"/>
            <accept connectionid="event$.connectionid"/>
        </transition>
        
        <transition event="connection.connected" state="init">
            <conf:comment expr="'Event: ' + event$.name"/>
            <assign name="general_connid" expr="event$.connectionid"/>
            <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_56" state="ASSERTION_NMBR_56">
            <!--
56
10.5.5.1
The successful execution of <createconference> MUST result in the generation of a conference.created event.  	
rachel.muller@aspect.com  	Accepted
-->
            <createconference conferenceid="confid"/>
            <send targettype="'ccxml'" target="session.id" name="'user.A56_failed'" delay="'2s'" sendid="A56_timer_event"/>
        </transition>

        <transition event="conference.created" state="ASSERTION_NMBR_56">
            <conf:comment expr="'Event: ' + event$.name"/>
            <cancel sendid="A56_timer_event"/>
            <script>assertions[assert_index].P_F = s_PASS</script>
            <assign name="ASSERTION_NUM" expr="'55'"/>
            <!--
55
10.5.5.1  	
A <createconference> instructs the implementation to allocate a Conference Object
rachel.muller@aspect.com  	Accepted

-->
            <if cond="event$.conference.objecttype == 'conference'">
                <conf:pass/>
                <else/>
                <assign name="chld_reason" expr="'type of conference object in event$.conference is ' + event$.conference.objecttype + '; should be object.'"/>
                <conf:fail reason="chld_reason"/>
            </if>

            <destroyconference conferenceid="confid"/>
        </transition>
        
       <transition event="conference.destroyed" state="ASSERTION_NMBR_56">
            <conf:comment expr="'Event: ' + event$.name"/>
            <assign name="current_state" expr="'GEN'"/>
            <send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
        </transition>
        
        <transition event="error.conference.destroy" state="ASSERTION_NMBR_56">
            <conf:comment expr="'Event: ' + event$.name"/>
            <assign name="current_state" expr="'GEN'"/>
            <send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
        </transition>
        
        <transition event="user.A56_failed" state="ASSERTION_NMBR_56">
            <conf:comment expr="'Event: ' + event$.name"/>
            <script>assertions[assert_index].P_F = s_FAIL;
					assertions[assert_index].reason = 'conference.created event should have been thrown.';</script>
            <assign name="current_state" expr="'GEN'"/>
            <send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
        </transition>


		<transition event="user.START_ASSERTION_58" state="ASSERTION_NMBR_58">
<!--
58
10.5.5.2
A <createconference> must have a conferenceid attribute which is an ECMAScript left hand side expression evaluating to a previously defined variable. The value of the attribute must receive the conference identifier.  	
rachel.muller@aspect.com  	Accepted
-->
			<createccxml next="'10_5_5_A_58.ccxml'"/>
		</transition>

		<transition event="error.createccxml" state="ASSERTION_NMBR_58">
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>

		<transition event="ccxml.created" state="ASSERTION_NMBR_58">
			<script>assertions[assert_index].P_F = s_FAIL;
					assertions[assert_index].reason = 'a createconference tag without a conferenceid attribute was successfully compiled';</script>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>

        <transition event="user.START_ASSERTION_59" state="ASSERTION_NMBR_59">
<!--
59
10.5.5.2
A <createconference> may have a confname attribute which is an ECMAScript expression which returns a string that is the name of the conference. The conference name corresponds to the conference identifier that will be returned in the variable specified in the conferenceid attribute.
rachel.muller@aspect.com  	Accepted 
-->

<!--
60  	
10.5.5.2  	
If the named conference does not exist, the platform must create a conference object as requested and return the value of the conference identifier to the variable specified in the conferenceid attribute.  	
rachel.muller@aspect.com  	Accepted
-->
            <createconference conferenceid="confid" confname="confName"/>
        </transition>

        <transition event="conference.created" state="ASSERTION_NMBR_59">
            <conf:comment expr="'Event: ' + event$.name"/>
			
			<assign name="ASSERTION_NUM" expr="'60'"/>
            <if cond="event$.conference == undefined">
                <conf:fail reason="'event$.conference variable is undefined.'"/>
            <elseif cond="confid==event$.conference.conferenceid"/>
                <conf:pass/>
            <else/>
                <conf:fail reason="'variable confid is ' + confid + '; conferenceid event$.conference.conferenceid is ' + event$.conference.conferenceid"/>
            </if>

            <if cond="session.conferences[confid] == undefined">
				<script>assertions[assert_index].P_F = s_FAIL;
						assertions[assert_index].reason = 'session.conferences[confid] is undefined.';</script>
            <elseif cond="confName==session.conferences[confid].conferencename"/>
                <script>assertions[assert_index].P_F = s_PASS;</script> 
            <else/>
				<script>assertions[assert_index].P_F = s_FAIL;
						assertions[assert_index].reason = 'variable confName is ' + confName + '; conference name session.conferences[confid].conferencename is ' + session.conferences[confid].conferencename;</script>
            </if>

            <destroyconference conferenceid="confid"/>
		</transition>
		
		<transition event="conference.destroyed" state="ASSERTION_NMBR_59">
            <conf:comment expr="'Event: ' + event$.name"/>
            <send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
        </transition>
        
        <transition event="user.START_ASSERTION_61" state="ASSERTION_NMBR_61">
            <!--
61
10.5.5.2
If a conference already exists the platform must return the conference identifier of the previously created conference.  	
rachel.muller@aspect.com  	Accepted
-->
            <createconference conferenceid="confid" confname="confName"/>
        </transition>
        
        <transition event="conference.created" state="ASSERTION_NMBR_61">
            <conf:comment expr="'Event: ' + event$.name"/>
            <assign name="A61_confid2" expr="confid"/>
            <assign name="current_state" expr="'ASSERTION_NMBR_61_IN_PROGRESS'"/>
            <createconference conferenceid="confid" confname="confName"/>
        </transition>
        
        <transition event="conference.created" state="ASSERTION_NMBR_61_IN_PROGRESS">  
            <conf:comment expr="'Event: ' + event$.name"/>
            <if cond="confid==A61_confid2">
                <script>assertions[assert_index].P_F = s_PASS;</script>
                <else/>
                <script>assertions[assert_index].P_F = s_FAIL;
						assertions[assert_index].reason = 'A conference was created twice with the same name ; the two IDs returned should have been the same, but they are different: first is ' + A61_confid2 + ', second is ' + confid + '.'</script>
            </if>
            <destroyconference conferenceid="confid"/>
		</transition>

		<transition event="conference.destroyed" state="ASSERTION_NMBR_61_IN_PROGRESS">
			<conf:comment expr="'Event: ' + event$.name"/>
            <send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
        </transition>
        
        <transition event="user.START_ASSERTION_62" state="ASSERTION_NMBR_62">
            <!--
62  	
10.5.5.2  	
A <createconference> may have a reservedtalkers attribute which is an ECMAScript expression which returns the number of guaranteed speaker slots the conference mixer must reserve.  	
rachel.muller@aspect.com  	Accepted
-->
            <createconference conferenceid="confid" reservedtalkers="1" confname="confName"/>
        </transition>

        <transition event="conference.created" state="ASSERTION_NMBR_62">
            <conf:comment expr="'Event: ' + event$.name"/>
            <script>assertions[assert_index].P_F = s_PASS;</script>
            <assign name="current_state" expr="'ASSERTION_NMBR_63'"/>
            <!--			
63  	
10.5.5.2  	
If the conference already exists, then the reservedtalkers attribute must be ignored.  	
sshah@genesyslab.com  	Accepted
-->
            <assign name="ASSERTION_NUM" expr="'63'"/>
			<assign name="current_state" expr="'ASSERTION_NMBR_63'"/>
            <createconference conferenceid="confid" reservedtalkers="conf_MAX_PART" confname="confName"/>
        </transition>

        <transition event="conference.created" state="ASSERTION_NMBR_63">
            <conf:comment expr="'Event: ' + event$.name"/>
            <conf:pass/>
            <destroyconference conferenceid="confid"/>
        </transition>

        <transition event="error.conference.create" state="ASSERTION_NMBR_63">
            <conf:comment expr="'Event: ' + event$.name"/>
            <assign name="chld_reason" expr="'in the case that a conference is created twice with the same name, the reservedtalkers attribute should be ignored the second time, but it was not ignored.'"/>
            <conf:fail reason="chld_reason"/>
			<destroyconference conferenceid="confid"/>
		</transition>

		<transition event="conference.destroyed" state="ASSERTION_NMBR_63">
            <conf:comment expr="'Event: ' + event$.name"/>
            <send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
        </transition>


        <transition event="user.START_ASSERTION_65" state="ASSERTION_NMBR_65">
            <!--
65
10.5.5.2
A <createconference> may have a reservedlisteners attribute which is an ECMAScript expression which returns the number of guaranteed listener slots the conference mixer must reserve.  	
rachel.muller@aspect.com  	Accepted
-->
            <createconference conferenceid="confid" reservedlisteners="1"/>
        </transition>

        <transition event="conference.created" state="ASSERTION_NMBR_65">
            <conf:comment expr="'Event: ' + event$.name"/>
            <script>assertions[assert_index].P_F = s_PASS;</script>
            <assign name="current_state" expr="'ASSERTION_NMBR_66'"/>
            <!--
66  	
10.5.5.2
If the conference already exists, then the reservedlisteners attribute must be ignored.  	
sshah@genesyslab.com  	Accepted
-->
            <assign name="ASSERTION_NUM" expr="'66'"/>
            <createconference conferenceid="confid" reservedtalkers="conf_MAX_PART" confname="confName"/>
        </transition>

        <transition event="conference.created" state="ASSERTION_NMBR_66">
            <conf:comment expr="'Event: ' + event$.name"/>
            <conf:pass/>
            <destroyconference conferenceid="confid"/>
        </transition>

        <transition event="error.conference.create" state="ASSERTION_NMBR_66">
            <conf:comment expr="'Event: ' + event$.name"/>
            <assign name="chld_reason" expr="'in the case that a conference is created twice with the same name, the reservedlisteners attribute should be ignored the second time, but it was not ignored.'"/>
            <conf:fail reason="chld_reason"/>
			<destroyconference conferenceid="confid"/>
		</transition>
		
		<transition event="conference.destroyed" state="ASSERTION_NMBR_66">
            <send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
        </transition>


        <transition event="user.START_ASSERTION_68" state="ASSERTION_NMBR_68">
<!--
68
10.5.5.2
A <createconference> may have a hints attribute which is the ECMAScript object returned contains information which may be used by the implementing platform when creating the conference.  	
rachel.muller@aspect.com  	Accepted -->

            <script>var Hints = new Object;
					Hints.headers = new Object();
					Hints.headers['x-headerOne'] = 'one'</script>
            <createconference conferenceid="confid" hints="Hints"/>
        </transition>

        <transition event="conference.created" state="ASSERTION_NMBR_68">
            <conf:comment expr="'Event: ' + event$.name"/>
            <script>assertions[assert_index].P_F = s_PASS;</script>
            <destroyconference conferenceid="confid"/>
		</transition>

		<transition event="conference.destroyed" state="ASSERTION_NMBR_68">
            <conf:comment expr="'Event: ' + event$.name"/>
            <send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
        </transition>


			
        <transition event="user.START_ASSERTION_1112" state="ASSERTION_NMBR_1112">
            <conf:comment expr="'Event: ' + event$.name"/>
            <createconference conferenceid="application.confid1"/>
        </transition>
        
        <transition event="conference.created" state="ASSERTION_NMBR_1112">
            <conf:comment expr="'Event: ' + event$.name"/>
            <fetch next="'10_5_5_A_1112.ccxml'"/>
        </transition>
        
        <transition event="fetch.done" state="ASSERTION_NMBR_1112">
            <conf:comment expr="'Event: ' + event$.name"/>
            <goto fetchid="event$.fetchid"/>
        </transition>

<!--======================================================== All-purpose handlers ========================================================-->		

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

        <transition event="conference.destroyed">
            <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>
