读取Spring配置文件 main方法里面测试实现功能

  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")  

posted @ 2013-03-06 14:42  Shaman  阅读(1958)  评论(0编辑  收藏  举报