在执行单元测试时,为了避免产生脏数据,将测试单元设置成事务回滚!!!!!
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;
import com.bookingctrip.api.manual.service.WalletBatchService;

/**
 * @author yzp
 * @version 1.0
 * @parameter
 * @return
 */
@SuppressWarnings("deprecation")
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true)
@Transactional
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:context/applicationContext.xml")
public class TestWalletBatch {
	static final Logger log = LoggerFactory.getLogger(TestWalletBatch.class);
	@Autowired
	private WalletBatchService batchService;

	@Test
	public void testSelectPrimaryKeyByBatchNo() {
		String batchNo = "pay2017010901ffn6q2x0setpmv0x";
		Long selectPrimaryKeyByBatchNo = batchService.selectPrimaryKeyByBatchNo(batchNo);
		System.out.print(selectPrimaryKeyByBatchNo);
	}
}


Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