服务热线:13616026886

技术文档 欢迎使用技术文档,我们为你提供从新手到专业开发者的所有资源,你也可以通过它日益精进

位置:首页 > 技术文档 > JAVA > 新手入门 > 基础入门 > 查看文档

osworkflow小测试练习之beanshell


  下面我将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一路跑绿。
  
  其他待续

扫描关注微信公众号