Changes between Version 1 and Version 2 of demo_03


Ignore:
Timestamp:
04/05/2012 03:21:30 PM (14 years ago)
Author:
chenyang
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • demo_03

    v1 v2  
    11== 单元测试应用示例——测试Service层对象 == 
     2GameStart是游戏登陆与充值的接口,SxdGameStart实现了GameStart接口,完成了用户登陆神仙道游戏服务器,充值,检验用户是否存在等功能,示例如何测试用户是否存在功能.[[BR]] 
     3prestart(User user,Game game,Server server)方法判断用户在游戏厂商服务器中是否存在,要测试该方法,需要准备user,game,server对象[[BR]] 
     4{{{ #!java 
     5@RunWith(SpringJUnit4ClassRunner.class) 
     6@ContextConfiguration(locations = {"classpath:applicationContext.xml"}) 
     7public class SxdGameStartTest extends AbstractTransactionalJUnit4SpringContextTests{ 
     8         
     9        @Ignore 
     10        public void prestart() throws Exception { 
     11                 
     12        GameStart start = (GameStart) applicationContext.getBean("sxdGameStart"); 
     13                 
     14       //准备user对象 
     15        User user = new User(); 
     16        user.setUserId(9673315); 
     17        user.setName("lifeng"); 
     18         
     19        //准备game         
     20        Game game = new Game(); 
     21 
     22        //准备server 
     23        Server server = new Server(); 
     24        server.setStartURL("http://s1.sxd.pcgames.com.cn/login_api.php"); 
     25        server.setPrestartURL("http://api.sxd.xd.com/api/check_user.php"); 
     26        server.setLoginkey("{B819BBB7-F049-4D31-ABED-C871DC7628F2}"); 
     27         
     28        server.setPrestartResult("1"); 
     29 
     30        boolean b = start.prestart(user, game, server); 
     31         
     32        //断言用户存在 
     33        Assert.assertTrue(b); 
     34 } 
     35 
     36................... 
     37 
     38} 
     39}}}