mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-04-05 17:38:05 +08:00
将部分仅供测试代码使用的常量挪走
This commit is contained in:
parent
f3ac9983be
commit
7340e03636
1
pom.xml
1
pom.xml
@ -87,6 +87,7 @@
|
||||
<module>weixin-java-cp</module>
|
||||
<module>weixin-java-mp</module>
|
||||
<module>weixin-java-pay</module>
|
||||
<!--module>weixin-java-osgi</module-->
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
|
@ -136,13 +136,6 @@ public class WxConsts {
|
||||
public static final String MEDIA_VIDEO = "video";
|
||||
public static final String MEDIA_THUMB = "thumb";
|
||||
public static final String MEDIA_FILE = "file";
|
||||
///////////////////////
|
||||
// 文件类型
|
||||
///////////////////////
|
||||
public static final String FILE_JPG = "jpeg";
|
||||
public static final String FILE_MP3 = "mp3";
|
||||
public static final String FILE_AMR = "amr";
|
||||
public static final String FILE_MP4 = "mp4";
|
||||
/**
|
||||
* 点击推事件
|
||||
*/
|
||||
|
@ -0,0 +1,17 @@
|
||||
package me.chanjar.weixin.cp.api;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 仅供测试使用的一些常量
|
||||
* Created by Binary Wang on 2017-3-9.
|
||||
* </pre>
|
||||
*/
|
||||
public class TestConstants {
|
||||
///////////////////////
|
||||
// 文件类型
|
||||
///////////////////////
|
||||
public static final String FILE_JPG = "jpeg";
|
||||
public static final String FILE_MP3 = "mp3";
|
||||
public static final String FILE_AMR = "amr";
|
||||
public static final String FILE_MP4 = "mp4";
|
||||
}
|
@ -54,10 +54,10 @@ public class WxCpMediaAPITest {
|
||||
@DataProvider
|
||||
public Object[][] uploadMedia() {
|
||||
return new Object[][]{
|
||||
new Object[]{WxConsts.MEDIA_IMAGE, WxConsts.FILE_JPG, "mm.jpeg"},
|
||||
new Object[]{WxConsts.MEDIA_VOICE, WxConsts.FILE_MP3, "mm.mp3"},
|
||||
new Object[]{WxConsts.MEDIA_VIDEO, WxConsts.FILE_MP4, "mm.mp4"},
|
||||
new Object[]{WxConsts.MEDIA_FILE, WxConsts.FILE_JPG, "mm.jpeg"}
|
||||
new Object[]{WxConsts.MEDIA_IMAGE, TestConstants.FILE_JPG, "mm.jpeg"},
|
||||
new Object[]{WxConsts.MEDIA_VOICE, TestConstants.FILE_MP3, "mm.mp3"},
|
||||
new Object[]{WxConsts.MEDIA_VIDEO, TestConstants.FILE_MP4, "mm.mp4"},
|
||||
new Object[]{WxConsts.MEDIA_FILE, TestConstants.FILE_JPG, "mm.jpeg"}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ 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.api.test.TestConstants;
|
||||
import me.chanjar.weixin.mp.bean.WxMpMassNews;
|
||||
import me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage;
|
||||
import me.chanjar.weixin.mp.bean.WxMpMassTagMessage;
|
||||
@ -101,7 +102,7 @@ public class WxMpMassMessageAPITest {
|
||||
.getSystemResourceAsStream("mm.mp4")) {
|
||||
// 上传视频到媒体库
|
||||
WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService()
|
||||
.mediaUpload(WxConsts.MEDIA_VIDEO, WxConsts.FILE_MP4, inputStream);
|
||||
.mediaUpload(WxConsts.MEDIA_VIDEO, TestConstants.FILE_MP4, inputStream);
|
||||
Assert.assertNotNull(uploadMediaRes);
|
||||
Assert.assertNotNull(uploadMediaRes.getMediaId());
|
||||
|
||||
@ -122,7 +123,7 @@ public class WxMpMassMessageAPITest {
|
||||
try (InputStream inputStream = ClassLoader
|
||||
.getSystemResourceAsStream("mm.jpeg")) {
|
||||
WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService()
|
||||
.mediaUpload(WxConsts.MEDIA_IMAGE, WxConsts.FILE_JPG, inputStream);
|
||||
.mediaUpload(WxConsts.MEDIA_IMAGE, TestConstants.FILE_JPG, inputStream);
|
||||
Assert.assertNotNull(uploadMediaRes);
|
||||
Assert.assertNotNull(uploadMediaRes.getMediaId());
|
||||
messages[1] = new Object[]{WxConsts.MASS_MSG_IMAGE, uploadMediaRes.getMediaId()};
|
||||
@ -134,7 +135,7 @@ public class WxMpMassMessageAPITest {
|
||||
try (InputStream inputStream = ClassLoader
|
||||
.getSystemResourceAsStream("mm.mp3")) {
|
||||
WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService()
|
||||
.mediaUpload(WxConsts.MEDIA_VOICE, WxConsts.FILE_MP3, inputStream);
|
||||
.mediaUpload(WxConsts.MEDIA_VOICE, TestConstants.FILE_MP3, inputStream);
|
||||
Assert.assertNotNull(uploadMediaRes);
|
||||
Assert.assertNotNull(uploadMediaRes.getMediaId());
|
||||
messages[2] = new Object[]{WxConsts.MASS_MSG_VOICE, uploadMediaRes.getMediaId()};
|
||||
@ -147,7 +148,7 @@ public class WxMpMassMessageAPITest {
|
||||
.getSystemResourceAsStream("mm.jpeg")) {
|
||||
// 上传照片到媒体库
|
||||
WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService()
|
||||
.mediaUpload(WxConsts.MEDIA_IMAGE, WxConsts.FILE_JPG, inputStream);
|
||||
.mediaUpload(WxConsts.MEDIA_IMAGE, TestConstants.FILE_JPG, inputStream);
|
||||
Assert.assertNotNull(uploadMediaRes);
|
||||
Assert.assertNotNull(uploadMediaRes.getMediaId());
|
||||
|
||||
|
@ -7,6 +7,7 @@ import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.fs.FileUtils;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.api.test.ApiTestModule;
|
||||
import me.chanjar.weixin.mp.api.test.TestConstants;
|
||||
import me.chanjar.weixin.mp.bean.material.*;
|
||||
import org.testng.annotations.*;
|
||||
|
||||
@ -45,10 +46,10 @@ public class WxMpMaterialServiceImplTest {
|
||||
@DataProvider
|
||||
public Object[][] mediaFiles() {
|
||||
return new Object[][]{
|
||||
new Object[]{WxConsts.MEDIA_IMAGE, WxConsts.FILE_JPG, "mm.jpeg"},
|
||||
new Object[]{WxConsts.MEDIA_VOICE, WxConsts.FILE_MP3, "mm.mp3"},
|
||||
new Object[]{WxConsts.MEDIA_VIDEO, WxConsts.FILE_MP4, "mm.mp4"},
|
||||
new Object[]{WxConsts.MEDIA_THUMB, WxConsts.FILE_JPG, "mm.jpeg"}
|
||||
new Object[]{WxConsts.MEDIA_IMAGE, TestConstants.FILE_JPG, "mm.jpeg"},
|
||||
new Object[]{WxConsts.MEDIA_VOICE, TestConstants.FILE_MP3, "mm.mp3"},
|
||||
new Object[]{WxConsts.MEDIA_VIDEO, TestConstants.FILE_MP4, "mm.mp4"},
|
||||
new Object[]{WxConsts.MEDIA_THUMB, TestConstants.FILE_JPG, "mm.jpeg"}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
package me.chanjar.weixin.mp.api.test;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 仅供测试使用的一些常量
|
||||
* Created by Binary Wang on 2017-3-9.
|
||||
* </pre>
|
||||
*/
|
||||
public class TestConstants {
|
||||
///////////////////////
|
||||
// 文件类型
|
||||
///////////////////////
|
||||
public static final String FILE_JPG = "jpeg";
|
||||
public static final String FILE_MP3 = "mp3";
|
||||
public static final String FILE_AMR = "amr";
|
||||
public static final String FILE_MP4 = "mp4";
|
||||
}
|
@ -6,6 +6,7 @@ import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.common.session.WxSessionManager;
|
||||
import me.chanjar.weixin.mp.api.WxMpMessageHandler;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.api.test.TestConstants;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutImageMessage;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
|
||||
@ -18,7 +19,7 @@ public class DemoImageHandler implements WxMpMessageHandler {
|
||||
WxMpService wxMpService, WxSessionManager sessionManager) {
|
||||
try {
|
||||
WxMediaUploadResult wxMediaUploadResult = wxMpService.getMaterialService()
|
||||
.mediaUpload(WxConsts.MEDIA_IMAGE, WxConsts.FILE_JPG, ClassLoader.getSystemResourceAsStream("mm.jpeg"));
|
||||
.mediaUpload(WxConsts.MEDIA_IMAGE, TestConstants.FILE_JPG, ClassLoader.getSystemResourceAsStream("mm.jpeg"));
|
||||
WxMpXmlOutImageMessage m
|
||||
= WxMpXmlOutMessage
|
||||
.IMAGE()
|
||||
|
Loading…
Reference in New Issue
Block a user