summaryrefslogtreecommitdiffstats
path: root/test/uscxml/test-expect.scxml
blob: abd2a58d06fbfbd7d5b2c40a7ab32740f0169a18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<scxml datamodel="ecmascript">
	<script src="http://uscxml.tk.informatik.tu-darmstadt.de/scripts/dump.js" />
	<state id="start">
		<state id="spawn">
			<invoke type="expect" id="telnet">
				<param name="debug" expr="false" />
				<param name="timeout" expr="3" />
				<param name="loguser" expr="false" />
				<param name="spawn" expr="'/usr/bin/telnet'" />
				<param name="argument" expr="_ioprocessors.basichttp.host" />
				<param name="argument" expr="_ioprocessors.basichttp.port" />
				<!-- <param name="argument" expr="80" /> -->
				<finalize><script>//print('------------'); dump(_event);</script></finalize>
			</invoke>
		
			<state id="idle">
				<onentry><log expr="'Waiting'"/></onentry>
				<transition event="spawn.success" target="spawned" />
				<transition event="spawn.failed" target="exit">
					<script>print('FAIL: '); dump(_event);</script>
				</transition>
			</state>

			<state id="spawned">
				<onentry>
					<log expr="'Spawned'"/>
					<send target="#_telnet" event="expect.match">
						<param name="exact:refused" expr="'Connection refused'" />
						<!-- last line of a telnet connect -->
						<param name="exact:connected" expr="'Escape character is \'^]\'.'" />
					</send>
				</onentry>
				<transition event="expect.match.connected" target="established" />
			</state>

			<state id="established">
				<onentry>
					<log expr="'Established'"/>
					<send target="#_telnet" event="expect.send">
						<content>GET /${_name} HTTP/1.1\n\n</content>
					</send>
					<send target="#_telnet" event="expect.match">
						<param name="exact:answered" expr="'Some arbitrary content'" />
					</send>
				</onentry>

				<!-- Answer the telnet request -->
				<transition event="http.get" type="internal">
					<respond to="_event.origin">
						<header name="Content-Type" value="text/plain" />
						<content>Some arbitrary content</content>
					</respond>
				</transition>

				<transition event="expect.match.answered" target="start" type="external" />

			</state>

		</state>
	</state>
	
	
	<final id="exit" />
</scxml>