1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.scxml2.env.groovy;
18
19 import java.net.URL;
20 import java.util.Set;
21
22 import org.apache.commons.scxml2.SCXMLExecutor;
23 import org.apache.commons.scxml2.SCXMLTestHelper;
24 import org.apache.commons.scxml2.model.EnterableState;
25
26 import org.junit.Assert;
27 import org.junit.Test;
28
29 public class GroovyClosureTest {
30
31 @Test
32 public void testGroovyClosure() throws Exception {
33 URL groovyClosure = SCXMLTestHelper.getResource("org/apache/commons/scxml2/env/groovy/groovy-closure.xml");
34 SCXMLExecutor exec = SCXMLTestHelper.getExecutor(groovyClosure, new GroovyEvaluator(true));
35 exec.go();
36 Set<EnterableState> currentStates = SCXMLTestHelper.fireEvent(exec, "turn_on");
37 Assert.assertEquals(2, currentStates.size());
38 String id = currentStates.iterator().next().getId();
39 Assert.assertTrue(id.equals("closed") || id.equals("cooking"));
40 }
41 }