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," } };
}
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 } };
}
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 } };
}
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();
}
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");
}
Aggregations