1
0
mirror of synced 2025-12-22 00:48:00 +08:00

生成带参数的二维码时加入场景值的校验 #106

This commit is contained in:
Binary Wang
2016-12-23 14:14:01 +08:00
parent 637fc87c0d
commit c70bf9b0c3
3 changed files with 37 additions and 22 deletions

View File

@@ -6,6 +6,7 @@ import me.chanjar.weixin.mp.api.ApiTestModule;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
@@ -19,20 +20,26 @@ import java.io.File;
@Test(groups = "qrCodeAPI")
@Guice(modules = ApiTestModule.class)
public class WxMpQrCodeServiceImplTest {
@Inject
protected WxMpService wxService;
public void testQrCodeCreateTmpTicket() throws WxErrorException {
WxMpQrCodeTicket ticket = this.wxService.getQrcodeService().qrCodeCreateTmpTicket(1, null);
@DataProvider
public Object[][] sceneIds() {
return new Object[][]{{-1}, {0}, {1}, {200000}};
}
@Test(dataProvider = "sceneIds")
public void testQrCodeCreateTmpTicket(int sceneId) throws WxErrorException {
WxMpQrCodeTicket ticket = this.wxService.getQrcodeService().qrCodeCreateTmpTicket(sceneId, null);
Assert.assertNotNull(ticket.getUrl());
Assert.assertNotNull(ticket.getTicket());
Assert.assertTrue(ticket.getExpire_seconds() != -1);
System.out.println(ticket);
}
public void testQrCodeCreateLastTicket() throws WxErrorException {
WxMpQrCodeTicket ticket = this.wxService.getQrcodeService().qrCodeCreateLastTicket(1);
@Test(dataProvider = "sceneIds")
public void testQrCodeCreateLastTicket(int sceneId) throws WxErrorException {
WxMpQrCodeTicket ticket = this.wxService.getQrcodeService().qrCodeCreateLastTicket(sceneId);
Assert.assertNotNull(ticket.getUrl());
Assert.assertNotNull(ticket.getTicket());
Assert.assertTrue(ticket.getExpire_seconds() == -1);