@@ -45,7 +45,7 @@ public interface WxService { | |||||
* </pre> | * </pre> | ||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
public void refreshAccessToken() throws WxErrorException; | |||||
public void accessTokenRefresh() throws WxErrorException; | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
@@ -64,15 +64,15 @@ public interface WxService { | |||||
* @param inputStream 输入流 | * @param inputStream 输入流 | ||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
public WxMediaUploadResult uploadMedia(String mediaType, String fileType, InputStream inputStream) throws WxErrorException, IOException; | |||||
public WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream inputStream) throws WxErrorException, IOException; | |||||
/** | /** | ||||
* @see #uploadMedia(String, String, InputStream) | |||||
* @see #mediaUpload(String, String, InputStream) | |||||
* @param mediaType | * @param mediaType | ||||
* @param file | * @param file | ||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
public WxMediaUploadResult uploadMedia(String mediaType, File file) throws WxErrorException; | |||||
public WxMediaUploadResult mediaUpload(String mediaType, File file) throws WxErrorException; | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
@@ -84,7 +84,7 @@ public interface WxService { | |||||
* @return 保存到本地的临时文件 | * @return 保存到本地的临时文件 | ||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
public File downloadMedia(String media_id) throws WxErrorException; | |||||
public File mediaDownload(String media_id) throws WxErrorException; | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
@@ -94,54 +94,58 @@ public interface WxService { | |||||
* @param message | * @param message | ||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
public void sendCustomMessage(WxCustomMessage message) throws WxErrorException; | |||||
public void customMessageSend(WxCustomMessage message) throws WxErrorException; | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 上传群发用的图文消息,上传后才能群发图文消息 {@link #sendMassMessage(WxMassMessage)} | |||||
* 上传群发用的图文消息,上传后才能群发图文消息 | |||||
* | * | ||||
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=高级群发接口 | * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=高级群发接口 | ||||
* </pre> | * </pre> | ||||
* @param news | * @param news | ||||
* @throws WxErrorException | * @throws WxErrorException | ||||
* @see #massGroupMessageSend(WxMassGroupMessage) | |||||
* @see #massOpenIdsMessageSend(WxMassOpenIdsMessage) | |||||
*/ | */ | ||||
public WxMassUploadResult uploadMassNews(WxMassNews news) throws WxErrorException; | |||||
public WxMassUploadResult massNewsUpload(WxMassNews news) throws WxErrorException; | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 上传群发用的视频,上传后才能群发视频消息 {@link #sendMassMessage(WxMassMessage)} | |||||
* 上传群发用的视频,上传后才能群发视频消息 | |||||
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=高级群发接口 | * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=高级群发接口 | ||||
* </pre> | * </pre> | ||||
* @return | * @return | ||||
* @throws WxErrorException | * @throws WxErrorException | ||||
* @see #massGroupMessageSend(WxMassGroupMessage) | |||||
* @see #massOpenIdsMessageSend(WxMassOpenIdsMessage) | |||||
*/ | */ | ||||
public WxMassUploadResult uploadMassVideo(WxMassVideo video) throws WxErrorException; | |||||
public WxMassUploadResult massVideoUpload(WxMassVideo video) throws WxErrorException; | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 分组群发消息 | * 分组群发消息 | ||||
* 如果发送图文消息,必须先使用 {@link #uploadMassNews(WxMassNews)} 获得media_id,然后再发送 | |||||
* 如果发送视频消息,必须先使用 {@link #uploadMassVideo(WxMassVideo)} 获得media_id,然后再发送 | |||||
* 如果发送图文消息,必须先使用 {@link #massNewsUpload(WxMassNews)} 获得media_id,然后再发送 | |||||
* 如果发送视频消息,必须先使用 {@link #massVideoUpload(WxMassVideo)} 获得media_id,然后再发送 | |||||
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=高级群发接口 | * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=高级群发接口 | ||||
* </pre> | * </pre> | ||||
* @param message | * @param message | ||||
* @throws WxErrorException | * @throws WxErrorException | ||||
* @return | * @return | ||||
*/ | */ | ||||
public WxMassSendResult sendMassMessageByGroup(WxMassGroupMessage message) throws WxErrorException; | |||||
public WxMassSendResult massGroupMessageSend(WxMassGroupMessage message) throws WxErrorException; | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 按openId列表群发消息 | * 按openId列表群发消息 | ||||
* 如果发送图文消息,必须先使用 {@link #uploadMassNews(WxMassNews)} 获得media_id,然后再发送 | |||||
* 如果发送视频消息,必须先使用 {@link #uploadMassVideo(WxMassVideo)} 获得media_id,然后再发送 | |||||
* 如果发送图文消息,必须先使用 {@link #massNewsUpload(WxMassNews)} 获得media_id,然后再发送 | |||||
* 如果发送视频消息,必须先使用 {@link #massVideoUpload(WxMassVideo)} 获得media_id,然后再发送 | |||||
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=高级群发接口 | * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=高级群发接口 | ||||
* </pre> | * </pre> | ||||
* @param message | * @param message | ||||
* @return | * @return | ||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
public WxMassSendResult sendMassMessageByOpenIds(WxMassOpenIdsMessage message) throws WxErrorException; | |||||
public WxMassSendResult massOpenIdsMessageSend(WxMassOpenIdsMessage message) throws WxErrorException; | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
@@ -151,7 +155,7 @@ public interface WxService { | |||||
* @param menu | * @param menu | ||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
public void createMenu(WxMenu menu) throws WxErrorException; | |||||
public void menuCreate(WxMenu menu) throws WxErrorException; | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
@@ -160,7 +164,7 @@ public interface WxService { | |||||
* </pre> | * </pre> | ||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
public void deleteMenu() throws WxErrorException; | |||||
public void menuDelete() throws WxErrorException; | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
@@ -170,7 +174,7 @@ public interface WxService { | |||||
* @return | * @return | ||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
public WxMenu getMenu() throws WxErrorException; | |||||
public WxMenu menuGet() throws WxErrorException; | |||||
public void setWxConfigStorage(WxConfigStorage wxConfigProvider); | public void setWxConfigStorage(WxConfigStorage wxConfigProvider); | ||||
} | } |
@@ -79,7 +79,7 @@ public class WxServiceImpl implements WxService { | |||||
return buf.toString(); | return buf.toString(); | ||||
} | } | ||||
public void refreshAccessToken() throws WxErrorException { | |||||
public void accessTokenRefresh() throws WxErrorException { | |||||
if (!GLOBAL_ACCESS_TOKEN_REFRESH_FLAG.getAndSet(true)) { | if (!GLOBAL_ACCESS_TOKEN_REFRESH_FLAG.getAndSet(true)) { | ||||
try { | try { | ||||
String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential" | String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential" | ||||
@@ -116,22 +116,22 @@ public class WxServiceImpl implements WxService { | |||||
} | } | ||||
} | } | ||||
public void sendCustomMessage(WxCustomMessage message) throws WxErrorException { | |||||
public void customMessageSend(WxCustomMessage message) throws WxErrorException { | |||||
String url = "https://api.weixin.qq.com/cgi-bin/message/custom/send"; | String url = "https://api.weixin.qq.com/cgi-bin/message/custom/send"; | ||||
execute(new SimplePostRequestExecutor(), url, message.toJson()); | execute(new SimplePostRequestExecutor(), url, message.toJson()); | ||||
} | } | ||||
public void createMenu(WxMenu menu) throws WxErrorException { | |||||
public void menuCreate(WxMenu menu) throws WxErrorException { | |||||
String url = "https://api.weixin.qq.com/cgi-bin/menu/create"; | String url = "https://api.weixin.qq.com/cgi-bin/menu/create"; | ||||
execute(new SimplePostRequestExecutor(), url, menu.toJson()); | execute(new SimplePostRequestExecutor(), url, menu.toJson()); | ||||
} | } | ||||
public void deleteMenu() throws WxErrorException { | |||||
public void menuDelete() throws WxErrorException { | |||||
String url = "https://api.weixin.qq.com/cgi-bin/menu/delete"; | String url = "https://api.weixin.qq.com/cgi-bin/menu/delete"; | ||||
execute(new SimpleGetRequestExecutor(), url, null); | execute(new SimpleGetRequestExecutor(), url, null); | ||||
} | } | ||||
public WxMenu getMenu() throws WxErrorException { | |||||
public WxMenu menuGet() throws WxErrorException { | |||||
String url = "https://api.weixin.qq.com/cgi-bin/menu/get"; | String url = "https://api.weixin.qq.com/cgi-bin/menu/get"; | ||||
try { | try { | ||||
String resultContent = execute(new SimpleGetRequestExecutor(), url, null); | String resultContent = execute(new SimpleGetRequestExecutor(), url, null); | ||||
@@ -145,39 +145,39 @@ public class WxServiceImpl implements WxService { | |||||
} | } | ||||
} | } | ||||
public WxMediaUploadResult uploadMedia(String mediaType, String fileType, InputStream inputStream) throws WxErrorException, IOException { | |||||
return uploadMedia(mediaType,FileUtil.createTmpFile(inputStream, UUID.randomUUID().toString(), fileType)); | |||||
public WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream inputStream) throws WxErrorException, IOException { | |||||
return mediaUpload(mediaType,FileUtil.createTmpFile(inputStream, UUID.randomUUID().toString(), fileType)); | |||||
} | } | ||||
public WxMediaUploadResult uploadMedia(String mediaType, File file) throws WxErrorException { | |||||
public WxMediaUploadResult mediaUpload(String mediaType, File file) throws WxErrorException { | |||||
String url = "http://file.api.weixin.qq.com/cgi-bin/media/upload?type=" + mediaType; | String url = "http://file.api.weixin.qq.com/cgi-bin/media/upload?type=" + mediaType; | ||||
return execute(new MediaUploadRequestExecutor(), url, file); | return execute(new MediaUploadRequestExecutor(), url, file); | ||||
} | } | ||||
public File downloadMedia(String media_id) throws WxErrorException { | |||||
public File mediaDownload(String media_id) throws WxErrorException { | |||||
String url = "http://file.api.weixin.qq.com/cgi-bin/media/get"; | String url = "http://file.api.weixin.qq.com/cgi-bin/media/get"; | ||||
return execute(new MediaDownloadRequestExecutor(), url, "media_id=" + media_id); | return execute(new MediaDownloadRequestExecutor(), url, "media_id=" + media_id); | ||||
} | } | ||||
public WxMassUploadResult uploadMassNews(WxMassNews news) throws WxErrorException { | |||||
public WxMassUploadResult massNewsUpload(WxMassNews news) throws WxErrorException { | |||||
String url = "https://api.weixin.qq.com/cgi-bin/media/uploadnews"; | String url = "https://api.weixin.qq.com/cgi-bin/media/uploadnews"; | ||||
String responseContent = execute(new SimplePostRequestExecutor(), url, news.toJson()); | String responseContent = execute(new SimplePostRequestExecutor(), url, news.toJson()); | ||||
return WxMassUploadResult.fromJson(responseContent); | return WxMassUploadResult.fromJson(responseContent); | ||||
} | } | ||||
public WxMassUploadResult uploadMassVideo(WxMassVideo video) throws WxErrorException { | |||||
public WxMassUploadResult massVideoUpload(WxMassVideo video) throws WxErrorException { | |||||
String url = "http://file.api.weixin.qq.com/cgi-bin/media/uploadvideo"; | String url = "http://file.api.weixin.qq.com/cgi-bin/media/uploadvideo"; | ||||
String responseContent = execute(new SimplePostRequestExecutor(), url, video.toJson()); | String responseContent = execute(new SimplePostRequestExecutor(), url, video.toJson()); | ||||
return WxMassUploadResult.fromJson(responseContent); | return WxMassUploadResult.fromJson(responseContent); | ||||
} | } | ||||
public WxMassSendResult sendMassMessageByGroup(WxMassGroupMessage message) throws WxErrorException { | |||||
public WxMassSendResult massGroupMessageSend(WxMassGroupMessage message) throws WxErrorException { | |||||
String url = "https://api.weixin.qq.com/cgi-bin/message/mass/sendall"; | String url = "https://api.weixin.qq.com/cgi-bin/message/mass/sendall"; | ||||
String responseContent = execute(new SimplePostRequestExecutor(), url, message.toJson()); | String responseContent = execute(new SimplePostRequestExecutor(), url, message.toJson()); | ||||
return WxMassSendResult.fromJson(responseContent); | return WxMassSendResult.fromJson(responseContent); | ||||
} | } | ||||
public WxMassSendResult sendMassMessageByOpenIds(WxMassOpenIdsMessage message) throws WxErrorException { | |||||
public WxMassSendResult massOpenIdsMessageSend(WxMassOpenIdsMessage message) throws WxErrorException { | |||||
String url = "https://api.weixin.qq.com/cgi-bin/message/mass/send"; | String url = "https://api.weixin.qq.com/cgi-bin/message/mass/send"; | ||||
String responseContent = execute(new SimplePostRequestExecutor(), url, message.toJson()); | String responseContent = execute(new SimplePostRequestExecutor(), url, message.toJson()); | ||||
return WxMassSendResult.fromJson(responseContent); | return WxMassSendResult.fromJson(responseContent); | ||||
@@ -193,7 +193,7 @@ public class WxServiceImpl implements WxService { | |||||
*/ | */ | ||||
public <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException { | public <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException { | ||||
if (StringUtils.isBlank(wxConfigStorage.getAccessToken())) { | if (StringUtils.isBlank(wxConfigStorage.getAccessToken())) { | ||||
refreshAccessToken(); | |||||
accessTokenRefresh(); | |||||
} | } | ||||
String accessToken = wxConfigStorage.getAccessToken(); | String accessToken = wxConfigStorage.getAccessToken(); | ||||
@@ -210,7 +210,7 @@ public class WxServiceImpl implements WxService { | |||||
* 42001 access_token超时 | * 42001 access_token超时 | ||||
*/ | */ | ||||
if (error.getErrcode() == 42001 || error.getErrcode() == 40001) { | if (error.getErrcode() == 42001 || error.getErrcode() == 40001) { | ||||
refreshAccessToken(); | |||||
accessTokenRefresh(); | |||||
return execute(executor, uri, data); | return execute(executor, uri, data); | ||||
} | } | ||||
/** | /** | ||||
@@ -24,7 +24,7 @@ public class WxBaseAPITest { | |||||
public void testRefreshAccessToken() throws WxErrorException { | public void testRefreshAccessToken() throws WxErrorException { | ||||
WxConfigStorage configStorage = wxService.wxConfigStorage; | WxConfigStorage configStorage = wxService.wxConfigStorage; | ||||
String before = configStorage.getAccessToken(); | String before = configStorage.getAccessToken(); | ||||
wxService.refreshAccessToken(); | |||||
wxService.accessTokenRefresh(); | |||||
String after = configStorage.getAccessToken(); | String after = configStorage.getAccessToken(); | ||||
@@ -28,7 +28,7 @@ public class WxCustomMessageAPITest { | |||||
message.setTouser(configProvider.getOpenId()); | message.setTouser(configProvider.getOpenId()); | ||||
message.setContent("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>"); | message.setContent("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>"); | ||||
wxService.sendCustomMessage(message); | |||||
wxService.customMessageSend(message); | |||||
} | } | ||||
} | } |
@@ -41,7 +41,7 @@ public class WxMassMessageAPITest { | |||||
massMessage.setContent("测试群发消息\n欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>"); | massMessage.setContent("测试群发消息\n欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>"); | ||||
massMessage.getTouser().add(configProvider.getOpenId()); | massMessage.getTouser().add(configProvider.getOpenId()); | ||||
WxMassSendResult massResult = wxService.sendMassMessageByOpenIds(massMessage); | |||||
WxMassSendResult massResult = wxService.massOpenIdsMessageSend(massMessage); | |||||
Assert.assertNotNull(massResult); | Assert.assertNotNull(massResult); | ||||
Assert.assertNotNull(massResult.getMsg_id()); | Assert.assertNotNull(massResult.getMsg_id()); | ||||
} | } | ||||
@@ -55,7 +55,7 @@ public class WxMassMessageAPITest { | |||||
massMessage.setMedia_id(mediaId); | massMessage.setMedia_id(mediaId); | ||||
massMessage.getTouser().add(configProvider.getOpenId()); | massMessage.getTouser().add(configProvider.getOpenId()); | ||||
WxMassSendResult massResult = wxService.sendMassMessageByOpenIds(massMessage); | |||||
WxMassSendResult massResult = wxService.massOpenIdsMessageSend(massMessage); | |||||
Assert.assertNotNull(massResult); | Assert.assertNotNull(massResult); | ||||
Assert.assertNotNull(massResult.getMsg_id()); | Assert.assertNotNull(massResult.getMsg_id()); | ||||
} | } | ||||
@@ -69,7 +69,7 @@ public class WxMassMessageAPITest { | |||||
{ | { | ||||
// 上传视频到媒体库 | // 上传视频到媒体库 | ||||
InputStream inputStream = ClassLoader.getSystemResourceAsStream("mm.mp4"); | InputStream inputStream = ClassLoader.getSystemResourceAsStream("mm.mp4"); | ||||
WxMediaUploadResult uploadMediaRes = wxService.uploadMedia(WxConsts.MEDIA_VIDEO, WxConsts.FILE_MP4, inputStream); | |||||
WxMediaUploadResult uploadMediaRes = wxService.mediaUpload(WxConsts.MEDIA_VIDEO, WxConsts.FILE_MP4, inputStream); | |||||
Assert.assertNotNull(uploadMediaRes); | Assert.assertNotNull(uploadMediaRes); | ||||
Assert.assertNotNull(uploadMediaRes.getMedia_id()); | Assert.assertNotNull(uploadMediaRes.getMedia_id()); | ||||
@@ -78,7 +78,7 @@ public class WxMassMessageAPITest { | |||||
video.setTitle("测试标题"); | video.setTitle("测试标题"); | ||||
video.setDescription("测试描述"); | video.setDescription("测试描述"); | ||||
video.setMedia_id(uploadMediaRes.getMedia_id()); | video.setMedia_id(uploadMediaRes.getMedia_id()); | ||||
WxMassUploadResult uploadResult = wxService.uploadMassVideo(video); | |||||
WxMassUploadResult uploadResult = wxService.massVideoUpload(video); | |||||
Assert.assertNotNull(uploadResult); | Assert.assertNotNull(uploadResult); | ||||
Assert.assertNotNull(uploadResult.getMedia_id()); | Assert.assertNotNull(uploadResult.getMedia_id()); | ||||
messages[0] = new Object[] { WxConsts.MASS_MSG_VIDEO, uploadResult.getMedia_id() }; | messages[0] = new Object[] { WxConsts.MASS_MSG_VIDEO, uploadResult.getMedia_id() }; | ||||
@@ -88,7 +88,7 @@ public class WxMassMessageAPITest { | |||||
*/ | */ | ||||
{ | { | ||||
InputStream inputStream = ClassLoader.getSystemResourceAsStream("mm.jpeg"); | InputStream inputStream = ClassLoader.getSystemResourceAsStream("mm.jpeg"); | ||||
WxMediaUploadResult uploadMediaRes = wxService.uploadMedia(WxConsts.MEDIA_IMAGE, WxConsts.FILE_JPG, inputStream); | |||||
WxMediaUploadResult uploadMediaRes = wxService.mediaUpload(WxConsts.MEDIA_IMAGE, WxConsts.FILE_JPG, inputStream); | |||||
Assert.assertNotNull(uploadMediaRes); | Assert.assertNotNull(uploadMediaRes); | ||||
Assert.assertNotNull(uploadMediaRes.getMedia_id()); | Assert.assertNotNull(uploadMediaRes.getMedia_id()); | ||||
messages[1] = new Object[] { WxConsts.MASS_MSG_IMAGE, uploadMediaRes.getMedia_id() }; | messages[1] = new Object[] { WxConsts.MASS_MSG_IMAGE, uploadMediaRes.getMedia_id() }; | ||||
@@ -98,7 +98,7 @@ public class WxMassMessageAPITest { | |||||
*/ | */ | ||||
{ | { | ||||
InputStream inputStream = ClassLoader.getSystemResourceAsStream("mm.mp3"); | InputStream inputStream = ClassLoader.getSystemResourceAsStream("mm.mp3"); | ||||
WxMediaUploadResult uploadMediaRes = wxService.uploadMedia(WxConsts.MEDIA_VOICE, WxConsts.FILE_MP3, inputStream); | |||||
WxMediaUploadResult uploadMediaRes = wxService.mediaUpload(WxConsts.MEDIA_VOICE, WxConsts.FILE_MP3, inputStream); | |||||
Assert.assertNotNull(uploadMediaRes); | Assert.assertNotNull(uploadMediaRes); | ||||
Assert.assertNotNull(uploadMediaRes.getMedia_id()); | Assert.assertNotNull(uploadMediaRes.getMedia_id()); | ||||
messages[2] = new Object[] { WxConsts.MASS_MSG_VOICE, uploadMediaRes.getMedia_id() }; | messages[2] = new Object[] { WxConsts.MASS_MSG_VOICE, uploadMediaRes.getMedia_id() }; | ||||
@@ -109,7 +109,7 @@ public class WxMassMessageAPITest { | |||||
{ | { | ||||
// 上传照片到媒体库 | // 上传照片到媒体库 | ||||
InputStream inputStream = ClassLoader.getSystemResourceAsStream("mm.jpeg"); | InputStream inputStream = ClassLoader.getSystemResourceAsStream("mm.jpeg"); | ||||
WxMediaUploadResult uploadMediaRes = wxService.uploadMedia(WxConsts.MEDIA_IMAGE, WxConsts.FILE_JPG, inputStream); | |||||
WxMediaUploadResult uploadMediaRes = wxService.mediaUpload(WxConsts.MEDIA_IMAGE, WxConsts.FILE_JPG, inputStream); | |||||
Assert.assertNotNull(uploadMediaRes); | Assert.assertNotNull(uploadMediaRes); | ||||
Assert.assertNotNull(uploadMediaRes.getMedia_id()); | Assert.assertNotNull(uploadMediaRes.getMedia_id()); | ||||
@@ -131,7 +131,7 @@ public class WxMassMessageAPITest { | |||||
article2.setDigest("摘要2"); | article2.setDigest("摘要2"); | ||||
news.addArticle(article2); | news.addArticle(article2); | ||||
WxMassUploadResult massUploadResult = wxService.uploadMassNews(news); | |||||
WxMassUploadResult massUploadResult = wxService.massNewsUpload(news); | |||||
Assert.assertNotNull(massUploadResult); | Assert.assertNotNull(massUploadResult); | ||||
Assert.assertNotNull(uploadMediaRes.getMedia_id()); | Assert.assertNotNull(uploadMediaRes.getMedia_id()); | ||||
messages[3] = new Object[] { WxConsts.MASS_MSG_VIDEO, massUploadResult.getMedia_id() }; | messages[3] = new Object[] { WxConsts.MASS_MSG_VIDEO, massUploadResult.getMedia_id() }; | ||||
@@ -32,7 +32,7 @@ public class WxMediaAPITest { | |||||
@Test(dataProvider="uploadMedia", enabled = true) | @Test(dataProvider="uploadMedia", enabled = true) | ||||
public void testUploadMedia(String mediaType, String fileType, String fileName) throws WxErrorException, IOException { | public void testUploadMedia(String mediaType, String fileType, String fileName) throws WxErrorException, IOException { | ||||
InputStream inputStream = ClassLoader.getSystemResourceAsStream(fileName); | InputStream inputStream = ClassLoader.getSystemResourceAsStream(fileName); | ||||
WxMediaUploadResult res = wxService.uploadMedia(mediaType, fileType, inputStream); | |||||
WxMediaUploadResult res = wxService.mediaUpload(mediaType, fileType, inputStream); | |||||
Assert.assertNotNull(res.getType()); | Assert.assertNotNull(res.getType()); | ||||
Assert.assertNotNull(res.getCreated_at()); | Assert.assertNotNull(res.getCreated_at()); | ||||
Assert.assertTrue(res.getMedia_id() != null || res.getThumb_media_id() != null); | Assert.assertTrue(res.getMedia_id() != null || res.getThumb_media_id() != null); | ||||
@@ -57,7 +57,7 @@ public class WxMediaAPITest { | |||||
@Test(dependsOnMethods = { "testUploadMedia" }, dataProvider="downloadMedia") | @Test(dependsOnMethods = { "testUploadMedia" }, dataProvider="downloadMedia") | ||||
public void testDownloadMedia(String media_id) throws WxErrorException { | public void testDownloadMedia(String media_id) throws WxErrorException { | ||||
wxService.downloadMedia(media_id); | |||||
wxService.mediaDownload(media_id); | |||||
} | } | ||||
@DataProvider | @DataProvider | ||||
@@ -27,17 +27,17 @@ public class WxMenuAPITest { | |||||
@Test(dataProvider = "menu", enabled = true) | @Test(dataProvider = "menu", enabled = true) | ||||
public void testCreateMenu(WxMenu wxMenu) throws WxErrorException { | public void testCreateMenu(WxMenu wxMenu) throws WxErrorException { | ||||
wxService.createMenu(wxMenu); | |||||
wxService.menuCreate(wxMenu); | |||||
} | } | ||||
@Test(dependsOnMethods = { "testCreateMenu"}, enabled = true) | @Test(dependsOnMethods = { "testCreateMenu"}, enabled = true) | ||||
public void testGetMenu() throws WxErrorException { | public void testGetMenu() throws WxErrorException { | ||||
Assert.assertNotNull(wxService.getMenu()); | |||||
Assert.assertNotNull(wxService.menuGet()); | |||||
} | } | ||||
@Test(dependsOnMethods = { "testGetMenu"}, enabled = true) | @Test(dependsOnMethods = { "testGetMenu"}, enabled = true) | ||||
public void testDeleteMenu() throws WxErrorException { | public void testDeleteMenu() throws WxErrorException { | ||||
wxService.deleteMenu(); | |||||
wxService.menuDelete(); | |||||
} | } | ||||
@DataProvider(name="menu") | @DataProvider(name="menu") | ||||