<?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="general_connid"/>
	<var name="A1077_passed"/>
	<var name="A1078_passed"/>

	<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('1067');

//children of 1067
add_2_assert_trace('1069');
add_2_assert_trace('1070');
add_2_assert_trace('1071');
add_2_assert_trace('1074');
add_2_assert_trace('1075');
add_2_assert_trace('1076');
add_2_assert_trace('1077');
add_2_assert_trace('1078');
add_2_assert_trace('1079');
add_2_assert_trace('1080');

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">
			<assign name="general_connid" expr="event$.connectionid"/>
		</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" sendid="cur_event_ID"/>
				<log label="s_TA" expr="'Loop event: SendID=' + cur_event_ID"/>
			</if>
		</transition>
		
		<transition event="user.START_ASSERTION_1067" state="ASSERTION_NMBR_1067">
<!--
1067  	
Appendix L - Session Creation Event I/O Processor  	
Implementation MUST support HTTP Post  	
rgreen@voxeo.com  	Accepted
-->
			<script>assertions[assert_index].P_F = s_PASS;</script>

<!--
1069  	
Appendix L - Session Creation Event I/O Processor  	
The http reserved parameter "uri" specifies the URI of the CCXML document to load. This parameter is required  	
rgreen@voxeo.com  	Accepted
-->
			<!-- by virtue of the fact that this test file was loaded, we can assume that the proper url was followed. -->
			<assign name="ASSERTION_NUM" expr="'1069'"/>
			<conf:pass/>
<!--
1070  	
Appendix L - Session Creation Event I/O Processor  	
The http reserved parameter "eventsource" specifies a URI to which events may be sent from the created session using, for example, the "basichttp" event processor. This parameter is optional.  	
rgreen@voxeo.com  	Accepted
-->
 			<assign name="ASSERTION_NUM" expr="'1070'"/>
			<conf:pass/>
				
<!--
1074  	
Appendix L - Session Creation Event I/O Processor  	
In the created session, session.startupmode MUST be set to "external"  	rgreen@voxeo.com  	Accepted
-->
			<assign name="ASSERTION_NUM" expr="'1074'"/>
			<if cond="session.startupmode == 'external'">
				<conf:pass/>
			<else/>
				<conf:fail reason="'session.startupmode should be \'external\' but is instead \'' + session.startupmode + '\'.'"/>
			</if>
<!--
1075  	
Appendix L - Session Creation Event I/O Processor  	
In the created session, session.uri MUST be set to the value of the uri parameter  	
rgreen@voxeo.com  	Accepted
-->
			<assign name="ASSERTION_NUM" expr="'1075'"/>
			<!-- the uri variable is set in the constants.es file -->
			<if cond="session.uri == uri">
				<conf:pass/>
			<else/>
				<conf:fail reason="'session.uri should be \'' + uri + '\', but is instead \'' + session.startupmode + '\'.'"/>
			</if>
<!--
1076  	
Appendix L - Session Creation Event I/O Processor  	
In the created session, session.values object MUST be defined  	
rgreen@voxeo.com  	Accepted			
-->
			<assign name="ASSERTION_NUM" expr="'1076'"/>
			
			<if cond="session.values != null">
				<conf:pass/>
			<else/>
				<conf:fail reason="'session.values should be defined, but isn\'t.'"/>
			</if>
<!--
1077  	
Appendix L - Session Creation Event I/O Processor  	
In the created session, session.values.type MUST be set to the value "createsession"  	
rgreen@voxeo.com  	Accepted
-->
			<assign name="ASSERTION_NUM" expr="'1077'"/>

			<if cond="session.values.type == 'createsession'">
				<conf:pass/>
				<assign name="A1077_passed" expr="true"/>
			<else/>
				<conf:fail reason="'session.values.type should have been \'createsession\', but was \'' + session.values.type + '\' instead.'"/>
			</if>
<!--
1078  	
Appendix L - Session Creation Event I/O Processor  	
In the created session, session.values.eventsource MUST be set to the value of the "eventsource" parameter  	
rgreen@voxeo.com  Accepted
-->

			<assign name="ASSERTION_NUM" expr="'1078'"/>
			
			<if cond="session.values.eventsource == session.ioprocessors['basichttp']">
				<conf:pass/>
				<assign name="A1078_passed" expr="true"/>
			<else/>
				<conf:fail reason="'session.values.eventsource should have been \'' + session.ioprocessors['basichttp'] + '\' but was \'' + session.values.eventsource + '\' instead.'"/>
			</if>
<!--	
1080  	
Appendix L - Session Creation Event I/O Processor  	
In the created session, to avoid conflict with the "type" and "eventsource" property of session.values object, payload parameters with the name "type" and "eventsource" are ignored.  	
rgreen@voxeo.com  	Accepted
-->
			<assign name="ASSERTION_NUM" expr="'1080'"/>
			
			<if cond="A1077_passed &amp;&amp; A1078_passed">
				<conf:pass/>
			<else/>
				<conf:fail reason="'payload properties for type and eventsource weren\'t ignored when they should have been.'"/>
			</if>
<!--
1079  	
Appendix L - Session Creation Event I/O Processor  	
In the created session, Other payload parameters are exposed as properties of session.values (complex parameter names require appropriate initialization of sub-objects).  	
rgreen@voxeo.com  	Accepted
-->
<!--
1071  	
Appendix L - Session Creation Event I/O Processor  	
Other parameters provided in the HTTP request are treated as the event payload. Single parameter values MUST be supported  	
rgreen@voxeo.com  	Accepted	
-->
			<assign name="ASSERTION_NUM" expr="'1079'"/>
			
			<if cond="session.values.foo == 'bar'">
				<conf:pass/>
				<assign name="ASSERTION_NUM" expr="'1071'"/>
				<conf:pass/>
			<else/>
				<conf:fail reason="'session.values.foo should have been \'bar\' but was \'' + session.values.foo + '\' instead.'"/>
				<assign name="ASSERTION_NUM" expr="'1071'"/>
				<conf:fail/>
			</if>
			
			<send name="name_prepare_new" targettype="'ccxml'" target="session.id"/>
			
		</transition>

<!-- ============================================================ All-purpose handlers ============================================================ -->

		<transition event="dialog.exit">
			<conf:comment expr="'Event: ' + event$.name"/>
		</transition>

		<transition event="">
			<conf:comment expr="'Event: ' + event$.name"/>
		</transition>

		<transition event="cancel.successful">
			<conf:comment expr="'Event: ' + event$.name"/>
		</transition>

		<transition event="dialog.started">
			<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">
			<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"/>
			<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>
