KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > graph > action > ScriptXmlTest


1 package org.jbpm.graph.action;
2
3 import junit.framework.TestCase;
4
5 import org.jbpm.graph.action.Script;
6 import org.jbpm.graph.def.Node;
7 import org.jbpm.graph.def.ProcessDefinition;
8
9 public class ScriptXmlTest extends TestCase {
10
11   public void testReadScriptExpression() {
12     ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
13       "<process-definition>" +
14       " <script name='s'>" +
15       " e = m * Math.pow(c,2);" +
16       " </script>" +
17       "</process-definition>"
18     );
19     
20     Script script = (Script) processDefinition.getAction("s");
21     assertEquals("e = m * Math.pow(c,2);", script.getExpression() );
22   }
23   
24   public void testReadScriptWithVariables() {
25     ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
26       "<process-definition>" +
27       " <node name='a'>" +
28       " <script>" +
29       " <variable name='a' access='read' />" +
30       " <variable name='b' access='write' />" +
31       " <variable name='c' />" +
32       " <expression>e = m * Math.pow(c,2);</expression>" +
33       " </script>" +
34       " </node>" +
35       "</process-definition>"
36     );
37     
38     Node node = processDefinition.getNode("a");
39     Script script = (Script) node.getAction();
40     
41     assertEquals( 3, script.getVariableAccesses().size() );
42     assertEquals("e = m * Math.pow(c,2);", script.getExpression() );
43   }
44 }
45
Popular Tags