1. 程式人生 > >mybatis測試類

mybatis測試類

public class RechargeRecordTest {


private SqlMapClient  sqlMapClient;

private ApplicationContext context;
// 此方法是在執行testFindUserById之前執行
@org.junit.Before
public void setUp() throws Exception {
String resource = "com/fenghu/config/SqlMapConfig.xml";
InputStream inputStream = null;
inputStream = Resources.getResourceAsStream(resource);
SqlMapClient  sqlMapClient = SqlMapClientBuilder.buildSqlMapClient(inputStream);

context = new ClassPathXmlApplicationContext("com/fenghu/config/applicationContext.xml");



}

@Test
public void updateRecordAndHistoryTest() throws Exception{
RechargeRecordBiz userService = (RechargeRecordBiz) context.getBean("rechargeRecordBiz");
Rechargerecord  rechargerecord = new Rechargerecord();
rechargerecord.setAvailableamount(50d);
rechargerecord.setOrderid(1000001);
rechargerecord.setRechargeamount(200d);
rechargerecord.setRechargedate(new Date());
rechargerecord.setRechargetype(2);
rechargerecord.setUsername("18300087973");
rechargerecord.setUsestatus(0);

String msg = userService.insertRechReco(rechargerecord,new Htrecord());
System.out.println(msg);



}

}