use of org.testng.annotations.Test in project weixin-java-tools by chanjarster.
the class WxCpBusyRetryTest method testRetryInThreadPool.
@Test(dataProvider = "getService")
public void testRetryInThreadPool(final WxCpService service) throws InterruptedException, ExecutionException {
// 当线程池中的线程复用的时候,还是能保证相同的重试次数
ExecutorService executorService = Executors.newFixedThreadPool(1);
Runnable runnable = new Runnable() {
@Override
public void run() {
try {
System.out.println("=====================");
System.out.println(Thread.currentThread().getName() + ": testRetry");
service.execute(null, null, null);
} catch (WxErrorException e) {
throw new RuntimeException(e);
} catch (RuntimeException e) {
// OK
}
}
};
Future<?> submit1 = executorService.submit(runnable);
Future<?> submit2 = executorService.submit(runnable);
submit1.get();
submit2.get();
}
use of org.testng.annotations.Test in project weixin-java-tools by chanjarster.
the class WxCpMediaAPITest method testUploadMedia.
@Test(dataProvider = "uploadMedia")
public void testUploadMedia(String mediaType, String fileType, String fileName) throws WxErrorException, IOException {
InputStream inputStream = ClassLoader.getSystemResourceAsStream(fileName);
WxMediaUploadResult res = wxService.mediaUpload(mediaType, fileType, inputStream);
Assert.assertNotNull(res.getType());
Assert.assertNotNull(res.getCreatedAt());
Assert.assertTrue(res.getMediaId() != null || res.getThumbMediaId() != null);
if (res.getMediaId() != null) {
media_ids.add(res.getMediaId());
}
if (res.getThumbMediaId() != null) {
media_ids.add(res.getThumbMediaId());
}
}
use of org.testng.annotations.Test in project weixin-java-tools by chanjarster.
the class WxCpUserAPITest method testUserUpdate.
@Test(dependsOnMethods = "testUserCreate")
public void testUserUpdate() throws WxErrorException {
WxCpUser user = new WxCpUser();
user.setUserId("some.woman");
user.setName("Some Woman");
user.addExtAttr("爱好", "table2");
wxCpService.userUpdate(user);
}
use of org.testng.annotations.Test in project weixin-java-tools by chanjarster.
the class WxMpBusyRetryTest method testRetryInThreadPool.
@Test(dataProvider = "getService")
public void testRetryInThreadPool(final WxMpService service) throws InterruptedException, ExecutionException {
// 当线程池中的线程复用的时候,还是能保证相同的重试次数
ExecutorService executorService = Executors.newFixedThreadPool(1);
Runnable runnable = new Runnable() {
@Override
public void run() {
try {
System.out.println("=====================");
System.out.println(Thread.currentThread().getName() + ": testRetry");
service.execute(null, null, null);
} catch (WxErrorException e) {
throw new RuntimeException(e);
} catch (RuntimeException e) {
// OK
}
}
};
Future<?> submit1 = executorService.submit(runnable);
Future<?> submit2 = executorService.submit(runnable);
submit1.get();
submit2.get();
}
use of org.testng.annotations.Test in project weixin-java-tools by chanjarster.
the class WxMpMassMessageAPITest method testTextMassOpenIdsMessageSend.
@Test
public void testTextMassOpenIdsMessageSend() throws WxErrorException {
// 发送群发消息
ApiTestModule.WxXmlMpInMemoryConfigStorage configProvider = (ApiTestModule.WxXmlMpInMemoryConfigStorage) wxService.wxMpConfigStorage;
WxMpMassOpenIdsMessage massMessage = new WxMpMassOpenIdsMessage();
massMessage.setMsgType(WxConsts.MASS_MSG_TEXT);
massMessage.setContent("测试群发消息\n欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
massMessage.getToUsers().add(configProvider.getOpenId());
WxMpMassSendResult massResult = wxService.massOpenIdsMessageSend(massMessage);
Assert.assertNotNull(massResult);
Assert.assertNotNull(massResult.getMsgId());
}
Aggregations