使用IDEA统一格式化测试代码

This commit is contained in:
Binary Wang
2017-01-23 16:54:48 +08:00
parent 123eb5088d
commit ff1b69a38f
45 changed files with 591 additions and 642 deletions

View File

@@ -4,14 +4,13 @@ import com.google.inject.Inject;
import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.test.ApiTestModule; import me.chanjar.weixin.mp.api.test.ApiTestModule;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.testng.Assert; import org.testng.*;
import org.testng.annotations.Guice; import org.testng.annotations.*;
import org.testng.annotations.Test;
/** /**
* 基础API测试 * 基础API测试
* @author chanjarster
* *
* @author chanjarster
*/ */
@Test(groups = "baseAPI") @Test(groups = "baseAPI")
@Guice(modules = ApiTestModule.class) @Guice(modules = ApiTestModule.class)

View File

@@ -4,8 +4,7 @@ import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestExecutor; import me.chanjar.weixin.common.util.http.RequestExecutor;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import org.testng.annotations.DataProvider; import org.testng.annotations.*;
import org.testng.annotations.Test;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
@@ -15,7 +14,7 @@ import java.util.concurrent.Future;
@Test @Test
public class WxMpBusyRetryTest { public class WxMpBusyRetryTest {
@DataProvider(name="getService") @DataProvider(name = "getService")
public Object[][] getService() { public Object[][] getService() {
WxMpService service = new WxMpServiceImpl() { WxMpService service = new WxMpServiceImpl() {
@@ -32,7 +31,7 @@ public class WxMpBusyRetryTest {
service.setMaxRetryTimes(3); service.setMaxRetryTimes(3);
service.setRetrySleepMillis(500); service.setRetrySleepMillis(500);
return new Object[][] { { service } }; return new Object[][]{{service}};
} }
@Test(dataProvider = "getService", expectedExceptions = RuntimeException.class) @Test(dataProvider = "getService", expectedExceptions = RuntimeException.class)

View File

@@ -1,14 +1,11 @@
package me.chanjar.weixin.mp.api; package me.chanjar.weixin.mp.api;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import org.testng.Assert;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import com.google.inject.Inject; import com.google.inject.Inject;
import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.crypto.SHA1; import me.chanjar.weixin.common.util.crypto.SHA1;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import org.testng.*;
import org.testng.annotations.*;
/** /**
* 测试jsapi ticket接口 * 测试jsapi ticket接口

View File

@@ -12,10 +12,8 @@ import me.chanjar.weixin.mp.bean.WxMpMassTagMessage;
import me.chanjar.weixin.mp.bean.WxMpMassVideo; import me.chanjar.weixin.mp.bean.WxMpMassVideo;
import me.chanjar.weixin.mp.bean.result.WxMpMassSendResult; import me.chanjar.weixin.mp.bean.result.WxMpMassSendResult;
import me.chanjar.weixin.mp.bean.result.WxMpMassUploadResult; import me.chanjar.weixin.mp.bean.result.WxMpMassUploadResult;
import org.testng.Assert; import org.testng.*;
import org.testng.annotations.DataProvider; import org.testng.annotations.*;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;

View File

@@ -5,16 +5,15 @@ import me.chanjar.weixin.common.session.StandardSessionManager;
import me.chanjar.weixin.common.session.WxSessionManager; import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import org.testng.Assert; import org.testng.*;
import org.testng.annotations.DataProvider; import org.testng.annotations.*;
import org.testng.annotations.Test;
import java.util.Map; import java.util.Map;
/** /**
* 测试消息路由器 * 测试消息路由器
* @author chanjarster
* *
* @author chanjarster
*/ */
@Test @Test
public class WxMpMessageRouterTest { public class WxMpMessageRouterTest {
@@ -51,7 +50,7 @@ public class WxMpMessageRouterTest {
.rule().async(async).handler(new WxEchoMpMessageHandler(sb, "ALL")).end(); .rule().async(async).handler(new WxEchoMpMessageHandler(sb, "ALL")).end();
} }
@Test(dataProvider="messages-1") @Test(dataProvider = "messages-1")
public void testSync(WxMpXmlMessage message, String expected) { public void testSync(WxMpXmlMessage message, String expected) {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
WxMpMessageRouter router = new WxMpMessageRouter(null); WxMpMessageRouter router = new WxMpMessageRouter(null);
@@ -60,7 +59,7 @@ public class WxMpMessageRouterTest {
Assert.assertEquals(sb.toString(), expected); Assert.assertEquals(sb.toString(), expected);
} }
@Test(dataProvider="messages-1") @Test(dataProvider = "messages-1")
public void testAsync(WxMpXmlMessage message, String expected) throws InterruptedException { public void testAsync(WxMpXmlMessage message, String expected) throws InterruptedException {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
WxMpMessageRouter router = new WxMpMessageRouter(null); WxMpMessageRouter router = new WxMpMessageRouter(null);
@@ -97,7 +96,8 @@ public class WxMpMessageRouterTest {
Thread.sleep(1000l * 2); Thread.sleep(1000l * 2);
} }
@DataProvider(name="messages-1")
@DataProvider(name = "messages-1")
public Object[][] messages2() { public Object[][] messages2() {
WxMpXmlMessage message1 = new WxMpXmlMessage(); WxMpXmlMessage message1 = new WxMpXmlMessage();
message1.setMsgType(WxConsts.XML_MSG_TEXT); message1.setMsgType(WxConsts.XML_MSG_TEXT);
@@ -135,40 +135,21 @@ public class WxMpMessageRouterTest {
c4.setEventKey("KEY_1"); c4.setEventKey("KEY_1");
c4.setContent("CONTENT_1"); c4.setContent("CONTENT_1");
return new Object[][] { return new Object[][]{
new Object[] { message1, WxConsts.XML_MSG_TEXT + "," }, new Object[]{message1, WxConsts.XML_MSG_TEXT + ","},
new Object[] { message2, WxConsts.EVT_CLICK + "," }, new Object[]{message2, WxConsts.EVT_CLICK + ","},
new Object[] { message3, "KEY_1," }, new Object[]{message3, "KEY_1,"},
new Object[] { message4, "CONTENT_1," }, new Object[]{message4, "CONTENT_1,"},
new Object[] { message5, "ALL," }, new Object[]{message5, "ALL,"},
new Object[] { message6, "abcd," }, new Object[]{message6, "abcd,"},
new Object[] { message7, "matcher," }, new Object[]{message7, "matcher,"},
new Object[] { c2, "COMBINE_2," }, new Object[]{c2, "COMBINE_2,"},
new Object[] { c3, "COMBINE_3," }, new Object[]{c3, "COMBINE_3,"},
new Object[] { c4, "COMBINE_4," } new Object[]{c4, "COMBINE_4,"}
}; };
} }
public static class WxEchoMpMessageHandler implements WxMpMessageHandler {
private StringBuffer sb;
private String echoStr;
public WxEchoMpMessageHandler(StringBuffer sb, String echoStr) {
this.sb = sb;
this.echoStr = echoStr;
}
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context, WxMpService wxMpService,
WxSessionManager sessionManager) {
this.sb.append(this.echoStr).append(',');
return null;
}
}
@DataProvider @DataProvider
public Object[][] standardSessionManager() { public Object[][] standardSessionManager() {
@@ -178,8 +159,8 @@ public class WxMpMessageRouterTest {
ism.setProcessExpiresFrequency(1); ism.setProcessExpiresFrequency(1);
ism.setBackgroundProcessorDelay(1); ism.setBackgroundProcessorDelay(1);
return new Object[][] { return new Object[][]{
new Object[] { ism } new Object[]{ism}
}; };
} }
@@ -290,6 +271,25 @@ public class WxMpMessageRouterTest {
} }
} }
public static class WxEchoMpMessageHandler implements WxMpMessageHandler {
private StringBuffer sb;
private String echoStr;
public WxEchoMpMessageHandler(StringBuffer sb, String echoStr) {
this.sb = sb;
this.echoStr = echoStr;
}
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context, WxMpService wxMpService,
WxSessionManager sessionManager) {
this.sb.append(this.echoStr).append(',');
return null;
}
}
public static class WxSessionMessageHandler implements WxMpMessageHandler { public static class WxSessionMessageHandler implements WxMpMessageHandler {
@Override @Override

View File

@@ -3,16 +3,13 @@ package me.chanjar.weixin.mp.api;
import com.google.inject.Inject; import com.google.inject.Inject;
import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.test.ApiTestModule; import me.chanjar.weixin.mp.api.test.ApiTestModule;
import org.testng.Assert; import org.testng.*;
import org.testng.annotations.Guice; import org.testng.annotations.*;
import org.testng.annotations.Test;
import java.util.Arrays; import java.util.Arrays;
/** /**
*
* @author chanjarster * @author chanjarster
*
*/ */
@Test(groups = "miscAPI") @Test(groups = "miscAPI")
@Guice(modules = ApiTestModule.class) @Guice(modules = ApiTestModule.class)

View File

@@ -3,9 +3,8 @@ package me.chanjar.weixin.mp.api;
import com.google.inject.Inject; import com.google.inject.Inject;
import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.test.ApiTestModule; import me.chanjar.weixin.mp.api.test.ApiTestModule;
import org.testng.Assert; import org.testng.*;
import org.testng.annotations.Guice; import org.testng.annotations.*;
import org.testng.annotations.Test;
/** /**
* 测试短连接 * 测试短连接

View File

@@ -2,17 +2,17 @@ package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject; import com.google.inject.Inject;
import me.chanjar.weixin.common.bean.WxCardApiSignature; import me.chanjar.weixin.common.bean.WxCardApiSignature;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.bean.result.WxMpCardResult; import me.chanjar.weixin.mp.bean.result.WxMpCardResult;
import org.testng.annotations.Guice; import org.testng.annotations.*;
import org.testng.annotations.Test;
import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.*;
/** /**
* 测试代码仅供参考,未做严格测试,因原接口作者并未提供单元测试代码 * 测试代码仅供参考,未做严格测试,因原接口作者并未提供单元测试代码
* Created by Binary Wang on 2016/7/27. * Created by Binary Wang on 2016/7/27.
*
* @author binarywang (https://github.com/binarywang) * @author binarywang (https://github.com/binarywang)
*/ */
@Test @Test

View File

@@ -1,67 +1,58 @@
package me.chanjar.weixin.mp.api.impl; package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.bean.datacube.*;
import org.apache.commons.lang3.time.FastDateFormat;
import org.testng.*;
import org.testng.annotations.*;
import java.text.ParseException; import java.text.ParseException;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import me.chanjar.weixin.mp.api.WxMpService;
import org.apache.commons.lang3.time.FastDateFormat;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import com.google.inject.Inject;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeArticleResult;
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeArticleTotal;
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeInterfaceResult;
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeMsgResult;
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate;
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary;
/** /**
* 测试统计分析相关的接口 * 测试统计分析相关的接口
* Created by Binary Wang on 2016/8/23. * Created by Binary Wang on 2016/8/23.
*
* @author binarywang (https://github.com/binarywang) * @author binarywang (https://github.com/binarywang)
*/ */
@Guice(modules = ApiTestModule.class) @Guice(modules = ApiTestModule.class)
public class WxMpDataCubeServiceImplTest { public class WxMpDataCubeServiceImplTest {
@Inject
protected WxMpService wxService;
private FastDateFormat simpleDateFormat = FastDateFormat private FastDateFormat simpleDateFormat = FastDateFormat
.getInstance("yyyy-MM-dd"); .getInstance("yyyy-MM-dd");
@Inject
protected WxMpService wxService;
@DataProvider @DataProvider
public Object[][] oneDay() throws ParseException { public Object[][] oneDay() throws ParseException {
return new Object[][] { { this.simpleDateFormat.parse("2016-08-22") } }; return new Object[][]{{this.simpleDateFormat.parse("2016-08-22")}};
} }
@DataProvider @DataProvider
public Object[][] threeDays() throws ParseException { public Object[][] threeDays() throws ParseException {
return new Object[][] { { this.simpleDateFormat.parse("2016-08-20"), return new Object[][]{{this.simpleDateFormat.parse("2016-08-20"),
this.simpleDateFormat.parse("2016-08-22") } }; this.simpleDateFormat.parse("2016-08-22")}};
} }
@DataProvider @DataProvider
public Object[][] sevenDays() throws ParseException { public Object[][] sevenDays() throws ParseException {
return new Object[][] { { this.simpleDateFormat.parse("2016-08-16"), return new Object[][]{{this.simpleDateFormat.parse("2016-08-16"),
this.simpleDateFormat.parse("2016-08-22") } }; this.simpleDateFormat.parse("2016-08-22")}};
} }
@DataProvider @DataProvider
public Object[][] fifteenDays() throws ParseException { public Object[][] fifteenDays() throws ParseException {
return new Object[][] { { this.simpleDateFormat.parse("2016-08-14"), return new Object[][]{{this.simpleDateFormat.parse("2016-08-14"),
this.simpleDateFormat.parse("2016-08-27") } }; this.simpleDateFormat.parse("2016-08-27")}};
} }
@DataProvider @DataProvider
public Object[][] thirtyDays() throws ParseException { public Object[][] thirtyDays() throws ParseException {
return new Object[][] { { this.simpleDateFormat.parse("2016-07-30"), return new Object[][]{{this.simpleDateFormat.parse("2016-07-30"),
this.simpleDateFormat.parse("2016-08-27") } }; this.simpleDateFormat.parse("2016-08-27")}};
} }
@Test(dataProvider = "sevenDays") @Test(dataProvider = "sevenDays")

View File

@@ -3,12 +3,10 @@ package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject; import com.google.inject.Inject;
import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.bean.device.WxDeviceQrCodeResult; import me.chanjar.weixin.mp.bean.device.WxDeviceQrCodeResult;
import org.testng.annotations.DataProvider; import org.testng.annotations.*;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
/** /**
* Created by keungtung on 14/12/2016. * Created by keungtung on 14/12/2016.

View File

@@ -3,25 +3,23 @@ package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject; import com.google.inject.Inject;
import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.api.test.TestConfigStorage; import me.chanjar.weixin.mp.api.test.TestConfigStorage;
import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage; import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage;
import me.chanjar.weixin.mp.bean.kefu.request.WxMpKfAccountRequest; import me.chanjar.weixin.mp.bean.kefu.request.WxMpKfAccountRequest;
import me.chanjar.weixin.mp.bean.kefu.result.*; import me.chanjar.weixin.mp.bean.kefu.result.*;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.testng.Assert; import org.testng.*;
import org.testng.annotations.DataProvider; import org.testng.annotations.*;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import java.io.File; import java.io.File;
import java.util.Date; import java.util.Date;
/** /**
* 测试客服相关接口 * 测试客服相关接口
* @author Binary Wang
* *
* @author Binary Wang
*/ */
@Test @Test
@Guice(modules = ApiTestModule.class) @Guice(modules = ApiTestModule.class)
@@ -87,7 +85,7 @@ public class WxMpKefuServiceImplTest {
public Object[][] getKfAccount() { public Object[][] getKfAccount() {
TestConfigStorage configStorage = (TestConfigStorage) this.wxService TestConfigStorage configStorage = (TestConfigStorage) this.wxService
.getWxMpConfigStorage(); .getWxMpConfigStorage();
return new Object[][] { { configStorage.getKfAccount() } }; return new Object[][]{{configStorage.getKfAccount()}};
} }
@Test(dataProvider = "getKfAccount") @Test(dataProvider = "getKfAccount")
@@ -98,7 +96,7 @@ public class WxMpKefuServiceImplTest {
} }
@Test(dependsOnMethods = { @Test(dependsOnMethods = {
"testKfAccountAdd" }, dataProvider = "getKfAccount") "testKfAccountAdd"}, dataProvider = "getKfAccount")
public void testKfAccountUpdate(String kfAccount) throws WxErrorException { public void testKfAccountUpdate(String kfAccount) throws WxErrorException {
WxMpKfAccountRequest request = WxMpKfAccountRequest.builder() WxMpKfAccountRequest request = WxMpKfAccountRequest.builder()
.kfAccount(kfAccount).nickName("我晕").build(); .kfAccount(kfAccount).nickName("我晕").build();
@@ -106,7 +104,7 @@ public class WxMpKefuServiceImplTest {
} }
@Test(dependsOnMethods = { @Test(dependsOnMethods = {
"testKfAccountAdd" }, dataProvider = "getKfAccount") "testKfAccountAdd"}, dataProvider = "getKfAccount")
public void testKfAccountInviteWorker(String kfAccount) throws WxErrorException { public void testKfAccountInviteWorker(String kfAccount) throws WxErrorException {
WxMpKfAccountRequest request = WxMpKfAccountRequest.builder() WxMpKfAccountRequest request = WxMpKfAccountRequest.builder()
.kfAccount(kfAccount).inviteWx(" ").build(); .kfAccount(kfAccount).inviteWx(" ").build();
@@ -114,7 +112,7 @@ public class WxMpKefuServiceImplTest {
} }
@Test(dependsOnMethods = { @Test(dependsOnMethods = {
"testKfAccountUpdate" }, dataProvider = "getKfAccount") "testKfAccountUpdate"}, dataProvider = "getKfAccount")
public void testKfAccountUploadHeadImg(String kfAccount) public void testKfAccountUploadHeadImg(String kfAccount)
throws WxErrorException { throws WxErrorException {
File imgFile = new File("src\\test\\resources\\mm.jpeg"); File imgFile = new File("src\\test\\resources\\mm.jpeg");
@@ -133,8 +131,8 @@ public class WxMpKefuServiceImplTest {
public Object[][] getKfAccountAndOpenid() { public Object[][] getKfAccountAndOpenid() {
TestConfigStorage configStorage = (TestConfigStorage) this.wxService TestConfigStorage configStorage = (TestConfigStorage) this.wxService
.getWxMpConfigStorage(); .getWxMpConfigStorage();
return new Object[][] { return new Object[][]{
{ configStorage.getKfAccount(), configStorage.getOpenid() } }; {configStorage.getKfAccount(), configStorage.getOpenid()}};
} }
@Test(dataProvider = "getKfAccountAndOpenid") @Test(dataProvider = "getKfAccountAndOpenid")
@@ -182,7 +180,7 @@ public class WxMpKefuServiceImplTest {
public void testKfMsgList() throws WxErrorException { public void testKfMsgList() throws WxErrorException {
Date startTime = DateTime.now().minusDays(1).toDate(); Date startTime = DateTime.now().minusDays(1).toDate();
Date endTime = DateTime.now().minusDays(0).toDate(); Date endTime = DateTime.now().minusDays(0).toDate();
WxMpKfMsgList result = this.wxService.getKefuService().kfMsgList(startTime,endTime, 1L, 50); WxMpKfMsgList result = this.wxService.getKefuService().kfMsgList(startTime, endTime, 1L, 50);
Assert.assertNotNull(result); Assert.assertNotNull(result);
System.err.println(result); System.err.println(result);
} }
@@ -191,7 +189,7 @@ public class WxMpKefuServiceImplTest {
public void testKfMsgListAll() throws WxErrorException { public void testKfMsgListAll() throws WxErrorException {
Date startTime = DateTime.now().minusDays(1).toDate(); Date startTime = DateTime.now().minusDays(1).toDate();
Date endTime = DateTime.now().minusDays(0).toDate(); Date endTime = DateTime.now().minusDays(0).toDate();
WxMpKfMsgList result = this.wxService.getKefuService().kfMsgList(startTime,endTime); WxMpKfMsgList result = this.wxService.getKefuService().kfMsgList(startTime, endTime);
Assert.assertNotNull(result); Assert.assertNotNull(result);
System.err.println(result); System.err.println(result);
} }

View File

@@ -5,15 +5,10 @@ import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.fs.FileUtils; import me.chanjar.weixin.common.util.fs.FileUtils;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.material.WxMpMaterial; import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.bean.material.WxMpMaterialArticleUpdate;
import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews;
import me.chanjar.weixin.mp.bean.material.*; import me.chanjar.weixin.mp.bean.material.*;
import org.testng.annotations.DataProvider; import org.testng.annotations.*;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@@ -44,14 +39,16 @@ public class WxMpMaterialServiceImplTest {
private String multiNewsMediaId = ""; private String multiNewsMediaId = "";
// 先查询保存测试开始前永久素材数据 // 先查询保存测试开始前永久素材数据
private WxMpMaterialCountResult wxMaterialCountResultBeforeTest; private WxMpMaterialCountResult wxMaterialCountResultBeforeTest;
// 以下为media接口的测试
private List<String> mediaIdsToDownload = new ArrayList<>();
@DataProvider @DataProvider
public Object[][] mediaFiles() { public Object[][] mediaFiles() {
return new Object[][] { return new Object[][]{
new Object[] { WxConsts.MEDIA_IMAGE, WxConsts.FILE_JPG, "mm.jpeg" }, new Object[]{WxConsts.MEDIA_IMAGE, WxConsts.FILE_JPG, "mm.jpeg"},
new Object[] { WxConsts.MEDIA_VOICE, WxConsts.FILE_MP3, "mm.mp3" }, new Object[]{WxConsts.MEDIA_VOICE, WxConsts.FILE_MP3, "mm.mp3"},
new Object[] { WxConsts.MEDIA_VIDEO, WxConsts.FILE_MP4, "mm.mp4" }, new Object[]{WxConsts.MEDIA_VIDEO, WxConsts.FILE_MP4, "mm.mp4"},
new Object[] { WxConsts.MEDIA_THUMB, WxConsts.FILE_JPG, "mm.jpeg" } new Object[]{WxConsts.MEDIA_THUMB, WxConsts.FILE_JPG, "mm.jpeg"}
}; };
} }
@@ -266,12 +263,9 @@ public class WxMpMaterialServiceImplTest {
return params.iterator(); return params.iterator();
} }
// 以下为media接口的测试 @Test(dataProvider = "mediaFiles")
private List<String> mediaIdsToDownload = new ArrayList<>();
@Test(dataProvider="mediaFiles")
public void testUploadMedia(String mediaType, String fileType, String fileName) throws WxErrorException, IOException { public void testUploadMedia(String mediaType, String fileType, String fileName) throws WxErrorException, IOException {
try(InputStream inputStream = ClassLoader.getSystemResourceAsStream(fileName)){ try (InputStream inputStream = ClassLoader.getSystemResourceAsStream(fileName)) {
WxMediaUploadResult res = this.wxService.getMaterialService().mediaUpload(mediaType, fileType, inputStream); WxMediaUploadResult res = this.wxService.getMaterialService().mediaUpload(mediaType, fileType, inputStream);
assertNotNull(res.getType()); assertNotNull(res.getType());
assertNotNull(res.getCreatedAt()); assertNotNull(res.getCreatedAt());
@@ -294,12 +288,12 @@ public class WxMpMaterialServiceImplTest {
public Object[][] downloadMedia() { public Object[][] downloadMedia() {
Object[][] params = new Object[this.mediaIdsToDownload.size()][]; Object[][] params = new Object[this.mediaIdsToDownload.size()][];
for (int i = 0; i < this.mediaIdsToDownload.size(); i++) { for (int i = 0; i < this.mediaIdsToDownload.size(); i++) {
params[i] = new Object[] { this.mediaIdsToDownload.get(i) }; params[i] = new Object[]{this.mediaIdsToDownload.get(i)};
} }
return params; return params;
} }
@Test(dependsOnMethods = { "testUploadMedia" }, dataProvider="downloadMedia") @Test(dependsOnMethods = {"testUploadMedia"}, dataProvider = "downloadMedia")
public void testDownloadMedia(String mediaId) throws WxErrorException { public void testDownloadMedia(String mediaId) throws WxErrorException {
File file = this.wxService.getMaterialService().mediaDownload(mediaId); File file = this.wxService.getMaterialService().mediaDownload(mediaId);
assertNotNull(file); assertNotNull(file);

View File

@@ -5,8 +5,8 @@ import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.bean.menu.WxMenu; import me.chanjar.weixin.common.bean.menu.WxMenu;
import me.chanjar.weixin.common.bean.menu.WxMenuButton; import me.chanjar.weixin.common.bean.menu.WxMenuButton;
import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.bean.menu.WxMpGetSelfMenuInfoResult; import me.chanjar.weixin.mp.bean.menu.WxMpGetSelfMenuInfoResult;
import me.chanjar.weixin.mp.bean.menu.WxMpMenu; import me.chanjar.weixin.mp.bean.menu.WxMpMenu;
import org.testng.*; import org.testng.*;

View File

@@ -3,8 +3,8 @@ package me.chanjar.weixin.mp.api.impl;
import com.github.binarywang.utils.qrcode.QrcodeUtils; import com.github.binarywang.utils.qrcode.QrcodeUtils;
import com.google.inject.Inject; import com.google.inject.Inject;
import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.api.test.TestConfigStorage; import me.chanjar.weixin.mp.api.test.TestConfigStorage;
import me.chanjar.weixin.mp.bean.pay.request.*; import me.chanjar.weixin.mp.bean.pay.request.*;
import me.chanjar.weixin.mp.bean.pay.result.*; import me.chanjar.weixin.mp.bean.pay.result.*;
@@ -36,10 +36,10 @@ public class WxMpPayServiceImplTest {
@Test @Test
public void testDownloadBill() throws Exception { public void testDownloadBill() throws Exception {
File file = this.wxService.getPayService().downloadBill("20170101","ALL","GZIP","1111111"); File file = this.wxService.getPayService().downloadBill("20170101", "ALL", "GZIP", "1111111");
assertNotNull(file); assertNotNull(file);
//必填字段为空时,抛出异常 //必填字段为空时,抛出异常
this.wxService.getPayService().downloadBill("","","",null); this.wxService.getPayService().downloadBill("", "", "", null);
} }
@Test @Test
@@ -58,7 +58,7 @@ public class WxMpPayServiceImplTest {
* 需要证书的接口需要先执行该方法 * 需要证书的接口需要先执行该方法
*/ */
@Test @Test
public void setSSLKey(){ public void setSSLKey() {
TestConfigStorage config = (TestConfigStorage) this.wxService.getWxMpConfigStorage(); TestConfigStorage config = (TestConfigStorage) this.wxService.getWxMpConfigStorage();
config.setSslContextFilePath(config.getKeyPath()); config.setSslContextFilePath(config.getKeyPath());
} }

View File

@@ -2,13 +2,11 @@ package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject; import com.google.inject.Inject;
import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket; import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;
import org.testng.Assert; import org.testng.*;
import org.testng.annotations.DataProvider; import org.testng.annotations.*;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import java.io.File; import java.io.File;

View File

@@ -2,12 +2,11 @@ package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject; import com.google.inject.Inject;
import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.api.test.TestConfigStorage; import me.chanjar.weixin.mp.api.test.TestConfigStorage;
import org.testng.Assert; import org.testng.*;
import org.testng.annotations.Guice; import org.testng.annotations.*;
import org.testng.annotations.Test;
@Test @Test
@Guice(modules = ApiTestModule.class) @Guice(modules = ApiTestModule.class)

View File

@@ -2,13 +2,12 @@ package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject; import com.google.inject.Inject;
import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.bean.store.WxMpStoreBaseInfo; import me.chanjar.weixin.mp.bean.store.WxMpStoreBaseInfo;
import me.chanjar.weixin.mp.bean.store.WxMpStoreInfo; import me.chanjar.weixin.mp.bean.store.WxMpStoreInfo;
import me.chanjar.weixin.mp.bean.store.WxMpStoreListResult; import me.chanjar.weixin.mp.bean.store.WxMpStoreListResult;
import org.testng.annotations.Guice; import org.testng.annotations.*;
import org.testng.annotations.Test;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.List;
@@ -18,7 +17,6 @@ import static org.junit.Assert.assertNotNull;
/** /**
* @author <a href="https://github.com/binarywang">binarywang(Binary Wang)</a> * @author <a href="https://github.com/binarywang">binarywang(Binary Wang)</a>
* Created by Binary Wang on 2016-09-23. * Created by Binary Wang on 2016-09-23.
*
*/ */
@Test @Test
@Guice(modules = ApiTestModule.class) @Guice(modules = ApiTestModule.class)
@@ -28,13 +26,14 @@ public class WxMpStoreServiceImplTest {
/** /**
* Test method for {@link me.chanjar.weixin.mp.api.impl.WxMpStoreServiceImpl#add(me.chanjar.weixin.mp.bean.store.WxMpStoreBaseInfo)}. * Test method for {@link me.chanjar.weixin.mp.api.impl.WxMpStoreServiceImpl#add(me.chanjar.weixin.mp.bean.store.WxMpStoreBaseInfo)}.
*
* @throws WxErrorException * @throws WxErrorException
*/ */
public void testAdd() throws WxErrorException { public void testAdd() throws WxErrorException {
this.wxMpService.getStoreService().add(WxMpStoreBaseInfo.builder().build()); this.wxMpService.getStoreService().add(WxMpStoreBaseInfo.builder().build());
this.wxMpService.getStoreService() this.wxMpService.getStoreService()
.add(WxMpStoreBaseInfo.builder().businessName("haha").branchName("abc") .add(WxMpStoreBaseInfo.builder().businessName("haha").branchName("abc")
.province("aaa").district("aaa").telephone("122").address("abc").categories(new String[] { "美食,江浙菜" }) .province("aaa").district("aaa").telephone("122").address("abc").categories(new String[]{"美食,江浙菜"})
.longitude(new BigDecimal("115.32375")) .longitude(new BigDecimal("115.32375"))
.latitude(new BigDecimal("25.097486")).city("aaa").offsetType(1) .latitude(new BigDecimal("25.097486")).city("aaa").offsetType(1)
.build()); .build());

View File

@@ -2,17 +2,16 @@ package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject; import com.google.inject.Inject;
import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.api.test.TestConfigStorage; import me.chanjar.weixin.mp.api.test.TestConfigStorage;
import me.chanjar.weixin.mp.bean.template.WxMpTemplate; import me.chanjar.weixin.mp.bean.template.WxMpTemplate;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData; import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateIndustry; import me.chanjar.weixin.mp.bean.template.WxMpTemplateIndustry;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage; import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.testng.Assert; import org.testng.*;
import org.testng.annotations.Guice; import org.testng.annotations.*;
import org.testng.annotations.Test;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
@@ -39,7 +38,7 @@ public class WxMpTemplateMsgServiceImplTest {
.toUser(configStorage.getOpenid()) .toUser(configStorage.getOpenid())
.templateId(configStorage.getTemplateId()).build(); .templateId(configStorage.getTemplateId()).build();
templateMessage.addWxMpTemplateData( templateMessage.addWxMpTemplateData(
new WxMpTemplateData("first", dateFormat.format(new Date()),"#FF00FF")); new WxMpTemplateData("first", dateFormat.format(new Date()), "#FF00FF"));
templateMessage.addWxMpTemplateData( templateMessage.addWxMpTemplateData(
new WxMpTemplateData("remark", RandomStringUtils.randomAlphanumeric(100), "#FF00FF")); new WxMpTemplateData("remark", RandomStringUtils.randomAlphanumeric(100), "#FF00FF"));
templateMessage.setUrl(" "); templateMessage.setUrl(" ");

View File

@@ -1,12 +1,11 @@
package me.chanjar.weixin.mp.api.impl; package me.chanjar.weixin.mp.api.impl;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.api.test.TestConfigStorage; import me.chanjar.weixin.mp.api.test.TestConfigStorage;
import me.chanjar.weixin.mp.bean.result.WxMpUserBlacklistGetResult; import me.chanjar.weixin.mp.bean.result.WxMpUserBlacklistGetResult;
import org.testng.Assert; import org.testng.*;
import org.testng.annotations.Guice; import org.testng.annotations.*;
import org.testng.annotations.Test;
import javax.inject.Inject; import javax.inject.Inject;
import java.util.ArrayList; import java.util.ArrayList;

View File

@@ -1,23 +1,18 @@
package me.chanjar.weixin.mp.api.impl; package me.chanjar.weixin.mp.api.impl;
import java.util.ArrayList;
import java.util.List;
import me.chanjar.weixin.mp.api.WxMpService;
import org.testng.Assert;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import com.google.inject.Inject; import com.google.inject.Inject;
import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule; import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.api.test.TestConfigStorage; import me.chanjar.weixin.mp.api.test.TestConfigStorage;
import me.chanjar.weixin.mp.bean.WxMpUserQuery; import me.chanjar.weixin.mp.bean.WxMpUserQuery;
import me.chanjar.weixin.mp.bean.result.WxMpUser; import me.chanjar.weixin.mp.bean.result.WxMpUser;
import me.chanjar.weixin.mp.bean.result.WxMpUserList; import me.chanjar.weixin.mp.bean.result.WxMpUserList;
import org.testng.*;
import org.testng.annotations.*;
import java.util.ArrayList;
import java.util.List;
/** /**
* 测试用户相关的接口 * 测试用户相关的接口

View File

@@ -1,21 +1,17 @@
package me.chanjar.weixin.mp.api.impl; package me.chanjar.weixin.mp.api.impl;
import java.util.List;
import me.chanjar.weixin.mp.api.WxMpService;
import org.testng.Assert;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import com.google.inject.Inject; import com.google.inject.Inject;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule; import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.api.test.TestConfigStorage; import me.chanjar.weixin.mp.api.test.TestConfigStorage;
import me.chanjar.weixin.mp.bean.tag.WxTagListUser; import me.chanjar.weixin.mp.bean.tag.WxTagListUser;
import me.chanjar.weixin.mp.bean.tag.WxUserTag; import me.chanjar.weixin.mp.bean.tag.WxUserTag;
import org.testng.*;
import org.testng.annotations.*;
import java.util.List;
/** /**
*
* @author <a href="https://github.com/binarywang">binarywang(Binary Wang)</a> * @author <a href="https://github.com/binarywang">binarywang(Binary Wang)</a>
* Created by Binary Wang on 2016/9/2. * Created by Binary Wang on 2016/9/2.
*/ */
@@ -43,7 +39,7 @@ public class WxMpUserTagServiceImplTest {
Assert.assertNotNull(res); Assert.assertNotNull(res);
} }
@Test(dependsOnMethods = { "testTagCreate" }) @Test(dependsOnMethods = {"testTagCreate"})
public void testTagUpdate() throws Exception { public void testTagUpdate() throws Exception {
String tagName = "修改标签" + System.currentTimeMillis(); String tagName = "修改标签" + System.currentTimeMillis();
Boolean res = this.wxService.getUserTagService().tagUpdate(this.tagId, tagName); Boolean res = this.wxService.getUserTagService().tagUpdate(this.tagId, tagName);
@@ -51,7 +47,7 @@ public class WxMpUserTagServiceImplTest {
Assert.assertTrue(res); Assert.assertTrue(res);
} }
@Test(dependsOnMethods = { "testTagCreate" }) @Test(dependsOnMethods = {"testTagCreate"})
public void testTagDelete() throws Exception { public void testTagDelete() throws Exception {
Boolean res = this.wxService.getUserTagService().tagDelete(this.tagId); Boolean res = this.wxService.getUserTagService().tagDelete(this.tagId);
System.out.println(res); System.out.println(res);

View File

@@ -2,8 +2,8 @@ package me.chanjar.weixin.mp.bean.kefu;
import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage.WxArticle; import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage.WxArticle;
import org.testng.Assert; import org.testng.*;
import org.testng.annotations.Test; import org.testng.annotations.*;
@Test @Test
public class WxMpKefuMessageTest { public class WxMpKefuMessageTest {

View File

@@ -1,14 +1,14 @@
package me.chanjar.weixin.mp.bean.kefu.result; package me.chanjar.weixin.mp.bean.kefu.result;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.testng.Assert; import org.testng.*;
import org.testng.annotations.Test; import org.testng.annotations.*;
@Test @Test
public class WxMpKfListTest { public class WxMpKfListTest {
public void testFromJson() { public void testFromJson() {
String json=" {\r\n" + String json = " {\r\n" +
" \"kf_list\" : [\r\n" + " \"kf_list\" : [\r\n" +
" {\r\n" + " {\r\n" +
" \"kf_account\" : \"test1@test\",\r\n" + " \"kf_account\" : \"test1@test\",\r\n" +

View File

@@ -1,10 +1,8 @@
package me.chanjar.weixin.mp.bean.kefu.result; package me.chanjar.weixin.mp.bean.kefu.result;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.testng.Assert; import org.testng.*;
import org.testng.annotations.Test; import org.testng.annotations.*;
import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfOnlineList;
@Test @Test
public class WxMpKfOnlineListTest { public class WxMpKfOnlineListTest {

View File

@@ -1,8 +1,8 @@
package me.chanjar.weixin.mp.bean.message; package me.chanjar.weixin.mp.bean.message;
import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.api.WxConsts;
import org.testng.Assert; import org.testng.*;
import org.testng.annotations.Test; import org.testng.annotations.*;
@Test @Test
public class WxMpXmlMessageTest { public class WxMpXmlMessageTest {

View File

@@ -1,7 +1,7 @@
package me.chanjar.weixin.mp.bean.message; package me.chanjar.weixin.mp.bean.message;
import org.testng.Assert; import org.testng.*;
import org.testng.annotations.Test; import org.testng.annotations.*;
@Test @Test
public class WxMpXmlOutImageMessageTest { public class WxMpXmlOutImageMessageTest {

View File

@@ -1,7 +1,7 @@
package me.chanjar.weixin.mp.bean.message; package me.chanjar.weixin.mp.bean.message;
import org.testng.Assert; import org.testng.*;
import org.testng.annotations.Test; import org.testng.annotations.*;
@Test @Test
public class WxMpXmlOutMusicMessageTest { public class WxMpXmlOutMusicMessageTest {

View File

@@ -1,7 +1,7 @@
package me.chanjar.weixin.mp.bean.message; package me.chanjar.weixin.mp.bean.message;
import org.testng.Assert; import org.testng.*;
import org.testng.annotations.Test; import org.testng.annotations.*;
@Test @Test
public class WxMpXmlOutNewsMessageTest { public class WxMpXmlOutNewsMessageTest {

View File

@@ -1,7 +1,7 @@
package me.chanjar.weixin.mp.bean.message; package me.chanjar.weixin.mp.bean.message;
import org.testng.Assert; import org.testng.*;
import org.testng.annotations.Test; import org.testng.annotations.*;
@Test @Test
public class WxMpXmlOutTextMessageTest { public class WxMpXmlOutTextMessageTest {

View File

@@ -1,7 +1,7 @@
package me.chanjar.weixin.mp.bean.message; package me.chanjar.weixin.mp.bean.message;
import org.testng.Assert; import org.testng.*;
import org.testng.annotations.Test; import org.testng.annotations.*;
/** /**
* Created by ben on 2015/12/29. * Created by ben on 2015/12/29.

View File

@@ -1,7 +1,7 @@
package me.chanjar.weixin.mp.bean.message; package me.chanjar.weixin.mp.bean.message;
import org.testng.Assert; import org.testng.*;
import org.testng.annotations.Test; import org.testng.annotations.*;
@Test @Test
public class WxMpXmlOutVideoMessageTest { public class WxMpXmlOutVideoMessageTest {

View File

@@ -1,7 +1,7 @@
package me.chanjar.weixin.mp.bean.message; package me.chanjar.weixin.mp.bean.message;
import org.testng.Assert; import org.testng.*;
import org.testng.annotations.Test; import org.testng.annotations.*;
@Test @Test
public class WxMpXmlOutVoiceMessageTest { public class WxMpXmlOutVoiceMessageTest {

View File

@@ -1,7 +1,7 @@
package me.chanjar.weixin.mp.bean.pay.result; package me.chanjar.weixin.mp.bean.pay.result;
import org.testng.Assert; import org.testng.*;
import org.testng.annotations.Test; import org.testng.annotations.*;
import java.util.Map; import java.util.Map;

View File

@@ -1,7 +1,7 @@
package me.chanjar.weixin.mp.bean.pay.result; package me.chanjar.weixin.mp.bean.pay.result;
import org.testng.Assert; import org.testng.*;
import org.testng.annotations.Test; import org.testng.annotations.*;
/** /**
* <pre> * <pre>

View File

@@ -1,8 +1,8 @@
package me.chanjar.weixin.mp.bean.pay.result; package me.chanjar.weixin.mp.bean.pay.result;
import org.testng.Assert; import org.testng.*;
import org.testng.annotations.Test; import org.testng.annotations.*;
/** /**
* <pre> * <pre>

View File

@@ -2,9 +2,8 @@ package me.chanjar.weixin.mp.bean.pay.result;
import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.XStream;
import me.chanjar.weixin.common.util.xml.XStreamInitializer; import me.chanjar.weixin.common.util.xml.XStreamInitializer;
import org.testng.Assert; import org.testng.*;
import org.testng.annotations.BeforeTest; import org.testng.annotations.*;
import org.testng.annotations.Test;
public class WxPaySendRedpackResultTest { public class WxPaySendRedpackResultTest {

View File

@@ -1,9 +1,5 @@
package me.chanjar.weixin.mp.demo; package me.chanjar.weixin.mp.demo;
import java.util.Map;
import java.util.Random;
import java.util.regex.Pattern;
import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.session.WxSession; import me.chanjar.weixin.common.session.WxSession;
import me.chanjar.weixin.common.session.WxSessionManager; import me.chanjar.weixin.common.session.WxSessionManager;
@@ -14,6 +10,10 @@ import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import java.util.Map;
import java.util.Random;
import java.util.regex.Pattern;
public class DemoGuessNumberHandler implements WxMpMessageHandler, WxMpMessageMatcher { public class DemoGuessNumberHandler implements WxMpMessageHandler, WxMpMessageMatcher {
private Random random = new Random(); private Random random = new Random();

View File

@@ -13,17 +13,16 @@ import java.io.InputStream;
@XStreamAlias("xml") @XStreamAlias("xml")
class WxMpDemoInMemoryConfigStorage extends WxMpInMemoryConfigStorage { class WxMpDemoInMemoryConfigStorage extends WxMpInMemoryConfigStorage {
@Override
public String toString() {
return "SimpleWxConfigProvider [appId=" + this.appId + ", secret=" + this.secret + ", accessToken=" + this.accessToken
+ ", expiresTime=" + this.expiresTime + ", token=" + this.token + ", aesKey=" + this.aesKey + "]";
}
public static WxMpDemoInMemoryConfigStorage fromXml(InputStream is) { public static WxMpDemoInMemoryConfigStorage fromXml(InputStream is) {
XStream xstream = XStreamInitializer.getInstance(); XStream xstream = XStreamInitializer.getInstance();
xstream.processAnnotations(WxMpDemoInMemoryConfigStorage.class); xstream.processAnnotations(WxMpDemoInMemoryConfigStorage.class);
return (WxMpDemoInMemoryConfigStorage) xstream.fromXML(is); return (WxMpDemoInMemoryConfigStorage) xstream.fromXML(is);
} }
@Override
public String toString() {
return "SimpleWxConfigProvider [appId=" + this.appId + ", secret=" + this.secret + ", accessToken=" + this.accessToken
+ ", expiresTime=" + this.expiresTime + ", token=" + this.token + ", aesKey=" + this.aesKey + "]";
}
} }

View File

@@ -1,18 +1,17 @@
package me.chanjar.weixin.mp.demo; package me.chanjar.weixin.mp.demo;
import java.io.IOException;
import java.io.InputStream;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.mp.api.WxMpConfigStorage; import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.api.WxMpMessageHandler; import me.chanjar.weixin.mp.api.WxMpMessageHandler;
import me.chanjar.weixin.mp.api.WxMpMessageRouter; import me.chanjar.weixin.mp.api.WxMpMessageRouter;
import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import java.io.IOException;
import java.io.InputStream;
public class WxMpDemoServer { public class WxMpDemoServer {

View File

@@ -1,16 +1,15 @@
package me.chanjar.weixin.mp.demo; package me.chanjar.weixin.mp.demo;
import java.io.IOException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken; import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
import me.chanjar.weixin.mp.bean.result.WxMpUser; import me.chanjar.weixin.mp.bean.result.WxMpUser;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class WxMpOAuth2Servlet extends HttpServlet { public class WxMpOAuth2Servlet extends HttpServlet {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;