🎨 增加点单元测试示例代码

This commit is contained in:
Binary Wang 2020-11-15 22:18:15 +08:00
parent 6d556f8b1d
commit 5986698d42

View File

@ -1,9 +1,10 @@
package me.chanjar.weixin.open.api.impl; package me.chanjar.weixin.open.api.impl;
import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
import me.chanjar.weixin.common.error.WxErrorException;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import static org.testng.Assert.*;
/** /**
* 单元测试. * 单元测试.
* *
@ -11,28 +12,40 @@ import static org.testng.Assert.*;
* @date 2020-10-19 * @date 2020-10-19
*/ */
public class WxOpenOAuth2ServiceImplTest { public class WxOpenOAuth2ServiceImplTest {
private final WxOpenOAuth2ServiceImpl service = new WxOpenOAuth2ServiceImpl("123", "");
@BeforeTest
public void init() {
this.service.setWxOpenConfigStorage(new WxOpenInMemoryConfigStorage());
}
@Test @Test
public void testBuildAuthorizationUrl() { public void testBuildAuthorizationUrl() {
this.service.buildAuthorizationUrl("", "", "");
} }
@Test @Test
public void testGetAccessToken() { public void testGetAccessToken() throws WxErrorException {
this.service.getAccessToken("a");
} }
@Test @Test
public void testTestGetAccessToken() { public void testTestGetAccessToken() throws WxErrorException {
this.service.getAccessToken("", "", "");
} }
@Test @Test
public void testRefreshAccessToken() { public void testRefreshAccessToken() throws WxErrorException {
this.service.refreshAccessToken("");
} }
@Test @Test
public void testGetUserInfo() { public void testGetUserInfo() throws WxErrorException {
this.service.getUserInfo(new WxOAuth2AccessToken(), "");
} }
@Test @Test
public void testValidateAccessToken() { public void testValidateAccessToken() {
this.service.validateAccessToken(new WxOAuth2AccessToken());
} }
} }