<?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-07-08
FIXED: 
ISSUE-680: TA 699,  TA 1014. 
ISSUE-691.1: minor TYPOs
ISSUE 670: 
- reason and sessionid added on TA 1165,710,711(2 cases),712 (2 cases),675 
- child_5.ccxml modified accordingly: cond="event$.sessionid == parentSessionid" instead of cond="event$.sessionid == session.id"
- TEST_VERY_LONG_TIMEOUT used instead of TEST_LONG_TIMEOUT
- TA 714 changed
-->

<!--
Release 1.1 - 2010-10-21
Consequently to ISSUE-725 fixed in child_9.ccxml we add a do-nothing transition for ccxml.exit thrown by session associated with child_9.ccxml 
-->	

<!--
Release 1.2 - 2011-03-25
FIXED:  TA 615 replaced 'errorNoneDeclared_615_1.ccxml' with 'errorFetchMeta615_1.ccxml'
-->	
	
	<!--
Serguei's infrastructure performs a loop on the 'assertions' Ecma array, based on "name_prepare_new" event for doing the "loop".

Mainly we have to different levels of assertions: 

- Main assertions, stored in 'assertions' array
- Children assertions, stored into 'assert_trace'

An assertion is a child assertion if it does not need to perform any action, but it is sufficient to test its father assertion result to determine if it passes or fails.

The test finishes when all the main assertions have been tested. Children assertions are tested after the father itself.

If an unexpected event is caught by the <transition event"*"/> a comment is printed and the loop continues with the next iteration.

An hang up event causes the interruption of test: session exits.

All the send.successful events are caught and ignored (they are generated by the loop mechanism).
-->
	<conf:docsetup/>
	<var name="DialogID" expr="undefined"/>
	<var name="ConferenceID" expr="undefined"/>
	<var name="ConnectionID" expr="undefined"/>

	<var name="childSessionId" expr="undefined"/>
	<var name="bFatherContinuesExecution" expr="false"/>
	<var name="eventSessionId" expr="undefined"/>
	<var name="mySendId" expr="undefined"/>
	<var name="myFetchId" expr="undefined"/>
	
	<!-- parameters to be passed in the new created session-->
	<var name ="varString" expr="'These are words that go together well'"/>
	<var name ="varNum" expr="3333"/>
	<var name="param1" expr="'A wonderful day'"/> <!-- parameter with blanks (TA 674) -->

	<!-- variables used to test TA 714 and 715 about sessionid and reason fields of ccxml.kill event : child session will fill the following boolean giving back a result  -->
	<var name="bTA_714passed" expr="false"/>
	<var name="bTA_715passed" expr="false"/>
	<var name="bTA_674passed" expr="false"/>
	
	<!-- FIXED ISSUE-670: reason variable declaration added -->
	<var name="reason" expr="'kill request'"/>
	

	<!-- to check document order evaluation before eventprocessor -->	
	  <var name="counter" expr="0"/>
	  <script>
		function next()
		{
		  ccxml.counter = ccxml.counter + 1;
		  return ccxml.counter;
		}
	  </script>
	  <var name="firstVar" expr="next()"/>
	  <var name="secondVar" expr="next()"/>


	 <meta name="copyright" content="2009 W3C"/>
	 <meta name="maintainer" content="mail@example.com"/>

 <!-- Metadata about CCXML document -->

	<metadata>
	   <rdf:RDF
		   xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
		   xmlns:dc = "http://purl.org/dc/elements/1.1/">
	
		   <rdf:Description 
			   about="http://www.example.com/meta.ccxml"
			   dc:title="Hamlet-like Soliloquy"
			   dc:description="Soliloquy in the style of Hamlet"
			   dc:publisher="W3C"
			   dc:language="en"
			   dc:date="2002-11-29"
			   dc:rights="Copyright 2002 Aldine Turnbet"
			   dc:format="application/ccxml+xml" >
			   <dc:creator>William Shakespeare</dc:creator>
			   <dc:creator>Aldine Turnbet</dc:creator>
		   </rdf:Description>
	  </rdf:RDF>
 </metadata>
 
	<script><![CDATA[
		var i=0;
		assertions[i++] = init_assertion('606');
		assertions[i++] = init_assertion('611');
		assertions[i++] = init_assertion('619');
		assertions[i++] = init_assertion('605');
		assertions[i++] = init_assertion('724');
		assertions[i++] = init_assertion('662');
		assertions[i++] = init_assertion('721');
		assertions[i++] = init_assertion('661');
		assertions[i++] = init_assertion('1163');
		assertions[i++] = init_assertion('1166');
		assertions[i++] = init_assertion('1164');
		assertions[i++] = init_assertion('1165');
		assertions[i++] = init_assertion('710');
		assertions[i++] = init_assertion('711');
		assertions[i++] = init_assertion('712');
		assertions[i++] = init_assertion('675');
		assertions[i++] = init_assertion('610');
		
		// meta and metadata with fetch
		assertions[i++] = init_assertion('622');
		assertions[i++] = init_assertion('617');
		assertions[i++] = init_assertion('615');
	
				
		var assert_last = i - 1;
		var assert_index = -1;
		//
		// out of the loop assertions (children)
		
		// Children of 606:  ccxml element
		add_2_assert_trace('607');
		add_2_assert_trace('608');
		add_2_assert_trace('609');
	
		
		// Children of 611 : meta element 
		add_2_assert_trace('612');
						
		// Children of 724 : error.createccxml event 
		add_2_assert_trace('725');
		
		// Children of 662 : createccxml element 
		add_2_assert_trace('669');
				
		// Children of 721 : ccxml.created event 
		add_2_assert_trace('658');
		add_2_assert_trace('665');
		add_2_assert_trace('671');
		add_2_assert_trace('673');			

		
		// Children of 661 : // on ccxml.loaded event, parent sessionid .		
		add_2_assert_trace('708');					
				
		// Children of 1166 : ccxml.exit element 
		add_2_assert_trace('698');
		add_2_assert_trace('699');
		add_2_assert_trace('701');
		add_2_assert_trace('1014');
		
		
		// Children of 711 : ccxml.kill event 
		add_2_assert_trace('714');
		add_2_assert_trace('715');
		add_2_assert_trace('674');
		
				
		s_ASSERTIONS_LEFT = show_remained_assertions();
		var b_in_test = false;
	]]></script>
	<eventprocessor statevariable="current_state">
		<conf:setup type="connected"/>
		<transition event="connection.connected" state="init">
			<assign name="ConnectionID" expr="event$.connectionid"/>
			<send targettype="'ccxml'" target="session.id" name="'user.timeout'" delay="TEST_VERY_LONG_TIMEOUT"/>
			<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>assertions[assert_index].reason = t_ASSERT_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>
		<!-- 606.
		The <ccxml> can designate the CCXML namespace. This can be achieved by declaring an xmlns attribute or an attribute with an " xmlns " prefix.
		
		607.
		Note that when the xmlns attribute is used alone, it sets the default namespace for the element on which it appears and for any child elements.
		
		608.
		The namespace URI for CCXML is "http://www.w3.org/2002/09/ccxml".
		
		609.
		The <ccxml> element must contain a version attribute. The initial version number is 1.0.
		
		-->
		<transition event="user.START_ASSERTION_606" state="ASSERTION_NMBR_606">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<!--Transitioning here means that all ccxml tests has been successfully passed --> 
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<!-- Children management -->
			<assign name="ASSERTION_NUM" expr="'607'"/>
			<conf:pass/>
			<assign name="ASSERTION_NUM" expr="'608'"/>
			<conf:pass/>
			<assign name="ASSERTION_NUM" expr="'609'"/>
			<conf:pass/>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>
		
