下面我将osworkflow的各个部分职能的小测试写一下,以便比较全面的把握osworkflow。 Beanshell部分: 要把bsh的jar 包放到classpath中。 如做个简单的测试: public class SimpleBeanShell { private int count; public int getCount() { return count; } public void setCount(int count) { this.count = count; } } 过程定义这样写一下: <pre-functions> <function type="beanshell"> <arg name="script"> com.littledragon.os.SimpleBeanShell sbs= transientVars.get("aaaa"); sbs.setCount(20); </arg> </function> </pre-functions> 写个测试类: 测试方法如下。 public void testGetCount() throws Exception { //long id; SimpleBeanShell simpleBeanShell = new SimpleBeanShell(); Map inputs = new HashMap(); inputs.put("aaaa", simpleBeanShell); Workflow wf = new BasicWorkflow("testyunguang"); wf.initialize("ospractice", 1, inputs); int count = simpleBeanShell.getCount(); assertEquals(20, count); } 即可看到通过beanshell方法将count值设为20,junit一路跑绿。 其他待续
|