<?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-07
FIXED: ISSUE-689 : Deleted TA 555.
-->

	<conf:docsetup/>
	<var name="ConnectionID" expr="undefined"/>
	<var name="VxmlFile2" expr="'TWO_2.vxml'"/>
	<var name="param1" expr="1"/>
	<var name="param2" expr="'hello'"/>
	<var name="chld_reason"/>
	<var name="send_id_1"/>
	<var name="DialogID"/>
	<var name="i_success"/>
	<var name="MY_BLANK" expr="''"/>
	<var name="MY_UNDEF_VAR"/>

	<var name="WKR_STRING"/>
	<script><![CDATA[
	   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><![CDATA[
var i=0;
assertions[i++] = init_assertion('550');
assertions[i++] = init_assertion('551');
assertions[i++] = init_assertion('552');
assertions[i++] = init_assertion('1254');
assertions[i++] = init_assertion('557');

add_2_assert_trace('554');
add_2_assert_trace('556');
add_2_assert_trace('1255');
add_2_assert_trace('580');
add_2_assert_trace('582');
add_2_assert_trace('559');
add_2_assert_trace('560');
add_2_assert_trace('561');

var ASSERT_ID;
var ASSERT_PASS_FAIL;
var EVENT_NAME;
var EVENT_NAME_PREFIX = 'EVENT_';

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">
			<send targettype="'ccxml'" target="session.id" name="'user.timeout'" delay="TEST_LONG_TIMEOUT"/>
			<accept connectionid="event$.connectionid"/>
		</transition>
		<transition event="connection.connected" state="init">
			<assign name="ConnectionID" 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 &gt;= 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 &gt; 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"/>
			</if>
		</transition>
		<transition event="user.START_ASSERTION_550" state="ASSERTION_NMBR_550">
			<conf:comment expr="'Event: ' + event$.name"/>
			<!--
550
9.2.5 &lt;cancel&gt;  	
The <cancel> element MUST contain a sendid attribute that is an ECMAScript expression evaluating to the event identifier of an event to be removed from the delayed event queue of the session performing the <cancel>  	mscott@voicegenie.com  	Accepted  	


-->
			<createccxml next="'9_2_5_A_cancel_no_att.cxml'"/>
		</transition>
		<transition event="error.createccxml" state="ASSERTION_NMBR_550">
			<conf:comment expr="'Event: ' + event$.name"/>
			<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_550">
			<conf:comment expr="'Event: ' + event$.name"/>
			<script>assertions[assert_index].P_F = s_FAIL;
			assertions[assert_index].reason = 'fetch of the document ' + event$.uri + ' containing cancel without sendid attribute should have failed.'  

				</script>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>
		<transition event="user.START_ASSERTION_551" state="ASSERTION_NMBR_551">
			<conf:comment expr="'Event: ' + event$.name"/>
			<!--
551 	
9.2.5 &lt;cancel&gt; 	
If the delay on the referenced event has already expired and the event has been delivered, then the <cancel> 
request MUST fail and an error.notallowed event MUST be generated 	mscott@voicegenie.com 	Accepted 	


-->
			<send targettype="'ccxml'" target="session.id" name="'user.ass_551'" sendid="send_id_1"/>
		</transition>
		<transition event="user.ass_551" state="ASSERTION_NMBR_551">
			<conf:comment expr="'Event: ' + event$.name"/>
			<cancel sendid="send_id_1"/>
		</transition>
		<transition event="error.notallowed" state="ASSERTION_NMBR_551">
			<conf:comment expr="'Event: ' + event$.name"/>
			<script>assertions[assert_index].P_F = s_PASS;
				</script>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>
		<transition event="cancel.successful" state="ASSERTION_NMBR_551">
			<conf:comment expr="'Event: ' + event$.name"/>
			<script>
			assertions[assert_index].P_F = s_FAIL;
			assertions[assert_index].reason = 'Expected event: error.notallowed, got:' + event$.name;
				</script>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>
		<transition event="user.START_ASSERTION_552" state="ASSERTION_NMBR_552">
			<conf:comment expr="'Event: ' + event$.name"/>
			<!--
552
9.3.1 error.notallowed  	
This error event is MUST be thrown when the execution of an element causes an invalid operation to be performed on a session and/or connection.  	mscott@voicegenie.com  	Accepted  	
			<reject connectionid="ConnectionID"/>

-->
			<cancel sendid="send_id_1"/>
		</transition>
		<transition event="error.notallowed" state="ASSERTION_NMBR_552">
			<conf:comment expr="'Event: ' + event$.name + ' ID=' + event$.id"/>
			<script>assertions[assert_index].P_F = s_PASS;
				</script>
			<!--
554
9.3.1 error.notallowed 	
An error.notallowed event MUST have a sessionid property set to the ID of the affected session 	mscott@voicegenie.com 	Accepted 	
-->
			<assign name="ASSERTION_NUM" expr="'554'"/>
			<if cond="event$.sessionid==session.id">
				<conf:pass/>
				<else/>
				<script>t_ASSERT_REASON = 'expected ID='+session.id + ' Got ID=' + event$.sessionid</script>
				<conf:fail reason="t_ASSERT_REASON"/>
			</if>
		
<!--
556
9.3.1 error.notallowed 	
An error.notallowed event MUST have a reason property that describes the reason the operation was denied 	mscott@voicegenie.com 	Accepted 	
-->
			<assign name="ASSERTION_NUM" expr="'556'"/>
			<if cond="event$.reason==undefined">
				<script>t_ASSERT_REASON = 'event$.reason is undefined'</script>
				<conf:fail reason="t_ASSERT_REASON"/>
				<else/>
				<conf:pass/>
			</if>
			<!--
1255 	
9.3.1 error.notallowed 	An error.notallowed event MUST have a tagname property set to the ECMAScript string value of the name of the element that produced the error (ie accept, reject, etc). 	mscott@voicegenie.com 	Accepted
-->
			<assign name="ASSERTION_NUM" expr="'1255'"/>
			<if cond="event$.tagname=='cancel'">
				<conf:pass/>
				<else/>
				<script>t_ASSERT_REASON = 'event$.tagname=' + event$.tagname + ' Expected: rejected'</script>
				<conf:fail reason="t_ASSERT_REASON"/>
			</if>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>
		<transition event="user.START_ASSERTION_1254" state="ASSERTION_NMBR_1254">
			<conf:comment expr="'Event: ' + event$.name"/>
			<!--
1254 	
9.2.5 &lt;cancel&gt; 	
9.2.5 &lt;cancel&gt; 	
If <cancel> is successful, a cancel.successful event MUST be delivered to indicate that the cancelled event was not delivered 	mscott@voicegenie.com 	Accepted 	


-->
			<send targettype="'ccxml'" target="session.id" name="'user.ass_1254'" sendid="send_id_1" delay="'1s'"/>
			<cancel sendid="send_id_1"/>
		</transition>
		<transition event="cancel.successful" state="ASSERTION_NMBR_1254">
			<conf:comment expr="'Event: ' + event$.name"/>
			<script>
			assertions[assert_index].P_F = s_PASS;
				</script>
<!--
9.3.8 cancel.successful  	
An cancel.successful event MUST be thrown when the sending of an event has been successfully cancelled.  	mscott@voicegenie.com  	Accepted  	
-->				
			<assign name="ASSERTION_NUM" expr="'580'"/>
				<conf:pass/>
<!--
582 	
9.3.8 cancel.successful 	
An cancel.successful event MUST have a sendid property that is the ID of the cancelled event 	mscott@voicegenie.com 	Accepted

-->
			<assign name="ASSERTION_NUM" expr="'582'"/>
				<conf:pass/>
	
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new" delay="'2s'"/>

		</transition>
		<transition event="user.ass_1254" state="ASSERTION_NMBR_1254">
			<conf:comment expr="'Event: ' + event$.name"/>
			<script>assertions[assert_index].P_F = s_FAIL;
			assertions[assert_index].reason = 'Event' + event$.name + ' arrived, though it has been canceled.' 
				</script>
		</transition>

		<transition event="user.START_ASSERTION_557" state="ASSERTION_NMBR_557">
			<conf:comment expr="'Event: ' + event$.name"/>
			<!--
557  	
9.3.2 error.semantic  	
An error.semantic MUST be thrown when there is a semantic error in a CCXML element  	mscott@voicegenie.com  	Accepted  	


-->
			<reject reason="'503'" connectionid="MY_UNDEF_VAR"/>
		</transition>

		<transition event="error.semantic" state="ASSERTION_NMBR_557">
			<conf:comment expr="'Event: ' + event$.name"/>
			<script>assertions[assert_index].P_F = s_PASS;
				</script>
<!--
559 	
9.3.2 error.semantic 	
An error.semantic event MUST have a reason property set to the ECMAScript string value of the printable error message associated with this error 	mscott@voicegenie.com 	Accepted 	

560 	
9.3.2 error.semantic 	
An error.semantic event MUST have a tagname property set to the name of the element that produced the error 	mscott@voicegenie.com 	Accepted 	

561 	
9.3.2 error.semantic 	
An error.semantic event MAY have an attributelist property that is an object 
whose properties are the names of the attributes of the element in error; 
the value of each such property MAY be set to the corresponding string value of the attribute 	mscott@voicegenie.com 	Accepted 	
-->				
			<assign name="ASSERTION_NUM" expr="'559'"/>
			<if cond="event$.reason==undefined">
				<script>t_ASSERT_REASON = 'event$.reason is undefined'</script>
				<conf:fail reason="t_ASSERT_REASON"/>
				<else/>
				<conf:pass/>
			</if>
			<assign name="ASSERTION_NUM" expr="'560'"/>
			<if cond="event$.tagname=='reject'">
				<conf:pass/>
				<else/>
				<script>t_ASSERT_REASON = 'event$.tagname is ' + event$.tagname + ' Expected: reject'</script>
				<conf:fail reason="t_ASSERT_REASON"/>
			</if>
			<assign name="ASSERTION_NUM" expr="'561'"/>
			<if cond="event$.property==undefined">
				<conf:pass/>
				<else/>
				<if cond="event$.property.reason=='503'">
					<conf:pass/>
				<else/>
					<script>t_ASSERT_REASON = 'event$.property.reason=' + event$.property.reason + ' Expected: 503'</script>
					<conf:fail reason="t_ASSERT_REASON"/>
				</if>
			</if>
				
				
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>

		<transition event="user.timeout">
			<conf:uncond_exit expr="'TEST-TIMEOUT'"/>
		</transition>
		<transition event="send.successful">
			<conf:comment expr="'Event: ' + event$.name + ' sendid=' + event$.sendid"/>
		</transition>
		<transition event="error.send.failed.">
			<conf:comment expr="'Event: ' + event$.name + ' sendid=' + event$.sendid"/>
		</transition>
		<transition event="send.*">
			<conf:comment expr="'Event (send*): ' + event$.name"/>
		</transition>
		<transition event="*">
			<conf:comment expr="'Event: ' + event$.name"/>
			<assign name="t_ASSERT_REASON" expr="'UNEXPECTED EVENT ' + event$.name + ' IN STATE ' + current_state"/>
			<conf:comment expr="t_ASSERT_REASON"/>
			<if cond="current_state == 'init'">
				<conf:uncond_exit expr="'Did not come out from init state.'"/>
				<else/>
				<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
			</if>
		</transition>
	</eventprocessor>
</ccxml>
