Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1320568
  • 博文数量: 179
  • 博客积分: 4141
  • 博客等级: 中将
  • 技术积分: 2083
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-21 20:04
文章存档

2024年(1)

2019年(13)

2016年(1)

2014年(16)

2011年(8)

2010年(25)

2009年(115)

分类: Java

2014-10-11 03:29:13


点击(此处)折叠或打开

  1. public class ProjectCase {
  2.     private String name = null;
  3.     private String desc = null;

  4.     private enum ScenarioCaseType {
  5.         UnitTesting, StressTesting
  6.     }

  7.     public String getName() {

  8.         return name;
  9.     }

  10.     public void setName(String name) {

  11.         this.name = name;
  12.     }

  13.     public String getDesc() {

  14.         return desc;
  15.     }

  16.     public void setDesc(String desc) {

  17.         this.desc = desc;
  18.     }

  19.     public List<ScenarioCase> getUnitTestingCaseList() throws InstantiationException, IllegalAccessException,
  20.             ClassNotFoundException {

  21.         return getScenarioCaseList(ScenarioCaseType.UnitTesting);
  22.     }

  23.     public List<ScenarioCase> getStressTestingCaseList() throws InstantiationException, IllegalAccessException,
  24.             ClassNotFoundException {

  25.         return getScenarioCaseList(ScenarioCaseType.StressTesting);
  26.     }

  27.     private List<ScenarioCase> getScenarioCaseList(ScenarioCaseType type) throws InstantiationException,
  28.             IllegalAccessException, ClassNotFoundException {

  29.         List<ScenarioCase> scenarioCaseList = new ArrayList<ScenarioCase>();
  30.         List<String> classesList = ClassUtils.listAllClassesInCurrentDir(getClass());

  31.         for (String objectName : classesList) {
  32.             Object obj = Class.forName(objectName).newInstance();

  33.             switch (type) {
  34.             case UnitTesting:
  35.                 if (obj instanceof UnitTestingCase) {
  36.                     scenarioCaseList.add((ScenarioCase) obj);
  37.                 }
  38.                 break;
  39.             case StressTesting:
  40.                 if (obj instanceof StressTestingCase) {
  41.                     scenarioCaseList.add((ScenarioCase) obj);
  42.                 }
  43.                 break;
  44.             }

  45.         }

  46.         return scenarioCaseList;
  47.     }
  48. }

阅读(3806) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~