<!-- 
611.
A CCXML document may contain a <meta> element.

612.
A <meta> element may conatin a name attribute indicating the name of the metadata information

-->
		<transition event="user.START_ASSERTION_611" state="ASSERTION_NMBR_611">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<!--Transitioning here means that all ccxml tests has been successfully passed --> 
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<!-- Children management -->
			<assign name="ASSERTION_NUM" expr="'612'"/>
			<conf:pass/>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>

<!-- 
619.

A CCXML document may contain a <metadata> element. <metadata> is a container in which information about the document can be placed using a metadata language.

-->
		<transition event="user.START_ASSERTION_619" state="ASSERTION_NMBR_619">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<!--Transitioning here means that all ccxml tests has been successfully passed --> 
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>
		<!-- TA 605  on metadata element -->
		<transition event="user.START_ASSERTION_605" state="ASSERTION_NMBR_605">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
		    <var name="thirdVar" expr="next()"/>
		    	<conf:comment expr=" 'Current state : ' + current_state + ' , firstVar: ' + firstVar"/>
		    	<conf:comment expr=" 'Current state : ' + current_state + ' , secondVar: ' + secondVar"/>
		    	<conf:comment expr=" 'Current state : ' + current_state + ' , thirdVar: ' + thirdVar"/>
			<if cond="firstVar ==1 &amp;&amp; secondVar ==2 &amp;&amp; thirdVar == 3">
				<script>assertions[assert_index].P_F = s_PASS;</script>
			<else/>
				<assign name="t_ASSERT_REASON" expr="'Invalid connectionid value: ' + event$.connectionid + ' in ' +  event$.name + ' event , STATE ' + current_state"/>
				<script>
					assertions[assert_index].P_F = s_FAIL;
					assertions[assert_index].reason = t_ASSERT_REASON;  
				</script>
			</if>
				<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>


