Search in sources :

Example 66 with DataProvider

use of org.testng.annotations.DataProvider in project weixin-java-tools by chanjarster.

the class WxMpMessageRouterTest method messages2.

@DataProvider(name = "messages-1")
public Object[][] messages2() {
    WxMpXmlMessage message1 = new WxMpXmlMessage();
    message1.setMsgType(WxConsts.XML_MSG_TEXT);
    WxMpXmlMessage message2 = new WxMpXmlMessage();
    message2.setEvent(WxConsts.EVT_CLICK);
    WxMpXmlMessage message3 = new WxMpXmlMessage();
    message3.setEventKey("KEY_1");
    WxMpXmlMessage message4 = new WxMpXmlMessage();
    message4.setContent("CONTENT_1");
    WxMpXmlMessage message5 = new WxMpXmlMessage();
    message5.setContent("BLA");
    WxMpXmlMessage message6 = new WxMpXmlMessage();
    message6.setContent("abcd");
    WxMpXmlMessage message7 = new WxMpXmlMessage();
    message7.setFormat("strangeformat");
    WxMpXmlMessage c2 = new WxMpXmlMessage();
    c2.setMsgType(WxConsts.XML_MSG_TEXT);
    c2.setEvent(WxConsts.EVT_CLICK);
    WxMpXmlMessage c3 = new WxMpXmlMessage();
    c3.setMsgType(WxConsts.XML_MSG_TEXT);
    c3.setEvent(WxConsts.EVT_CLICK);
    c3.setEventKey("KEY_1");
    WxMpXmlMessage c4 = new WxMpXmlMessage();
    c4.setMsgType(WxConsts.XML_MSG_TEXT);
    c4.setEvent(WxConsts.EVT_CLICK);
    c4.setEventKey("KEY_1");
    c4.setContent("CONTENT_1");
    return new Object[][] { new Object[] { message1, WxConsts.XML_MSG_TEXT + "," }, new Object[] { message2, WxConsts.EVT_CLICK + "," }, new Object[] { message3, "KEY_1," }, new Object[] { message4, "CONTENT_1," }, new Object[] { message5, "ALL," }, new Object[] { message6, "abcd," }, new Object[] { message7, "matcher," }, new Object[] { c2, "COMBINE_2," }, new Object[] { c3, "COMBINE_3," }, new Object[] { c4, "COMBINE_4," } };
}
Also used : WxMpXmlMessage(me.chanjar.weixin.mp.bean.WxMpXmlMessage) DataProvider(org.testng.annotations.DataProvider)

Example 67 with DataProvider

use of org.testng.annotations.DataProvider in project weixin-java-tools by chanjarster.

the class WxCpMessageRouterTest method standardSessionManager.

@DataProvider
public Object[][] standardSessionManager() {
    // 故意把session存活时间变短,清理更频繁
    StandardSessionManager ism = new StandardSessionManager();
    ism.setMaxInactiveInterval(1);
    ism.setProcessExpiresFrequency(1);
    ism.setBackgroundProcessorDelay(1);
    return new Object[][] { new Object[] { ism } };
}
Also used : StandardSessionManager(me.chanjar.weixin.common.session.StandardSessionManager) DataProvider(org.testng.annotations.DataProvider)

Example 68 with DataProvider

use of org.testng.annotations.DataProvider in project OpenAM by OpenRock.

the class ApplicationManagerTest method testMatchData.

