下面我将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一路跑绿。
其他待续
闽公网安备 35060202000074号