ApplicationContext context = new ClassPathXmlApplicationContext("/webservice-servlet.xml"); AccountService accountService = (AccountService)context.getBean("accountService"); Random random = new Random(); String email = "OoPassAutoTestFengxiang" + random.nextInt() + "@oozic.com"; String password = String.valueOf(random.nextInt()); try { accountService.register(email, password); } catch (OoPassException e) { e.printStackTrace(); }
或者使用注解 JUnit 进行白盒测试
@ContextConfiguration(locations = "/webservice-servlet.xml")