<!--
724.
The error.createccxml event contains a sessionid property set to identifier of the failing CCXML session. This is the same identifier as was returned on the sessionid attribute of the <createccxml> request that created the session

725.
The error.createccxml event contains a reason property set the a string describing the error encountered
-->
		<transition event="user.START_ASSERTION_724" state="ASSERTION_NMBR_724">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<createccxml next="'doesntExist.ccxml'" sessionid="childSessionId"/>
		</transition>
		<transition event="error.createccxml" state="ASSERTION_NMBR_724">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<if cond="event$.sessionid == childSessionId">
				<script>assertions[assert_index].P_F = s_PASS;</script>
			<else/>
				<assign name="t_ASSERT_REASON" expr="'Invalid sessionid value: ' + event$.sessionid + ' in ' +  event$.name + ' event , STATE ' + current_state +' , it must be equal to sessionid of createccxml element : ' + childSessionId"/>
				<script>
					assertions[assert_index].P_F = s_FAIL;
					assertions[assert_index].reason = t_ASSERT_REASON;  
				</script>
			</if>
			<!-- Child management -->
			<assign name="ASSERTION_NUM" expr="'725'"/>
			<if cond="event$.reason !=  undefined">
				<conf:pass/>
			<else/>
				<conf:fail reason="'reason property of error.createccxml must be present while its value is  '  + event$.reason"/>
			</if>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>


<!-- 
662.
Execution returns from the <createccxml> element immediately, and the CCXML interpreter can continue on while the new CCXML session is established and loads its initial document.

669.
The sessionid attribute is optional. It is an ECMAScript left hand side expression evaluating to a previously defined variable. The value of the attribute must receive an internally generated unique string identifier which identifies the newly created session.

-->
		<transition event="user.START_ASSERTION_662" state="ASSERTION_NMBR_662">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<assign name="childSessionId" expr="undefined"/>
			<assign name="application.fatherVariable" expr="'hello child'" /> <!-- It will be used to test TA 661 -->
			<createccxml next="'child_1.ccxml'" sessionid="childSessionId" parameters="varString varNum"/>
			<assign name="bFatherContinuesExecution" expr="true"/>
			<if cond="bFatherContinuesExecution">
				<script>assertions[assert_index].P_F = s_PASS;</script>
			<else/>
				<assign name="t_ASSERT_REASON" expr="'Execution has not returned immediately form createccxml because bFatherContinuesExecution boolean value is not true  : ' + bFatherContinuesExecution"/>
				<script>
					assertions[assert_index].P_F = s_FAIL;
					assertions[assert_index].reason = t_ASSERT_REASON;  
				</script>
			</if>
			<!-- Child management -->
			<assign name="ASSERTION_NUM" expr="'669'"/>
			<if cond="childSessionId !=  undefined">
				<conf:pass/>
			<else/>
				<conf:fail reason="'childSessionId has been used in createccxml must has not correctly assigned:   '  + childSessionId"/>
			</if>
		</transition>
		<transition event="ccxml.created" state="ASSERTION_NMBR_662">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<!-- Saving event$.sessionid value in order to check it later on test 721 -->
			<assign name="eventSessionId" expr="event$.sessionid"/>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>		
		</transition>

<!-- 
721.
The ccxml.created event contains a sessionid property set to identifier of the newly created CCXML session. This is the same identifier as was returned on the sessionid attribute of the <createccxml> request that created the session

658.
<createccxml> is used to create another CCXML session, which begins execution with the document identified by this element.

665.
The next attribute is required. It is an ECMAScript expression which returns the URI of the resource to be fetched

671.
The maxage attribute is optional. It is an ECMAScript expression. The character string returned must be interpreted as a time interval. This indicates that the document is willing to use content whose age must be no greater than the specified time in seconds (cf. 'max-age' in HTTP 1.1 [RFC2616]). The document is not willing to use stale content, unless maxstale is also provided

673.
The maxstale attribute is optional. It is an ECMAScript expression. The character string returned must be interpreted as a time interval. This indicates that the document is willing to use content that has exceeded its expiration time (cf. 'max-age' in HTTP 1.1 [RFC2616]). If maxstale is assigned a value, then the document is willing to accept content that has exceeded its expiration time by no more than the specified number of seconds.  	

