<?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="param1" expr="1"/>
	<var name="param2" expr="'hello'"/>
	<var name="chld_reason"/>
	<var name="send_id_1"/>
	<var name="DialogID"/>
	<var name="i_success"/>

	<script><![CDATA[
var i=0;
assertions[i++] = init_assertion('522');
assertions[i++] = init_assertion('520');
assertions[i++] = init_assertion('521');
assertions[i++] = init_assertion('1228');
assertions[i++] = init_assertion('519');
assertions[i++] = init_assertion('524');
assertions[i++] = init_assertion('1247');
assertions[i++] = init_assertion('531');

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_519" state="ASSERTION_NMBR_519">
			<!--
519  	9.2.3 &lt;send&gt;  	The <send> element MUST contain a target attribute that specifies the unique identifier of the event target 
				that the Event I/O processor must send the event to.    	
-->
			<conf:comment expr="'Event: ' + event$.name"/>
			<createccxml next="'522_J_assert_519_error.ccxml'" /> 
		</transition>

		<transition event="error.createccxml" state="ASSERTION_NMBR_519">
			<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_519">
			<conf:comment expr="'Event: ' + event$.name"/>
			<script>
			assertions[assert_index].P_F = s_FAIL;
			t_ASSERT_REASON = ' Got ccxml.created , expected error.createccxml.';
			</script>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>

		<transition event="user.START_ASSERTION_524" state="ASSERTION_NMBR_524">
			<!--
524 (522_J)	9.2.3 &lt;send&gt; 	The <send> element MUST specify the content of the message to be sent 
using either the name attribute with an optional namelist attribute that is a space-separated namelist
 of ECMAScript variables to include, or through inline XML content.
-->
			<conf:comment expr="'Event: ' + event$.name"/>
			<fetch next="'522_J_assert_524_error.ccxml'" /> 
		</transition>

		<transition event="error.fetch" state="ASSERTION_NMBR_524">
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>

		<transition event="fetch.done" state="ASSERTION_NMBR_524">
			<script>
			assertions[assert_index].P_F = s_FAIL;
			t_ASSERT_REASON  = ' Got fetch.done, expected error.fetch.';			
			</script>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>

		<transition event="user.START_ASSERTION_522" state="ASSERTION_NMBR_522">
			<!--
522 	9.2.3 &lt;send&gt; 	
Platforms MUST support a targettype attribute with a value of ccxml to target the CCXML 
				Session Event Processor. 		
-->
			<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="user.START_ASSERTION_520" state="ASSERTION_NMBR_520">
			<!--
520 	9.2.3 &lt;send&gt; 	
If the value of the target attribute is not supported, invalid, 
or unreachable by the Event I/O processor, 
the implementation must throw an error.send.targetunavailable event. 		
-->
			<send target="'blah'" targettype="'ccxml'" name="USER_ERROR"/>
		</transition>
		<transition event="error.send.targetunavailable" state="ASSERTION_NMBR_520">
			<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="user.START_ASSERTION_521" state="ASSERTION_NMBR_521">
			<!--
521 	9.2.3 &lt;send&gt; 	
The <send> element MAY contain a targettype attribute that specifies the Event I/O processor to 
which the event must be sent. 
if no targettype attribute is present, ccxml should be used.
-->
			<send target="session.id" name="'user.SEND_NO_TAG_TYPE'"/>
		</transition>
		<transition event="user.SEND_NO_TAG_TYPE" state="ASSERTION_NMBR_521">
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>



		<transition event="user.START_ASSERTION_1228" state="ASSERTION_NMBR_1228">
			<!--
1228 	9.2.3 &lt;send&gt; 	
If the targettype attribute on <send> is not supported, 
the platform MUST throw an error.send.targettypeinvalid event. 	mscott@voicegenie.com 	Accepted 	

-->
			<send targettype="'ccxml_invalid'" target="session.id" name="'just_dummy_message_assert_1228'"/>
		</transition>
		<transition event="error.send.targettypeinvalid" state="ASSERTION_NMBR_1228">
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>



		<transition event="user.START_ASSERTION_1247" state="ASSERTION_NMBR_1247">
			<!--
1247 	
9.2.3 &lt;send&gt; 	
The <send> element MAY contain a name attribute that indicates the type of event being generated, 
consisting of alphanumeric characters, with the exception of the first character which MUST NOT be a dot or a digit. 	
-->
			<send targettype="'ccxml'" target="session.id" name="'.name_prepare_new'"/>
		</transition>
		
		<transition event="error.send.*" state="ASSERTION_NMBR_1247">
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>



		<transition event="user.START_ASSERTION_531" state="ASSERTION_NMBR_531">
<!--
531 	
9.2.3 &lt;send&gt; 	
If the send request fails, an event signifying the error MUST be returned to the CCXML Session.
Request failed because of tartget timeout
-->
			<send targettype="'basichttp'" target="uri_UNREACHEABLE" name="'just_dummy_message_assert_531'"/>
		</transition>
		<transition event="error.send.*" state="ASSERTION_NMBR_531">
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>
		<transition event="send.successful">
		</transition>
		<transition event="user.timeout">
			<conf:uncond_exit expr="'TEST-TIMEOUT'"/>
		</transition>
		<!-- Loquendo mod 8 -->
		<transition event="*">
			<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>
		<!-- END Loquendo mod -->


	</eventprocessor>
</ccxml>