@DataProvider(name = "testMatchData")
public Object[][] testMatchData() throws IllegalAccessException, InstantiationException {
    Application dummyApplication = application("Application");
    dummyApplication.setDescription("An example application");
    dummyApplication.setCreatedBy("amadmin");
    dummyApplication.setCreationDate(10);
    dummyApplication.setLastModifiedBy("bjensen");
    dummyApplication.setLastModifiedDate(100);
    return new Object[][] { // Name
    { asSet(nameFilter("Application")), dummyApplication, MATCH }, { asSet(nameFilter("*")), dummyApplication, MATCH }, { asSet(nameFilter("A*t*o*")), dummyApplication, MATCH }, { asSet(nameFilter("iPlanetAMWebAgentService")), dummyApplication, NO_MATCH }, // Description
    { asSet(descriptionFilter("An example application")), dummyApplication, MATCH }, { asSet(descriptionFilter("*")), dummyApplication, MATCH }, { asSet(descriptionFilter("Now is the winter of our discontent...")), dummyApplication, NO_MATCH }, // Created By
    { asSet(createdByFilter("amadmin")), dummyApplication, MATCH }, { asSet(createdByFilter("*")), dummyApplication, MATCH }, { asSet(createdByFilter("rumpelstiltskin")), dummyApplication, NO_MATCH }, // Last Modified By
    { asSet(lastModifiedByFilter("bjensen")), dummyApplication, MATCH }, { asSet(lastModifiedByFilter("*")), dummyApplication, MATCH }, { asSet(lastModifiedByFilter("rumpelstiltskin")), dummyApplication, NO_MATCH }, // Creation Date
    { asSet(creationDateFilter(11, LESS_THAN_OPERATOR)), dummyApplication, MATCH }, { asSet(creationDateFilter(10, LESS_THAN_OPERATOR)), dummyApplication, NO_MATCH }, { asSet(creationDateFilter(10, LESS_THAN_OR_EQUAL_OPERATOR)), dummyApplication, MATCH }, { asSet(creationDateFilter(10, EQUALS_OPERATOR)), dummyApplication, MATCH }, { asSet(creationDateFilter(10, GREATER_THAN_OR_EQUAL_OPERATOR)), dummyApplication, MATCH }, { asSet(creationDateFilter(10, GREATER_THAN_OPERATOR)), dummyApplication, NO_MATCH }, { asSet(creationDateFilter(9, GREATER_THAN_OPERATOR)), dummyApplication, MATCH }, // Last Modified Date
    { asSet(lastModifiedDateFilter(101, LESS_THAN_OPERATOR)), dummyApplication, MATCH }, { asSet(lastModifiedDateFilter(100, LESS_THAN_OPERATOR)), dummyApplication, NO_MATCH }, { asSet(lastModifiedDateFilter(100, LESS_THAN_OR_EQUAL_OPERATOR)), dummyApplication, MATCH }, { asSet(lastModifiedDateFilter(100, EQUALS_OPERATOR)), dummyApplication, MATCH }, { asSet(lastModifiedDateFilter(100, GREATER_THAN_OR_EQUAL_OPERATOR)), dummyApplication, MATCH }, { asSet(lastModifiedDateFilter(100, GREATER_THAN_OPERATOR)), dummyApplication, NO_MATCH }, { asSet(lastModifiedDateFilter(99, GREATER_THAN_OPERATOR)), dummyApplication, MATCH } };
}
Also used : Application(com.sun.identity.entitlement.Application) DataProvider(org.testng.annotations.DataProvider)

Example 69 with DataProvider

use of org.testng.annotations.DataProvider in project selenium-tests by Wikia.

the class ArticleRTETest method wikiTextsProvider.

@DataProvider(parallel = false, name = "wikiTextsProvider")
public Iterator<Object[]> wikiTextsProvider() throws Exception {
    String[] wikiTexts = ArticleRTETest.createWikitexts();
    List al = new ArrayList();
    int startPos = 0;
    int endPos = WIKI_TEXTS_PER_CYCLE;
    while (endPos <= wikiTexts.length) {
        al.add(new Object[] { Arrays.copyOfRange(wikiTexts, startPos, endPos) });
        startPos = endPos;
        endPos += WIKI_TEXTS_PER_CYCLE;
    }
    if (startPos < wikiTexts.length) {
        al.add(new Object[] { Arrays.copyOfRange(wikiTexts, startPos, wikiTexts.length) });
    }
    return al.iterator();
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) DataProvider(org.testng.annotations.DataProvider)

Example 70 with DataProvider

use of org.testng.annotations.DataProvider in project pulsar by yahoo.

the class BrokerClientIntegrationTest method testResetCursor.

