?????????junit??????????????о??????????????????????????£?????????????????????δ???????????????????????????junit????????????
????????groboutils jar???????????????MultiThreadedTestRunner???TestRunnable??
??????е?junit?????????????GroboTestingJUnit-1.2.1-core.jar??
????????????
public class FaultServiceTest extends TestCase {
/**
* @param args
* @throws FaultException
* @throws ExpParamNotFoundException
* @throws ParseException
*/
private IFaultService faultService;
private static final int NUM_THREAD = 100; // ???????????
public FaultServiceTest() {
super();
IInitService initService = (IInitService) CustomBeanFactory
.getBean("initService");
initService.initSiteDatabase();
this.faultService = (IFaultService) CustomBeanFactory
.getBean("faultService");
}
public FaultServiceTest(String name) {
super(name);
IInitService initService = (IInitService) CustomBeanFactory
.getBean("initService");
initService.initSiteDatabase();
this.faultService = (IFaultService) CustomBeanFactory
.getBean("faultService");
}
// ?????????
public void testGetEquipEventAlertListByPage() throws Throwable {
EquipmentQueryBean equipmentQueryBean = new EquipmentQueryBean();
// ???????в??????
TestRunnable[] test = new TestRunnable[NUM_THREAD];
long start = System.currentTimeMillis();
for (int i = 0; i < test.length; i++) {
test[i] = new FaultServiceThread(faultService?? equipmentQueryBean);
}
// ????????????????
MultiThreadedTestRunner mttr = new MultiThreadedTestRunner(test);
// ???в??????
mttr.runTestRunnables();
long used = System.currentTimeMillis() - start;
System.out.printf("%s ??????? %s milli-seconds. "?? NUM_THREAD?? used);
}
public static Test suite() {
TestSuite test = new TestSuite("HealthService????????");
test.addTest(new FaultServiceTest("testGetEquipEventAlertListByPage"));
return test;
}
/*
* ???????????
*/
private static class FaultServiceThread extends TestRunnable {
private IFaultService faultService;
private EquipmentQueryBean equipmentQueryBean;
public FaultServiceThread(IFaultService faultService??
EquipmentQueryBean equipmentQueryBean) {
super();
this.faultService = faultService;
this.equipmentQueryBean = equipmentQueryBean;
}
@Override
public void runTest() throws Throwable {
faultService.getEquipEventAlertListByPage(equipmentQueryBean);
}
}
??