-->
		<transition event="user.START_ASSERTION_721" state="ASSERTION_NMBR_721">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<if cond="eventSessionId != undefined &amp;&amp; eventSessionId == childSessionId">
				<script>assertions[assert_index].P_F = s_PASS;</script>
			<else/>
				<assign name="t_ASSERT_REASON" expr="'Invalid sessionid on ccxml.created, its value is  : ' + eventSessionId"/>
				<script>
					assertions[assert_index].P_F = s_FAIL;
					assertions[assert_index].reason = t_ASSERT_REASON;  
				</script>
			</if>
			<!-- Children management -->
			<assign name="ASSERTION_NUM" expr="'658'"/>
			<!-- ccxml.created received means that the specified initial CCXML document has been parsed 
					and has begun execution of it by sending the ccxml.loaded event to the new session. So this 
					test pass without any  further condition -->
			<conf:pass/>
			<!-- ccxml.created received means that the specified next attribute in createccxml referenced 
			a valid ccxml document. So this test pass without any further condition	-->
			<assign name="ASSERTION_NUM" expr="'665'"/>
			<conf:pass/>
			<!-- ccxml.created received means that the specified maxage attribute in createccxml was correct-->
			<assign name="ASSERTION_NUM" expr="'671'"/>
			<conf:pass/>
			<!-- ccxml.created received means that the specified maxstale attribute in createccxml was correct-->
			<assign name="ASSERTION_NUM" expr="'673'"/>
			<conf:pass/>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>
		
<!-- 
661.
The new CCXML session has no relation to its creator once spawned, and has a wholly separate lifetime and address space.
	
708.
The ccxml.loaded event contains a parent property indicating the identifier of the session which issued the <createccxml> to start this document;
-->
		
		<transition event="user.START_ASSERTION_661" state="ASSERTION_NMBR_661">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<assign name="application.var1" expr="'Hi folks'"/>
			<assign name="ccxml.var2" expr="222"/>
			<send target="childSessionId" targettype="'ccxml'" name="'ccxml.checkVariables'" sendid="mySendId"/>
		</transition>
		<transition event="ccxml.OKFromChildEvent" state="ASSERTION_NMBR_661">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<!-- In anycase TA 708 pass: the send received by the child element has been perfomed on parent sessionid retrieved from ccxml.loaded event-->
			<assign name="ASSERTION_NUM" expr="'708'"/>
			<conf:pass/>
			<send target="session.id" targettype="'ccxml'" name="'ccxml.GoingOverCurrentTA'" sendid="mySendId"/>
		</transition>
		<transition event="ccxml.KOFromChildEvent" state="ASSERTION_NMBR_661">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<assign name="t_ASSERT_REASON" expr="'Child session ' +  childSessionId  + ' MUST NOT have any links with parent session! ' "/>
			<script>
				assertions[assert_index].P_F = s_FAIL;
				assertions[assert_index].reason = t_ASSERT_REASON;  
			</script>
			<!-- In anycase TA 708 pass: the send received by the child element has been perfomed on parent sessionid retrieved from ccxml.loaded event-->
			<assign name="ASSERTION_NUM" expr="'708'"/>
			<conf:pass/>
			<send target="session.id" targettype="'ccxml'" name="'ccxml.GoingOverCurrentTA'" sendid="mySendId"/>
		</transition>
				
		
<!-- 
1163.
A parameters attribute may be specified. If specified, the parameters attribute is a list of zero or more whitespace separated CCXML variable names. Each named variable will be created as a property of 'session.values' in the newly created session.


-->
		<transition event="user.START_ASSERTION_1163" state="ASSERTION_NMBR_1163">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<send target="childSessionId" targettype="'ccxml'" name="'ccxml.checkSessionValues'" sendid="mySendId"/>
		</transition>
		<transition event="ccxml.OKFromChildEvent" state="ASSERTION_NMBR_1163">
			<conf:comment expr=" 'Current state : ' + current_state + ' , 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.KOFromChildEvent" state="ASSERTION_NMBR_1163">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<assign name="t_ASSERT_REASON" expr="'Invalid session.values variables in child session !'"/>
			<script>
				assertions[assert_index].P_F = s_FAIL;
				assertions[assert_index].reason = t_ASSERT_REASON;  
			</script>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>	
		</transition>
<!-- 
1166.
The ccxml.exit event is only generated when the session exiting has a parent session. This event is sent to the parent session and not the exiting.

698.
A ccxml.exit event will contain a sessionid property set to the identifier of the exiting session; this is the same value returned to the sessionid attribute of the <createccxml> which created this session

699.
A ccxml.exit event will contain a expr property conatining the value of the value of the <exit> expr attribute

701.
A ccxml.exit event will contain a values object with sub properties for each entry in the namelist attribute.

