问答详情
源自:4-1 使用集成测试Service逻辑

executSeckill测试问题?

@Test
public void executeSeckill() throws Exception {
   long id = 1000;
   long phone = 13877093290L;
   String  md5 = "42d56fec120bf23e3af750569ca017c3";
   SeckillExcution seckillExcution = seckillService.executeSeckill(id,phone,md5);
   logger.info("SeckillExcution={}"+seckillExcution);

输出结果

18:14:52.931  [main]  DEBUG org.mybatis.spring.SqlSessionUtils -  Creating a new SqlSession

18:14:52.935  [main]  DEBUG org.mybatis.spring.SqlSessionUtils -  Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5b3f61ff]

18:14:52.940  [main]  DEBUG o.m.s.t.SpringManagedTransaction -  JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@616ac46a] will be managed by Spring

18:14:52.943  [main]  DEBUG o.s.dao.SeckillDao.reduceNumber -  ==>  Preparing: update seckill set number = number - 1 where seckill_id = ? and start_time <= ? and end_time >= ? and number > 0 

18:14:52.965  [main]  DEBUG o.s.dao.SeckillDao.reduceNumber -  ==> Parameters: 1001(Long), 2016-10-12 18:14:52.923(Timestamp), 2016-10-12 18:14:52.923(Timestamp)

18:14:52.973  [main]  DEBUG o.s.dao.SeckillDao.reduceNumber -  <==    Updates: 1

18:14:52.973  [main]  DEBUG org.mybatis.spring.SqlSessionUtils -  Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5b3f61ff]

18:14:52.974  [main]  DEBUG org.mybatis.spring.SqlSessionUtils -  Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5b3f61ff] from current transaction

18:14:52.974  [main]  DEBUG o.s.d.S.insertSuccessKilled -  ==>  Preparing: insert ignore into success_killed (seckill_id,user_phone) value (?,?) 

18:14:52.975  [main]  DEBUG o.s.d.S.insertSuccessKilled -  ==> Parameters: 1001(Long), 13877093293(Long)

18:14:52.983  [main]  DEBUG o.s.d.S.insertSuccessKilled -  <==    Updates: 1

18:14:52.983  [main]  DEBUG org.mybatis.spring.SqlSessionUtils -  Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5b3f61ff]

18:14:52.984  [main]  DEBUG org.mybatis.spring.SqlSessionUtils -  Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5b3f61ff] from current transaction

18:14:52.985  [main]  DEBUG o.s.d.S.queryByIdWithSeckill -  ==>  Preparing: select sk.seckill_id, sk.user_phone, sk.create_time, sk.state, s.seckill_id "seckill.seckill_id", s.name "seckill.name", s.number "seckill.number", s.start_time "seckill.start_time", s.end_time "seckill.end_time", s.create_time "seckill.create_time" from success_killed sk inner join seckill s on sk.seckill_id = s.seckill_id where sk.seckill_id = ? and sk.user_phone = ? 

18:14:52.985  [main]  DEBUG o.s.d.S.queryByIdWithSeckill -  ==> Parameters: 1001(Long), 13877093293(Long)

18:14:53.002  [main]  DEBUG o.s.d.S.queryByIdWithSeckill -  <==      Total: 1

18:14:53.006  [main]  DEBUG org.mybatis.spring.SqlSessionUtils -  Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5b3f61ff]

18:14:53.007  [main]  DEBUG org.mybatis.spring.SqlSessionUtils -  Transaction synchronization committing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5b3f61ff]

18:14:53.007  [main]  DEBUG org.mybatis.spring.SqlSessionUtils -  Transaction synchronization deregistering SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5b3f61ff]

18:14:53.007  [main]  DEBUG org.mybatis.spring.SqlSessionUtils -  Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5b3f61ff]

18:14:53.098  [main]  INFO  o.seckill.service.SeckillServiceTest -  SeckillExcution={}org.seckill.dto.SeckillExcution@1672fe87

为什么SeckillExcution ={} 里面没有信息的? 

提问者:搬砖工学编程 2016-10-12 18:27

个回答

  • 愚鱼欲语
    2016-10-13 15:28:41

    logger.info("SeckillExcution={}"+seckillExcution);
    中间应该是逗号","   不是"+"号