Search in sources :

Example 11 with Test

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();
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) WxErrorException(me.chanjar.weixin.common.exception.WxErrorException) Test(org.testng.annotations.Test)

Example 12 with Test

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());
    }
}
Also used : InputStream(java.io.InputStream) WxMediaUploadResult(me.chanjar.weixin.common.bean.result.WxMediaUploadResult) Test(org.testng.annotations.Test)

Example 13 with Test

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);
}
Also used : WxCpUser(me.chanjar.weixin.cp.bean.WxCpUser) Test(org.testng.annotations.Test)

Example 14 with Test

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();
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) WxErrorException(me.chanjar.weixin.common.exception.WxErrorException) Test(org.testng.annotations.Test)

Example 15 with Test

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());
}
Also used : WxMpMassSendResult(me.chanjar.weixin.mp.bean.result.WxMpMassSendResult) WxMpMassOpenIdsMessage(me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)24007 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2438 Task (com.evolveum.midpoint.task.api.Task)2069 File (java.io.File)1433 ArrayList (java.util.ArrayList)1237 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)1188 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)1078 HashMap (java.util.HashMap)965 CommandLineProgramTest (org.broadinstitute.hellbender.CommandLineProgramTest)814 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)692 BeforeTest (org.testng.annotations.BeforeTest)692 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)690 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)651 Parameters (org.testng.annotations.Parameters)610 BaseTest (org.xdi.oxauth.BaseTest)582 BigDecimal (java.math.BigDecimal)574 List (java.util.List)558 LocalDate (org.joda.time.LocalDate)553 HashSet (java.util.HashSet)548 BaseTest (util.BaseTest)537