1014.
A ccxml.exit event will contain a reason property set to the reason the session ended. Possible values are: "exit" - Session ended due to a <exit> element "error" - Session ended due to an unhandled error event "kill;" - Session ended due to ccxml.kill* event

-->
		<transition event="user.START_ASSERTION_1166" state="ASSERTION_NMBR_1166">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<send target="childSessionId" targettype="'ccxml'" name="'ccxml.terminateChildSession'" sendid="mySendId"/>
		</transition>
		<transition event="ccxml.exit" state="ASSERTION_NMBR_1166">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<assign name="ASSERTION_NUM" expr="'698'"/>
			<if cond="event$.sessionid == childSessionId">
				<conf:pass/>
			<else/>
				<conf:fail reason="'sessionid of ccxml.exit : ' + event$.sessionid + ' does not match sessionid of createccxml:  '  + childSessionId"/>			
			</if>
			<assign name="ASSERTION_NUM" expr="'699'"/>
			<if cond="event$.expr == 'oops!'">
				<conf:pass/>
			<else/>
					<!-- FIXED ISSUE-680:  missed '+' before event$.expr-->
				<conf:fail reason="'expr of ccxml.exit : ' +  event$.expr + ' does not match the expr of exit tag (oops!) '"/>			
			</if>
			<assign name="ASSERTION_NUM" expr="'701'"/>
			<if cond="event$.values.appleVar == 'apple'  &amp;&amp;  event$.values.grapeFruitVar=='grapefruit' &amp;&amp; event$.values.numberVar == 777">
				<conf:pass/>
			<else/>
				<conf:fail reason="'values of ccxml.exit: ' + event$.values.toSource() + ' dont match the namelist values of exit tag! '"/>			
			</if>
			<assign name="ASSERTION_NUM" expr="'1014'"/>
			<if cond="event$.reason == 'exit'">
				<conf:pass/>
			<else/>
			<!-- FIXED ISSUE-680:  missed '+' before event$.reason-->
				<conf:fail reason="'reason of ccxml.exit : ' + event$.reason + ' does not match the real exit reason (must be exit) '"/>			
			</if>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>	
		</transition>
		
<!-- 
1164.
ccxml.exit
This event is generated when a CCXML document has an unhandled "error.*" event
-->
		<transition event="user.START_ASSERTION_1164" state="ASSERTION_NMBR_1164">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<assign name ="childSessionId" expr="undefined"/>
			<createccxml next="'child_2.ccxml'" sessionid="childSessionId" />
		</transition>
		<transition event="ccxml.created" state="ASSERTION_NMBR_1164">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<send target="childSessionId" targettype="'ccxml'" name="'ccxml.transitionWithError'" sendid="mySendId"/>
		</transition>
		<transition event="ccxml.exit" state="ASSERTION_NMBR_1164">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>	
		</transition>		

<!-- 
1165.
ccxml.exit
This event is generated when a CCXML document has an unhandled ccxml.kill event.
-->
		<transition event="user.START_ASSERTION_1165" state="ASSERTION_NMBR_1165">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<assign name ="childSessionId" expr="undefined"/>
			<createccxml next="'child_3.ccxml'" sessionid="childSessionId" />
		</transition>
		<transition event="ccxml.created" state="ASSERTION_NMBR_1165">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<!-- FIXED ISSUE-670: reason and sessionid variables added in namelist -->
			<var name="sessionid" expr="session.id"/>
			<send target="childSessionId" targettype="'ccxml'" name="'ccxml.kill'" sendid="mySendId" namelist="sessionid reason"/>
		</transition>
		<transition event="ccxml.exit" state="ASSERTION_NMBR_1165">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>	
		</transition>		
<!-- 
710. 
The ccxml.kill event can be used by the platform to terminate a session without an explicit <exit>.

-->
		<transition event="user.START_ASSERTION_710" state="ASSERTION_NMBR_710">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<assign name ="childSessionId" expr="undefined"/>
			<createccxml next="'child_4.ccxml'" sessionid="childSessionId" />
		</transition>
		<transition event="ccxml.created" state="ASSERTION_NMBR_710">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<!-- FIXED ISSUE-670: reason and sessionid variables added in namelist -->
			<var name="sessionid" expr="session.id"/>
			<send target="childSessionId" targettype="'ccxml'" name="'ccxml.kill'" sendid="mySendId" namelist="sessionid reason"/>
		</transition>
		<transition event="ccxml.exit" state="ASSERTION_NMBR_710">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>	
		</transition>	
<!-- 
711.
The ccxml.kill event can be caught, typically to perform a clean-up operation at the end of a session. If the event is caught the session will not be terminated unless the an <exit> element is processed. If the event is not caught the session will be terminated and all active connections, conferences and dialogs that are owned by that session will be automatically terminated by the platform

