mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-04-24 18:04:38 +08:00
issue #74 添加测试用例
This commit is contained in:
parent
d0825ca396
commit
4f292da60c
@ -70,7 +70,7 @@ public interface WxMpService {
|
||||
* @param url url
|
||||
* @return
|
||||
*/
|
||||
public String createJsapiSignature(String timestamp, String noncestr, String url) throws WxErrorException;
|
||||
public String createJsapiSignature(long timestamp, String noncestr, String url) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
|
@ -127,7 +127,7 @@ public class WxMpServiceImpl implements WxMpService {
|
||||
return wxMpConfigStorage.getJsapiTicket();
|
||||
}
|
||||
|
||||
public String createJsapiSignature(String timestamp, String noncestr, String url) throws WxErrorException {
|
||||
public String createJsapiSignature(long timestamp, String noncestr, String url) throws WxErrorException {
|
||||
String jsapiTicket = getJsapiTicket(false);
|
||||
try {
|
||||
return SHA1.genWithAmple(
|
||||
|
@ -25,7 +25,6 @@ public class WxMpBaseAPITest {
|
||||
wxService.getAccessToken(false);
|
||||
|
||||
String after = configStorage.getAccessToken();
|
||||
|
||||
Assert.assertNotEquals(before, after);
|
||||
Assert.assertTrue(StringUtils.isNotBlank(after));
|
||||
}
|
||||
|
@ -0,0 +1,48 @@
|
||||
package me.chanjar.weixin.mp.api;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.crypto.SHA1;
|
||||
import me.chanjar.weixin.mp.bean.WxMpGroup;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 测试jsapi ticket接口
|
||||
*
|
||||
* @author chanjarster
|
||||
*/
|
||||
@Test(groups = "jsAPI", dependsOnGroups = "baseAPI")
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxMpJsAPITest {
|
||||
|
||||
@Inject
|
||||
protected WxMpServiceImpl wxService;
|
||||
|
||||
|
||||
public void testJsapiTicket() throws WxErrorException {
|
||||
String jsapiTicket = wxService.getJsapiTicket(false);
|
||||
System.out.println(jsapiTicket);
|
||||
Assert.assertNotNull(jsapiTicket);
|
||||
}
|
||||
|
||||
public void test() throws NoSuchAlgorithmException {
|
||||
long timestamp = 1419835025l;
|
||||
String url = "http://omstest.vmall.com:23568/thirdparty/wechat/vcode/gotoshare?quantity=1&batchName=MATE7";
|
||||
String noncestr = "82693e11-b9bc-448e-892f-f5289f46cd0f";
|
||||
String jsapiTicket = "bxLdikRXVbTPdHSM05e5u4RbEYQn7pNQMPrfzl8lJNb1foLDa3HIwI3BRMkQmSO_5F64VFa75uURcq6Uz7QHgA";
|
||||
String result = SHA1.genWithAmple(
|
||||
"jsapi_ticket=" + jsapiTicket,
|
||||
"noncestr=" + noncestr,
|
||||
"timestamp=" + timestamp,
|
||||
"url=" + url
|
||||
);
|
||||
|
||||
Assert.assertEquals(result, "c6f04b64d6351d197b71bd23fb7dd2d44c0db486");
|
||||
}
|
||||
|
||||
}
|
@ -13,6 +13,7 @@
|
||||
<class name="me.chanjar.weixin.mp.api.WxMpQrCodeAPITest" />
|
||||
<class name="me.chanjar.weixin.mp.api.WxMpShortUrlAPITest" />
|
||||
<class name="me.chanjar.weixin.mp.api.WxMpMessageRouterTest" />
|
||||
<class name="me.chanjar.weixin.mp.api.WxMpJsAPITest" />
|
||||
</classes>
|
||||
</test>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user