@Test(timeOut = 10000, dataProvider = "subType")
public void testResetCursor(SubscriptionType subType) throws Exception {
    final RetentionPolicies policy = new RetentionPolicies(60, 52 * 1024);
    final DestinationName destName = DestinationName.get("persistent://my-property/use/my-ns/unacked-topic");
    final int warmup = 20;
    final int testSize = 150;
    final List<Message> received = new ArrayList<Message>();
    final ConsumerConfiguration consConfig = new ConsumerConfiguration();
    final String subsId = "sub";
    final NavigableMap<Long, TimestampEntryCount> publishTimeIdMap = new ConcurrentSkipListMap<>();
    consConfig.setSubscriptionType(subType);
    consConfig.setMessageListener((MessageListener) (Consumer consumer, Message msg) -> {
        try {
            synchronized (received) {
                received.add(msg);
            }
            consumer.acknowledge(msg);
            long publishTime = ((MessageImpl) msg).getPublishTime();
            log.info(" publish time is " + publishTime + "," + msg.getMessageId());
            TimestampEntryCount timestampEntryCount = publishTimeIdMap.computeIfAbsent(publishTime, (k) -> new TimestampEntryCount(publishTime));
            timestampEntryCount.incrementAndGet();
        } catch (final PulsarClientException e) {
            log.warn("Failed to ack!");
        }
    });
    admin.namespaces().setRetention(destName.getNamespace(), policy);
    Consumer consumer = pulsarClient.subscribe(destName.toString(), subsId, consConfig);
    final Producer producer = pulsarClient.createProducer(destName.toString());
    log.info("warm up started for " + destName.toString());
    // send warmup msgs
    byte[] msgBytes = new byte[1000];
    for (Integer i = 0; i < warmup; i++) {
        producer.send(msgBytes);
    }
    log.info("warm up finished.");
    // sleep to ensure receiving of msgs
    for (int n = 0; n < 10 && received.size() < warmup; n++) {
        Thread.sleep(100);
    }
    // validate received msgs
    Assert.assertEquals(received.size(), warmup);
    received.clear();
    // publish testSize num of msgs
    log.info("Sending more messages.");
    for (Integer n = 0; n < testSize; n++) {
        producer.send(msgBytes);
        Thread.sleep(1);
    }
    log.info("Sending more messages done.");
    Thread.sleep(3000);
    long begints = publishTimeIdMap.firstEntry().getKey();
    long endts = publishTimeIdMap.lastEntry().getKey();
    // find reset timestamp
    long timestamp = (endts - begints) / 2 + begints;
    timestamp = publishTimeIdMap.floorKey(timestamp);
    NavigableMap<Long, TimestampEntryCount> expectedMessages = new ConcurrentSkipListMap<>();
    expectedMessages.putAll(publishTimeIdMap.tailMap(timestamp, true));
    received.clear();
    log.info("reset cursor to " + timestamp + " for topic " + destName.toString() + " for subs " + subsId);
    log.info("issuing admin operation on " + admin.getServiceUrl().toString());
    List<String> subList = admin.persistentTopics().getSubscriptions(destName.toString());
    for (String subs : subList) {
        log.info("got sub " + subs);
    }
    publishTimeIdMap.clear();
    // reset the cursor to this timestamp
    Assert.assertTrue(subList.contains(subsId));
    admin.persistentTopics().resetCursor(destName.toString(), subsId, timestamp);
    consumer = pulsarClient.subscribe(destName.toString(), subsId, consConfig);
    Thread.sleep(3000);
    int totalExpected = 0;
    for (TimestampEntryCount tec : expectedMessages.values()) {
        totalExpected += tec.numMessages;
    }
    // validate that replay happens after the timestamp
    Assert.assertTrue(publishTimeIdMap.firstEntry().getKey() >= timestamp);
    consumer.close();
    producer.close();
    // validate that expected and received counts match
    int totalReceived = 0;
    for (TimestampEntryCount tec : publishTimeIdMap.values()) {
        totalReceived += tec.numMessages;
    }
    Assert.assertEquals(totalReceived, totalExpected, "did not receive all messages on replay after reset");
}
Also used : RetentionPolicies(com.yahoo.pulsar.common.policies.data.RetentionPolicies) Assert.assertNull(org.testng.Assert.assertNull) DataProvider(org.testng.annotations.DataProvider) Consumer(com.yahoo.pulsar.client.api.Consumer) LoggerFactory(org.slf4j.LoggerFactory) Test(org.testng.annotations.Test) Mockito.spy(org.mockito.Mockito.spy) AfterMethod(org.testng.annotations.AfterMethod) OwnershipCache(com.yahoo.pulsar.broker.namespace.OwnershipCache) SubscriptionType(com.yahoo.pulsar.client.api.SubscriptionType) ProducerConfiguration(com.yahoo.pulsar.client.api.ProducerConfiguration) ArrayList(java.util.ArrayList) State(com.yahoo.pulsar.client.impl.HandlerBase.State) Assert(org.testng.Assert) ProducerConsumerBase(com.yahoo.pulsar.client.api.ProducerConsumerBase) RetentionPolicies(com.yahoo.pulsar.common.policies.data.RetentionPolicies) Matchers.anyObject(org.mockito.Matchers.anyObject) Mockito.doAnswer(org.mockito.Mockito.doAnswer) MessageListener(com.yahoo.pulsar.client.api.MessageListener) URI(java.net.URI) PulsarClient(com.yahoo.pulsar.client.api.PulsarClient) Assert.assertFalse(org.testng.Assert.assertFalse) ExecutorService(java.util.concurrent.ExecutorService) DestinationName(com.yahoo.pulsar.common.naming.DestinationName) NamespaceBundle(com.yahoo.pulsar.common.naming.NamespaceBundle) Logger(org.slf4j.Logger) Producer(com.yahoo.pulsar.client.api.Producer) Assert.fail(org.testng.Assert.fail) Mockito.atLeastOnce(org.mockito.Mockito.atLeastOnce) BeforeMethod(org.testng.annotations.BeforeMethod) ConsumerConfiguration(com.yahoo.pulsar.client.api.ConsumerConfiguration) Set(java.util.Set) PulsarHandler(com.yahoo.pulsar.common.api.PulsarHandler) Field(java.lang.reflect.Field) NavigableMap(java.util.NavigableMap) Executors(java.util.concurrent.Executors) Sets(com.google.common.collect.Sets) Mockito.verify(org.mockito.Mockito.verify) TimeUnit(java.util.concurrent.TimeUnit) Topic(com.yahoo.pulsar.broker.service.Topic) Mockito.never(org.mockito.Mockito.never) List(java.util.List) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) ClientConfiguration(com.yahoo.pulsar.client.api.ClientConfiguration) ConcurrentLongHashMap(com.yahoo.pulsar.common.util.collections.ConcurrentLongHashMap) Assert.assertTrue(org.testng.Assert.assertTrue) PulsarClientException(com.yahoo.pulsar.client.api.PulsarClientException) Message(com.yahoo.pulsar.client.api.Message) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) Message(com.yahoo.pulsar.client.api.Message) ArrayList(java.util.ArrayList) Consumer(com.yahoo.pulsar.client.api.Consumer) Producer(com.yahoo.pulsar.client.api.Producer) DestinationName(com.yahoo.pulsar.common.naming.DestinationName) ConsumerConfiguration(com.yahoo.pulsar.client.api.ConsumerConfiguration) PulsarClientException(com.yahoo.pulsar.client.api.PulsarClientException) Test(org.testng.annotations.Test)

Aggregations

DataProvider (org.testng.annotations.DataProvider)391 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)99 ArrayList (java.util.ArrayList)93 Test (org.testng.annotations.Test)85 File (java.io.File)74 List (java.util.List)72 Assert (org.testng.Assert)67 URIDetails (com.linkedin.restli.internal.testutils.URIDetails)65 Collectors (java.util.stream.Collectors)61 HashMap (java.util.HashMap)57 IntStream (java.util.stream.IntStream)54 Random (java.util.Random)50 RealMatrix (org.apache.commons.math3.linear.RealMatrix)44 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)41 IOException (java.io.IOException)39 ByteString (com.linkedin.data.ByteString)37 Array2DRowRealMatrix (org.apache.commons.math3.linear.Array2DRowRealMatrix)34 Stream (java.util.stream.Stream)31 DoubleStream (java.util.stream.DoubleStream)29 HashSet (java.util.HashSet)28