From 123eb5088d06292435d157f3f18b44e26f095c12 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Mon, 23 Jan 2017 16:48:00 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E6=B5=8B=E8=AF=95=E7=B1=BB?= =?UTF-8?q?=E7=9A=84=E5=8C=85=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chanjar/weixin/mp/api/WxMpBaseAPITest.java | 1 + .../chanjar/weixin/mp/api/WxMpJsAPITest.java | 1 + .../weixin/mp/api/WxMpMassMessageAPITest.java | 18 +++++++++--------- .../chanjar/weixin/mp/api/WxMpMiscAPITest.java | 1 + .../weixin/mp/api/WxMpShortUrlAPITest.java | 1 + .../mp/api/impl/WxMpCardServiceImplTest.java | 2 +- .../api/impl/WxMpDataCubeServiceImplTest.java | 2 +- .../mp/api/impl/WxMpDeviceServiceImplTest.java | 2 +- .../mp/api/impl/WxMpKefuServiceImplTest.java | 14 +++++++------- .../api/impl/WxMpMaterialServiceImplTest.java | 2 +- .../mp/api/impl/WxMpMenuServiceImplTest.java | 2 +- .../mp/api/impl/WxMpPayServiceImplTest.java | 8 ++++---- .../mp/api/impl/WxMpQrcodeServiceImplTest.java | 2 +- .../mp/api/impl/WxMpServiceImplTest.java | 6 +++--- .../mp/api/impl/WxMpStoreServiceImplTest.java | 2 +- .../impl/WxMpTemplateMsgServiceImplTest.java | 6 +++--- .../impl/WxMpUserBlacklistServiceImplTest.java | 10 +++++----- .../mp/api/impl/WxMpUserServiceImplTest.java | 8 ++++---- .../api/impl/WxMpUserTagServiceImplTest.java | 10 +++++----- .../mp/api/{ => test}/ApiTestModule.java | 11 ++++++----- .../TestConfigStorage.java} | 11 +++++------ 21 files changed, 62 insertions(+), 58 deletions(-) rename weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/{ => test}/ApiTestModule.java (77%) rename weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/{WxXmlMpInMemoryConfigStorage.java => test/TestConfigStorage.java} (87%) diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpBaseAPITest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpBaseAPITest.java index b6904eb1..c3b53d66 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpBaseAPITest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpBaseAPITest.java @@ -2,6 +2,7 @@ package me.chanjar.weixin.mp.api; import com.google.inject.Inject; import me.chanjar.weixin.common.exception.WxErrorException; +import me.chanjar.weixin.mp.api.test.ApiTestModule; import org.apache.commons.lang3.StringUtils; import org.testng.Assert; import org.testng.annotations.Guice; diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpJsAPITest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpJsAPITest.java index 54dcdc04..8355f216 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpJsAPITest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpJsAPITest.java @@ -1,5 +1,6 @@ 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; diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpMassMessageAPITest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpMassMessageAPITest.java index 99b7a52c..0fd5fcab 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpMassMessageAPITest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpMassMessageAPITest.java @@ -4,6 +4,8 @@ import com.google.inject.Inject; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; import me.chanjar.weixin.common.exception.WxErrorException; +import me.chanjar.weixin.mp.api.test.ApiTestModule; +import me.chanjar.weixin.mp.api.test.TestConfigStorage; import me.chanjar.weixin.mp.bean.WxMpMassNews; import me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage; import me.chanjar.weixin.mp.bean.WxMpMassTagMessage; @@ -33,7 +35,7 @@ public class WxMpMassMessageAPITest { @Test public void testTextMassOpenIdsMessageSend() throws WxErrorException { // 发送群发消息 - WxXmlMpInMemoryConfigStorage configProvider = (WxXmlMpInMemoryConfigStorage) this.wxService + TestConfigStorage configProvider = (TestConfigStorage) this.wxService .getWxMpConfigStorage(); WxMpMassOpenIdsMessage massMessage = new WxMpMassOpenIdsMessage(); massMessage.setMsgType(WxConsts.MASS_MSG_TEXT); @@ -47,10 +49,9 @@ public class WxMpMassMessageAPITest { } @Test(dataProvider = "massMessages") - public void testMediaMassOpenIdsMessageSend(String massMsgType, - String mediaId) throws WxErrorException { + public void testMediaMassOpenIdsMessageSend(String massMsgType, String mediaId) throws WxErrorException { // 发送群发消息 - WxXmlMpInMemoryConfigStorage configProvider = (WxXmlMpInMemoryConfigStorage) this.wxService + TestConfigStorage configProvider = (TestConfigStorage) this.wxService .getWxMpConfigStorage(); WxMpMassOpenIdsMessage massMessage = new WxMpMassOpenIdsMessage(); massMessage.setMsgType(massMsgType); @@ -83,8 +84,7 @@ public class WxMpMassMessageAPITest { WxMpMassTagMessage massMessage = new WxMpMassTagMessage(); massMessage.setMsgType(massMsgType); massMessage.setMediaId(mediaId); - massMessage - .setTagId(this.wxService.getUserTagService().tagGet().get(0).getId()); + massMessage.setTagId(this.wxService.getUserTagService().tagGet().get(0).getId()); WxMpMassSendResult massResult = this.wxService .massGroupMessageSend(massMessage); @@ -118,7 +118,7 @@ public class WxMpMassMessageAPITest { messages[0] = new Object[]{WxConsts.MASS_MSG_VIDEO, uploadResult.getMediaId()}; } - /** + /* * 图片素材 */ try (InputStream inputStream = ClassLoader @@ -130,7 +130,7 @@ public class WxMpMassMessageAPITest { messages[1] = new Object[]{WxConsts.MASS_MSG_IMAGE, uploadMediaRes.getMediaId()}; } - /** + /* * 语音素材 */ try (InputStream inputStream = ClassLoader @@ -142,7 +142,7 @@ public class WxMpMassMessageAPITest { messages[2] = new Object[]{WxConsts.MASS_MSG_VOICE, uploadMediaRes.getMediaId()}; } - /** + /* * 图文素材 */ try (InputStream inputStream = ClassLoader diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpMiscAPITest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpMiscAPITest.java index 656c7162..dd30538f 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpMiscAPITest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpMiscAPITest.java @@ -2,6 +2,7 @@ package me.chanjar.weixin.mp.api; import com.google.inject.Inject; import me.chanjar.weixin.common.exception.WxErrorException; +import me.chanjar.weixin.mp.api.test.ApiTestModule; import org.testng.Assert; import org.testng.annotations.Guice; import org.testng.annotations.Test; diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpShortUrlAPITest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpShortUrlAPITest.java index 87cf7406..f8b0ce6f 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpShortUrlAPITest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpShortUrlAPITest.java @@ -2,6 +2,7 @@ package me.chanjar.weixin.mp.api; import com.google.inject.Inject; import me.chanjar.weixin.common.exception.WxErrorException; +import me.chanjar.weixin.mp.api.test.ApiTestModule; import org.testng.Assert; import org.testng.annotations.Guice; import org.testng.annotations.Test; diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpCardServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpCardServiceImplTest.java index 97619223..1f28f4bb 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpCardServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpCardServiceImplTest.java @@ -2,7 +2,7 @@ package me.chanjar.weixin.mp.api.impl; import com.google.inject.Inject; import me.chanjar.weixin.common.bean.WxCardApiSignature; -import me.chanjar.weixin.mp.api.ApiTestModule; +import me.chanjar.weixin.mp.api.test.ApiTestModule; import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.bean.result.WxMpCardResult; import org.testng.annotations.Guice; diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpDataCubeServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpDataCubeServiceImplTest.java index 3e2257a3..22d0cc3e 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpDataCubeServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpDataCubeServiceImplTest.java @@ -14,7 +14,7 @@ import org.testng.annotations.Test; import com.google.inject.Inject; import me.chanjar.weixin.common.exception.WxErrorException; -import me.chanjar.weixin.mp.api.ApiTestModule; +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; diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpDeviceServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpDeviceServiceImplTest.java index e79dd250..0f621e3e 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpDeviceServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpDeviceServiceImplTest.java @@ -3,7 +3,7 @@ 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.ApiTestModule; +import me.chanjar.weixin.mp.api.test.ApiTestModule; import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.bean.device.WxDeviceQrCodeResult; import org.testng.annotations.DataProvider; diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImplTest.java index 3150dec3..105f078d 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImplTest.java @@ -3,9 +3,9 @@ package me.chanjar.weixin.mp.api.impl; import com.google.inject.Inject; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.exception.WxErrorException; -import me.chanjar.weixin.mp.api.ApiTestModule; +import me.chanjar.weixin.mp.api.test.ApiTestModule; import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage; +import me.chanjar.weixin.mp.api.test.TestConfigStorage; import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage; import me.chanjar.weixin.mp.bean.kefu.request.WxMpKfAccountRequest; import me.chanjar.weixin.mp.bean.kefu.result.*; @@ -31,7 +31,7 @@ public class WxMpKefuServiceImplTest { protected WxMpService wxService; public void testSendKefuMpNewsMessage() throws WxErrorException { - WxXmlMpInMemoryConfigStorage configStorage = (WxXmlMpInMemoryConfigStorage) this.wxService + TestConfigStorage configStorage = (TestConfigStorage) this.wxService .getWxMpConfigStorage(); WxMpKefuMessage message = new WxMpKefuMessage(); message.setMsgType(WxConsts.CUSTOM_MSG_MPNEWS); @@ -42,7 +42,7 @@ public class WxMpKefuServiceImplTest { } public void testSendKefuMessage() throws WxErrorException { - WxXmlMpInMemoryConfigStorage configStorage = (WxXmlMpInMemoryConfigStorage) this.wxService + TestConfigStorage configStorage = (TestConfigStorage) this.wxService .getWxMpConfigStorage(); WxMpKefuMessage message = new WxMpKefuMessage(); message.setMsgType(WxConsts.CUSTOM_MSG_TEXT); @@ -54,7 +54,7 @@ public class WxMpKefuServiceImplTest { } public void testSendKefuMessageWithKfAccount() throws WxErrorException { - WxXmlMpInMemoryConfigStorage configStorage = (WxXmlMpInMemoryConfigStorage) this.wxService + TestConfigStorage configStorage = (TestConfigStorage) this.wxService .getWxMpConfigStorage(); WxMpKefuMessage message = new WxMpKefuMessage(); message.setMsgType(WxConsts.CUSTOM_MSG_TEXT); @@ -85,7 +85,7 @@ public class WxMpKefuServiceImplTest { @DataProvider public Object[][] getKfAccount() { - WxXmlMpInMemoryConfigStorage configStorage = (WxXmlMpInMemoryConfigStorage) this.wxService + TestConfigStorage configStorage = (TestConfigStorage) this.wxService .getWxMpConfigStorage(); return new Object[][] { { configStorage.getKfAccount() } }; } @@ -131,7 +131,7 @@ public class WxMpKefuServiceImplTest { @DataProvider public Object[][] getKfAccountAndOpenid() { - WxXmlMpInMemoryConfigStorage configStorage = (WxXmlMpInMemoryConfigStorage) this.wxService + TestConfigStorage configStorage = (TestConfigStorage) this.wxService .getWxMpConfigStorage(); return new Object[][] { { configStorage.getKfAccount(), configStorage.getOpenid() } }; diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImplTest.java index 043a49ec..a3d8f47f 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImplTest.java @@ -5,7 +5,7 @@ import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.util.fs.FileUtils; -import me.chanjar.weixin.mp.api.ApiTestModule; +import me.chanjar.weixin.mp.api.test.ApiTestModule; import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.bean.material.WxMpMaterial; import me.chanjar.weixin.mp.bean.material.WxMpMaterialArticleUpdate; diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMenuServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMenuServiceImplTest.java index 08980a2b..45703b7b 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMenuServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMenuServiceImplTest.java @@ -5,7 +5,7 @@ import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.bean.menu.WxMenu; import me.chanjar.weixin.common.bean.menu.WxMenuButton; import me.chanjar.weixin.common.exception.WxErrorException; -import me.chanjar.weixin.mp.api.ApiTestModule; +import me.chanjar.weixin.mp.api.test.ApiTestModule; import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.bean.menu.WxMpGetSelfMenuInfoResult; import me.chanjar.weixin.mp.bean.menu.WxMpMenu; diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java index f46765c7..e890deda 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java @@ -3,9 +3,9 @@ package me.chanjar.weixin.mp.api.impl; import com.github.binarywang.utils.qrcode.QrcodeUtils; import com.google.inject.Inject; import me.chanjar.weixin.common.exception.WxErrorException; -import me.chanjar.weixin.mp.api.ApiTestModule; +import me.chanjar.weixin.mp.api.test.ApiTestModule; import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage; +import me.chanjar.weixin.mp.api.test.TestConfigStorage; import me.chanjar.weixin.mp.bean.pay.request.*; import me.chanjar.weixin.mp.bean.pay.result.*; import org.testng.annotations.*; @@ -59,7 +59,7 @@ public class WxMpPayServiceImplTest { */ @Test public void setSSLKey(){ - WxXmlMpInMemoryConfigStorage config = (WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage(); + TestConfigStorage config = (TestConfigStorage) this.wxService.getWxMpConfigStorage(); config.setSslContextFilePath(config.getKeyPath()); } @@ -107,7 +107,7 @@ public class WxMpPayServiceImplTest { request.setClientIp("aaa"); request.setMchBillNo("aaaa"); request - .setReOpenid(((WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage()).getOpenid()); + .setReOpenid(((TestConfigStorage) this.wxService.getWxMpConfigStorage()).getOpenid()); WxPaySendRedpackResult redpackResult = this.wxService.getPayService().sendRedpack(request); System.err.println(redpackResult); } diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImplTest.java index d1475dfe..b7957e7f 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImplTest.java @@ -2,7 +2,7 @@ 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.ApiTestModule; +import me.chanjar.weixin.mp.api.test.ApiTestModule; import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket; import org.testng.Assert; diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImplTest.java index c6b8689f..ffb55636 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImplTest.java @@ -2,9 +2,9 @@ package me.chanjar.weixin.mp.api.impl; import com.google.inject.Inject; import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.mp.api.ApiTestModule; +import me.chanjar.weixin.mp.api.test.ApiTestModule; import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage; +import me.chanjar.weixin.mp.api.test.TestConfigStorage; import org.testng.Assert; import org.testng.annotations.Guice; import org.testng.annotations.Test; @@ -103,7 +103,7 @@ public class WxMpServiceImplTest { @Test public void testBuildQrConnectUrl() { - String qrconnectRedirectUrl = ((WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage()).getQrconnectRedirectUrl(); + String qrconnectRedirectUrl = ((TestConfigStorage) this.wxService.getWxMpConfigStorage()).getQrconnectRedirectUrl(); String qrConnectUrl = this.wxService.buildQrConnectUrl(qrconnectRedirectUrl, WxConsts.QRCONNECT_SCOPE_SNSAPI_LOGIN, null); Assert.assertNotNull(qrConnectUrl); diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpStoreServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpStoreServiceImplTest.java index 63609293..0a6b5610 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpStoreServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpStoreServiceImplTest.java @@ -2,7 +2,7 @@ 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.ApiTestModule; +import me.chanjar.weixin.mp.api.test.ApiTestModule; import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.bean.store.WxMpStoreBaseInfo; import me.chanjar.weixin.mp.bean.store.WxMpStoreInfo; diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpTemplateMsgServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpTemplateMsgServiceImplTest.java index b37278e2..28932362 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpTemplateMsgServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpTemplateMsgServiceImplTest.java @@ -2,9 +2,9 @@ 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.ApiTestModule; +import me.chanjar.weixin.mp.api.test.ApiTestModule; import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage; +import me.chanjar.weixin.mp.api.test.TestConfigStorage; import me.chanjar.weixin.mp.bean.template.WxMpTemplate; import me.chanjar.weixin.mp.bean.template.WxMpTemplateData; import me.chanjar.weixin.mp.bean.template.WxMpTemplateIndustry; @@ -33,7 +33,7 @@ public class WxMpTemplateMsgServiceImplTest { public void testSendTemplateMsg() throws WxErrorException { SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss.SSS"); - WxXmlMpInMemoryConfigStorage configStorage = (WxXmlMpInMemoryConfigStorage) this.wxService + TestConfigStorage configStorage = (TestConfigStorage) this.wxService .getWxMpConfigStorage(); WxMpTemplateMessage templateMessage = WxMpTemplateMessage.builder() .toUser(configStorage.getOpenid()) diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserBlacklistServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserBlacklistServiceImplTest.java index 2bcc3aea..14796f9c 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserBlacklistServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserBlacklistServiceImplTest.java @@ -1,8 +1,8 @@ package me.chanjar.weixin.mp.api.impl; -import me.chanjar.weixin.mp.api.ApiTestModule; +import me.chanjar.weixin.mp.api.test.ApiTestModule; import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage; +import me.chanjar.weixin.mp.api.test.TestConfigStorage; import me.chanjar.weixin.mp.bean.result.WxMpUserBlacklistGetResult; import org.testng.Assert; import org.testng.annotations.Guice; @@ -23,7 +23,7 @@ public class WxMpUserBlacklistServiceImplTest { @Test public void testGetBlacklist() throws Exception { - WxXmlMpInMemoryConfigStorage configStorage = (WxXmlMpInMemoryConfigStorage) this.wxService + TestConfigStorage configStorage = (TestConfigStorage) this.wxService .getWxMpConfigStorage(); WxMpUserBlacklistGetResult wxMpUserBlacklistGetResult = this.wxService.getBlackListService().getBlacklist(configStorage.getOpenid()); Assert.assertNotNull(wxMpUserBlacklistGetResult); @@ -35,7 +35,7 @@ public class WxMpUserBlacklistServiceImplTest { @Test public void testPushToBlacklist() throws Exception { - WxXmlMpInMemoryConfigStorage configStorage = (WxXmlMpInMemoryConfigStorage) this.wxService + TestConfigStorage configStorage = (TestConfigStorage) this.wxService .getWxMpConfigStorage(); List openidList = new ArrayList<>(); openidList.add(configStorage.getOpenid()); @@ -44,7 +44,7 @@ public class WxMpUserBlacklistServiceImplTest { @Test public void testPullFromBlacklist() throws Exception { - WxXmlMpInMemoryConfigStorage configStorage = (WxXmlMpInMemoryConfigStorage) this.wxService + TestConfigStorage configStorage = (TestConfigStorage) this.wxService .getWxMpConfigStorage(); List openidList = new ArrayList<>(); openidList.add(configStorage.getOpenid()); diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImplTest.java index 02252800..3163ed69 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImplTest.java @@ -13,8 +13,8 @@ import org.testng.annotations.Test; import com.google.inject.Inject; import me.chanjar.weixin.common.exception.WxErrorException; -import me.chanjar.weixin.mp.api.ApiTestModule; -import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage; +import me.chanjar.weixin.mp.api.test.ApiTestModule; +import me.chanjar.weixin.mp.api.test.TestConfigStorage; import me.chanjar.weixin.mp.bean.WxMpUserQuery; import me.chanjar.weixin.mp.bean.result.WxMpUser; import me.chanjar.weixin.mp.bean.result.WxMpUserList; @@ -32,11 +32,11 @@ public class WxMpUserServiceImplTest { @Inject private WxMpService wxService; - private WxXmlMpInMemoryConfigStorage configProvider; + private TestConfigStorage configProvider; @BeforeTest public void setup() { - this.configProvider = (WxXmlMpInMemoryConfigStorage) this.wxService + this.configProvider = (TestConfigStorage) this.wxService .getWxMpConfigStorage(); } diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImplTest.java index bca04a06..54743ac4 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImplTest.java @@ -9,8 +9,8 @@ import org.testng.annotations.Test; import com.google.inject.Inject; -import me.chanjar.weixin.mp.api.ApiTestModule; -import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage; +import me.chanjar.weixin.mp.api.test.ApiTestModule; +import me.chanjar.weixin.mp.api.test.TestConfigStorage; import me.chanjar.weixin.mp.bean.tag.WxTagListUser; import me.chanjar.weixin.mp.bean.tag.WxUserTag; @@ -67,7 +67,7 @@ public class WxMpUserTagServiceImplTest { @Test public void testBatchTagging() throws Exception { - String[] openids = new String[]{((WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage()).getOpenid()}; + String[] openids = new String[]{((TestConfigStorage) this.wxService.getWxMpConfigStorage()).getOpenid()}; boolean res = this.wxService.getUserTagService().batchTagging(this.tagId, openids); System.out.println(res); Assert.assertTrue(res); @@ -75,7 +75,7 @@ public class WxMpUserTagServiceImplTest { @Test public void testBatchUntagging() throws Exception { - String[] openids = new String[]{((WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage()).getOpenid()}; + String[] openids = new String[]{((TestConfigStorage) this.wxService.getWxMpConfigStorage()).getOpenid()}; boolean res = this.wxService.getUserTagService().batchUntagging(this.tagId, openids); System.out.println(res); Assert.assertTrue(res); @@ -84,7 +84,7 @@ public class WxMpUserTagServiceImplTest { @Test public void testUserTagList() throws Exception { List res = this.wxService.getUserTagService().userTagList( - ((WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage()).getOpenid()); + ((TestConfigStorage) this.wxService.getWxMpConfigStorage()).getOpenid()); System.out.println(res); Assert.assertNotNull(res); } diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/ApiTestModule.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/test/ApiTestModule.java similarity index 77% rename from weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/ApiTestModule.java rename to weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/test/ApiTestModule.java index c506df0f..c957bde8 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/ApiTestModule.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/test/ApiTestModule.java @@ -1,9 +1,11 @@ -package me.chanjar.weixin.mp.api; +package me.chanjar.weixin.mp.api.test; import com.google.inject.Binder; import com.google.inject.Module; import com.thoughtworks.xstream.XStream; import me.chanjar.weixin.common.util.xml.XStreamInitializer; +import me.chanjar.weixin.mp.api.WxMpConfigStorage; +import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; import java.io.IOException; @@ -14,10 +16,9 @@ public class ApiTestModule implements Module { @Override public void configure(Binder binder) { - try (InputStream is1 = ClassLoader - .getSystemResourceAsStream("test-config.xml")) { - WxXmlMpInMemoryConfigStorage config = this - .fromXml(WxXmlMpInMemoryConfigStorage.class, is1); + try (InputStream is1 = ClassLoader.getSystemResourceAsStream("test-config.xml")) { + TestConfigStorage config = this + .fromXml(TestConfigStorage.class, is1); config.setAccessTokenLock(new ReentrantLock()); WxMpService wxService = new WxMpServiceImpl(); wxService.setWxMpConfigStorage(config); diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxXmlMpInMemoryConfigStorage.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/test/TestConfigStorage.java similarity index 87% rename from weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxXmlMpInMemoryConfigStorage.java rename to weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/test/TestConfigStorage.java index e51ffeb6..0dc91151 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxXmlMpInMemoryConfigStorage.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/test/TestConfigStorage.java @@ -1,18 +1,19 @@ -package me.chanjar.weixin.mp.api; +package me.chanjar.weixin.mp.api.test; import com.thoughtworks.xstream.annotations.XStreamAlias; +import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage; import org.apache.commons.lang3.builder.ToStringBuilder; import java.util.concurrent.locks.Lock; @XStreamAlias("xml") -public class WxXmlMpInMemoryConfigStorage - extends WxMpInMemoryConfigStorage { +public class TestConfigStorage extends WxMpInMemoryConfigStorage { private String openid; private String kfAccount; private String qrconnectRedirectUrl; private String templateId; + private String keyPath; public String getKeyPath() { return keyPath; @@ -22,8 +23,6 @@ public class WxXmlMpInMemoryConfigStorage this.keyPath = keyPath; } - private String keyPath; - public String getOpenid() { return this.openid; } @@ -61,7 +60,7 @@ public class WxXmlMpInMemoryConfigStorage this.templateId = templateId; } - public void setAccessTokenLock(Lock lock){ + public void setAccessTokenLock(Lock lock) { super.accessTokenLock = lock; }