FIXED ISSUE-670: TA changed
714.
The ccxml.kill event contains a sessionid property set to the session that has sent the event. 

715.
The ccxml.kill event contains a reason property set to a string describing the reason the platform sent the ccxml.kill event

674.
<createccxml>
The enctype attribute is optional. It is an ECMAScript expression which returns a character string that indicates the media encoding type of the submitted document (when the value of the method is "post"). Values defined by the specification are: application/x-www-form-urlencoded. (Only one enctype is defined.)
-->
		<transition event="user.START_ASSERTION_711" state="ASSERTION_NMBR_711">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<assign name ="childSessionId" expr="undefined"/>
			<createccxml next="'child_5.ccxml'" sessionid="childSessionId" parameters="param1" method="'POST'" enctype="'application/x-www-form' +  '-urlencoded'"/>
		</transition>
		<transition event="ccxml.created" state="ASSERTION_NMBR_711">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<!-- FIXED ISSUE-670: reason and sessionid variables added in namelist -->
			<var name="sessionid" expr="session.id"/>
			<send target="childSessionId" targettype="'ccxml'" name="'ccxml.kill'" sendid="mySendId" namelist="sessionid reason"/>
		</transition>
		<transition event="ccxml.StillAlive" state="ASSERTION_NMBR_711">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<var name="sessionid" expr="session.id"/>
			<send target="childSessionId" targettype="'ccxml'" name="'ccxml.kill'" sendid="mySendId" namelist="sessionid reason"/>
		</transition>
		<transition event="ccxml.exit" state="ASSERTION_NMBR_711">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
				<!-- check TA child first -->
			<if cond="event$.values != undefined">  <!-- namelist passed back from child session-->
				<assign name="bTA_714passed" expr="event$.values.bTA_714pass"/>
				<assign name="bTA_715passed" expr="event$.values.bTA_715pass"/>
			</if>
			<if cond="event$.values.returnedParam1 == param1">
				<assign name="bTA_674passed" expr="true"/>
			</if>
						
			<!-- going on with TA 711 -->
			<assign name="current_state" expr= "'ASSERTION_NMBR_711_SECOND_PART' "/>
			<assign name ="childSessionId" expr="undefined"/>
			<createccxml next="'child_6.ccxml'" sessionid="childSessionId" />
		</transition>
		<transition event="ccxml.created" state="ASSERTION_NMBR_711_SECOND_PART">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<!-- FIXED ISSUE-670: reason and sessionid variables added in namelist -->
			<var name="sessionid" expr="session.id"/>			
			<send target="childSessionId" targettype="'ccxml'" name="'ccxml.kill'" sendid="mySendId" namelist="sessionid reason"/>
		</transition>
		<transition event="ccxml.exit" state="ASSERTION_NMBR_711_SECOND_PART">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<!-- verifying TA children results already collected -->
			<assign name="ASSERTION_NUM" expr="'714'"/>
			<if cond="bTA_714passed">
				<conf:pass/>
			<else/>
				<conf:fail reason="'invalid sessionid field on ccxml.kill command! '"/>		
			</if>
			<assign name="ASSERTION_NUM" expr="'715'"/>
			<if cond="bTA_715passed">
				<conf:pass/>
			<else/>
				<conf:fail reason="'unassigned reason field on ccxml.kill command! '"/>		
			</if>
			<assign name="ASSERTION_NUM" expr="'674'"/>
			<if cond="bTA_674passed">
				<conf:pass/>
			<else/>
				<conf:fail reason="'returnedParam1 :' + returnedParam1 + ' is different from param1: ' + param1"/>		
			</if>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>	
		</transition>
		<!-- TA 712 -->
		<transition event="user.START_ASSERTION_712" state="ASSERTION_NMBR_712">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<assign name ="childSessionId" expr="undefined"/>
			<createccxml next="'child_7.ccxml'" sessionid="childSessionId" />
		</transition>
		<transition event="ccxml.created" state="ASSERTION_NMBR_712">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<!-- FIXED ISSUE-670: reason and sessionid variables added in namelist -->
			<var name="sessionid" expr="session.id"/>
			<send target="childSessionId" targettype="'ccxml'" name="'ccxml.kill.unconditional'" sendid="mySendId" namelist="sessionid reason"/>
		</transition>
		<transition event="ccxml.exit" state="ASSERTION_NMBR_712">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<send target="session.id" targettype="'ccxml'" name="'ccxml.GoingOverCurrentTA'" sendid="mySendId"/>
		</transition>		
		
		<transition event="ccxml.StillAlive" state="ASSERTION_NMBR_712">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<assign name="t_ASSERT_REASON" expr="'Received not acceptable ' + event$.name  +  ' while CCXML sent a kill.unconditional to child session !'"/>
			<script>
				assertions[assert_index].P_F = s_FAIL;
				assertions[assert_index].reason = t_ASSERT_REASON;  
			</script>	
			<send target="session.id" targettype="'ccxml'" name="'ccxml.GoingOverCurrentTA'" sendid="mySendId"/>
		</transition>		
		
