<?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="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('570');
assertions[i++] = init_assertion('566');
assertions[i++] = init_assertion('562');

add_2_assert_trace('572');
add_2_assert_trace('573');
add_2_assert_trace('568');
add_2_assert_trace('569');
add_2_assert_trace('564');
add_2_assert_trace('565');

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_570" state="ASSERTION_NMBR_570">
			<conf:comment expr="'Event: ' + event$.name"/>
			<!--
570  	
9.3.5 error.send.failed  	
An error.send.failed event MUST be thrown when a <send> could not be completed for a reason not covered by another error.send.* event.  	
mscott@voicegenie.com  	Accepted  	


-->
			<send targettype="'basichttp'" target="'9_2_5_B_500.jsp'" name="'user.ass_570'" sendid="send_id_1"/>
		</transition>
		<transition event="error.send.failed" state="ASSERTION_NMBR_570">
			<conf:comment expr="'Event: ' + event$.name + ' Reason=' + event$.reason"/>
			<script>assertions[assert_index].P_F = s_PASS;
				</script>

			<!--
572 	
9.3.5 error.send.failed 	
An error.send.failed event MUST have a sendid property that is the ID of the affected event 	
mscott@voicegenie.com 	Accepted 	
-->
			<assign name="ASSERTION_NUM" expr="'572'"/>
			<if cond="event$.sendid==send_id_1">
				<conf:pass/>
				<else/>
				<script>t_ASSERT_REASON = 'expected ID='+send_id_1 + ' Got ID=' + event$.sendid</script>
				<conf:fail reason="t_ASSERT_REASON"/>
			</if>
<!--
573 	
9.3.5 error.send.failed 	
An error.send.failed event MUST have a reason property that describes the reason the operation was denied 	
mscott@voicegenie.com 	Accepted
-->
			<assign name="ASSERTION_NUM" expr="'573'"/>
			<if cond="event$.reason==undefined">
				<script>t_ASSERT_REASON = 'event$.reason is undefined.'</script>
				<conf:fail reason="t_ASSERT_REASON"/>
				<else/>
				<conf:pass/>
			</if>

			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>
		<transition event="user.ass_570" state="ASSERTION_NMBR_570">
			<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_566" state="ASSERTION_NMBR_566">
			<conf:comment expr="'Event: ' + event$.name"/>
			<!--
566  	
9.3.4 error.send.targettypeinvalid  	
An error.send.targettypeinvalid event MUST be thrown when the targettype attribute specified in a <send> is not valid  	mscott@voicegenie.com  	Accepted  	

-->
			<send targettype="'my_basichttp'" target="uri_UNREACHEABLE" name="'user.ass_566'" sendid="send_id_1"/>
		</transition>
		<transition event="error.send.targettypeinvalid" state="ASSERTION_NMBR_566">
			<conf:comment expr="'Event: ' + event$.name + ' Reason=' + event$.reason"/>
			<script>assertions[assert_index].P_F = s_PASS;
				</script>
<!--
568 	
9.3.4 error.send.targettypeinvalid 	
An error.send.targettypeinvalid event MUST have a sendid property that is the ID of the affected event 	mscott@voicegenie.com 	Accepted 	
-->
			<assign name="ASSERTION_NUM" expr="'568'"/>
			<if cond="event$.sendid==send_id_1">
				<conf:pass/>
				<else/>
				<script>t_ASSERT_REASON = 'expected ID='+send_id_1 + ' Got ID=' + event$.sendid</script>
				<conf:fail reason="t_ASSERT_REASON"/>
			</if>


<!--
569 	
9.3.4 error.send.targettypeinvalid 	
An error.send.targettypeinvalid event MUST have a reason property that describes the reason the operation was denied 	mscott@voicegenie.com 	Accepted
-->

			<assign name="ASSERTION_NUM" expr="'569'"/>
			<if cond="event$.reason==undefined">
				<script>t_ASSERT_REASON = 'event$.reason is undefined.'</script>
				<conf:fail reason="t_ASSERT_REASON"/>
				<else/>
				<conf:pass/>
			</if>

			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>


		<transition event="user.START_ASSERTION_562" state="ASSERTION_NMBR_562">
			<conf:comment expr="'Event: ' + event$.name"/>
			<!--
9.3.3 error.send.targetunavailable  	
An error.send.targetunavailable event MUST be thrown when CCXML could not send the event to the target listed in <send> due to it currently being unavailable  	mscott@voicegenie.com  	Accepted  	

-->
			<send targettype="'ccxml'" target="'not_available'" name="'user.ass_562'" sendid="send_id_1"/>
		</transition>
		
		<transition event="error.send.failed" state="ASSERTION_NMBR_562">
			<script>assertions[assert_index].P_F = s_FAIL;
					assertions[assert_index].reason = "expecting event error.send.targetunavailable"</script>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>
		
		<transition event="error.send.targetunavailable" state="ASSERTION_NMBR_562">
			<conf:comment expr="'Event: ' + event$.name + ' Reason=' + event$.reason"/>
			<script>assertions[assert_index].P_F = s_PASS;
				</script>
<!--
564 	
9.3.3 error.send.targetunavailable 	
An error.send.targetunavailable event MUST have a sendid property that is the ID of the affected event 	mscott@voicegenie.com 	Accepted 	
Accepted 	
-->
			<assign name="ASSERTION_NUM" expr="'564'"/>
			<if cond="event$.sendid==send_id_1">
				<conf:pass/>
				<else/>
				<script>t_ASSERT_REASON = 'expected ID='+send_id_1 + ' Got ID=' + event$.sendid</script>
				<conf:fail reason="t_ASSERT_REASON"/>
			</if>


<!--
565 	
9.3.3 error.send.targetunavailable 	
An error.send.targetunavailable event MUST have a reason property that describes the reason the operation was denied 	mscott@voicegenie.com 	-->

			<assign name="ASSERTION_NUM" expr="'565'"/>
			<if cond="event$.reason==undefined">
				<script>t_ASSERT_REASON = 'event$.reason is undefined.'</script>
				<conf:fail reason="t_ASSERT_REASON"/>
				<else/>
				<conf:pass/>
			</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>