<!--
675.
<exit> ends execution of the CCXML session. All pending events are discarded, and there is no way to restart CCXML execution.
-->
		
		<transition event="user.START_ASSERTION_675" state="ASSERTION_NMBR_675">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<assign name ="childSessionId" expr="undefined"/>
			<createccxml next="'child_8.ccxml'" sessionid="childSessionId"/>
		</transition>
		<transition event="ccxml.created" state="ASSERTION_NMBR_675">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<!-- FIXED ISSUE-670: reason and sessionid variables added in namelist -->
			<var name="sessionid" expr="session.id"/>
			<send target="childSessionId" targettype="'ccxml'" name="'ccxml.kill'" namelist="sessionid reason"/>
			<send targettype="'ccxml'" target="session.id" name="'ccxml.test675_OK'" delay="'15s'" sendid="mySendId"/>			
		</transition>
		<transition event="ccxml.exit" state="ASSERTION_NMBR_675">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
		</transition>				
		<transition event="ccxml.FromChild8StillAlive" state="ASSERTION_NMBR_675">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<script>
			assertions[assert_index].P_F = s_FAIL;
			assertions[assert_index].reason = 'ccxml.FromChild8StillAlive should not be received';  
			</script>
			<cancel sendid="mySendId"/>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>

		<transition event="ccxml.test675_OK" state="ASSERTION_NMBR_675">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<script>
			assertions[assert_index].P_F = s_PASS;
			</script>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>			
		</transition>

		
<!--
610.
The <ccxml> element may contain a xml:base attribute. This is the URI which all relative references within the document take as their base.
-->

		<transition event="user.START_ASSERTION_610" state="ASSERTION_NMBR_610">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<assign name ="childSessionId" expr="undefined"/>
			<createccxml next="'child_9.ccxml'" sessionid="childSessionId"/>
		</transition>
		<transition event="ccxml.created" state="ASSERTION_NMBR_610">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
		</transition>
		<transition event="ccxml.FromChild9Fail" state="ASSERTION_NMBR_610">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<script>
			assertions[assert_index].P_F = s_FAIL;
			</script>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>
		<transition event="ccxml.FromChild9Pass" state="ASSERTION_NMBR_610">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<script>
			assertions[assert_index].P_F = s_PASS;
			</script>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>

		<!-- TA 622 -->
		<transition event="user.START_ASSERTION_622" state="ASSERTION_NMBR_622">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<fetch next="'errorFetchMetadata.ccxml'" fetchid="myFetchId"/>
		</transition>
		<transition event="error.fetch" state="ASSERTION_NMBR_622">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<send target="session.id" targettype="'ccxml'" name="'ccxml.GoingOverCurrentTA'" sendid="mySendId"/>
		</transition>			
		<transition event="fetch.done" state="ASSERTION_NMBR_622">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<assign name="t_ASSERT_REASON" expr="'Received not acceptable ' + event$.name  +  ' while loading ccxml doc has metadata with an attribute !'"/>
			<script>
				assertions[assert_index].P_F = s_FAIL;
				assertions[assert_index].reason = t_ASSERT_REASON;  
			</script>	
			<send target="session.id" targettype="'ccxml'" name="'ccxml.GoingOverCurrentTA'" sendid="mySendId"/>
		</transition>			
		<!-- TA 617 -->
		<transition event="user.START_ASSERTION_617" state="ASSERTION_NMBR_617">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<fetch next="'errorFetchMeta617.ccxml'" fetchid="myFetchId"/>
		</transition>
		<transition event="error.fetch" state="ASSERTION_NMBR_617">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<send target="session.id" targettype="'ccxml'" name="'ccxml.GoingOverCurrentTA'" sendid="mySendId"/>
		</transition>			
		<transition event="fetch.done" state="ASSERTION_NMBR_617">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<assign name="t_ASSERT_REASON" expr="'Received not acceptable ' + event$.name  +  ' while loading ccxml doc has meta without content attribute !'"/>
			<script>
				assertions[assert_index].P_F = s_FAIL;
				assertions[assert_index].reason = t_ASSERT_REASON;  
			</script>	
			<send target="session.id" targettype="'ccxml'" name="'ccxml.GoingOverCurrentTA'" sendid="mySendId"/>
		</transition>			
		<!-- TA 615 -->
		<!-- This test has built on 4 subtest parts:
				1 -> neither http-equiv nor name have been specified => fetch.done and error on loaded page
				2 -> in new doc: both http-equiv and name have been specified => fetch.done and error on loaded page
				3 -> in new doc: only http-equiv has been specified => fetch.done and ccxml.loaded.
				4 -> only name has been specified => fetch.done
		-->
		
		<transition event="user.START_ASSERTION_615" state="ASSERTION_NMBR_615">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<assign name ="current_state" expr="'ASSERTION_NMBR_615_1'"/>
		<!-- FIXED TA 615 replaced 'errorNoneDeclared_615_1.ccxml' with 'errorFetchMeta615_1.ccxml' -->
			<fetch next="'errorFetchMeta615_1.ccxml'" fetchid="myFetchId"/>
		</transition>
	
		<transition event="error.fetch" state="ASSERTION_NMBR_615_1">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name + ' => PASS on Part 1 !'"/>
			<assign name ="current_state" expr="'ASSERTION_NMBR_615_2'"/>	
			<fetch next="'errorFetchMeta615_2.ccxml'" fetchid="myFetchId"/>	
		</transition>
		<transition event="fetch.done" state="ASSERTION_NMBR_615_2">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<assign name="t_ASSERT_REASON" expr="'Received not acceptable ' + event$.name  +  ' while loaded ccxml doc has BOTH http-equiv and name declared  !'"/>
			<script>
				assertions[assert_index].P_F = s_FAIL;
				assertions[assert_index].reason = t_ASSERT_REASON;  
			</script>	
			<send target="session.id" targettype="'ccxml'" name="'ccxml.GoingOverCurrentTA'" sendid="mySendId"/>
		</transition>
		<transition event="error.fetch" state="ASSERTION_NMBR_615_2">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name + ' => PASS on Part 2 ! '"/>
			<assign name ="current_state" expr="'ASSERTION_NMBR_615_3'"/>	
			<fetch next="'fetchDoneMeta615_3.ccxml'" fetchid="myFetchId"/>	
		</transition>
		<transition event="fetch.done" state="ASSERTION_NMBR_615_3">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name + ' => PASS on Part 3 ! '"/>
			<assign name ="current_state" expr="'ASSERTION_NMBR_615_4'"/>	
			<fetch next="'fetchDoneMeta615_4.ccxml'" fetchid="myFetchId"/>	
		</transition>
		<transition event="error.fetch" state="ASSERTION_NMBR_615_3">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<assign name="t_ASSERT_REASON" expr="'Received not acceptable ' + event$.name  +  ' while loaded ccxml doc has ONLY http-equiv  attribute declared  !'"/>
			<script>
				assertions[assert_index].P_F = s_FAIL;
				assertions[assert_index].reason = t_ASSERT_REASON;  
			</script>	
			<send target="session.id" targettype="'ccxml'" name="'ccxml.GoingOverCurrentTA'" sendid="mySendId"/>
		</transition>
		<transition event="fetch.done" state="ASSERTION_NMBR_615_4">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name + ' => PASS on Part 3 ! '"/>
			<assign name ="current_state" expr="'ASSERTION_NMBR_615'"/>	
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<send target="session.id" targettype="'ccxml'" name="'ccxml.GoingOverCurrentTA'" sendid="mySendId"/>
		</transition>
		<transition event="error.fetch" state="ASSERTION_NMBR_615_4">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<assign name="t_ASSERT_REASON" expr="'Received not acceptable ' + event$.name  +  ' while loaded ccxml doc has ONLY name attribute declared  !'"/>
			<script>
				assertions[assert_index].P_F = s_FAIL;
				assertions[assert_index].reason = t_ASSERT_REASON;  
			</script>	
			<assign name ="current_state" expr="'ASSERTION_NMBR_615'"/>	
			<send target="session.id" targettype="'ccxml'" name="'ccxml.GoingOverCurrentTA'" sendid="mySendId"/>
		</transition>


<!--
Consequently to ISSUE-725 fixed in child_9.ccxml we add a do-nothing transition for ccxml.exit thrown by session associated with child_9.ccxml 
-->
		<transition event="ccxml.exit">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
		</transition>		

		
	<!-- ====================================================================-->
		<!-- In every state this is useful to go over the current TA -->
		<transition event="ccxml.GoingOverCurrentTA">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>		

		<!-- ====================================================================-->
	
			<!-- Safety timeout -->					
		 <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="connection.disconnected">
			<conf:uncond_exit expr="'CONNECTION-DISCONNECTED'"/>
		</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>
