当前位置: 首页>>代码示例>>Java>>正文


Java Maps类代码示例

本文整理汇总了Java中org.testng.collections.Maps的典型用法代码示例。如果您正苦于以下问题:Java Maps类的具体用法?Java Maps怎么用?Java Maps使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Maps类属于org.testng.collections包,在下文中一共展示了Maps类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createDocTest

import org.testng.collections.Maps; //导入依赖的package包/类
@Test
void createDocTest()
{
	BaseIndexer indexer = new SolrIndexer("", TEST1);
	List<String> languages = Lists.newArrayList();
	languages.add(LOCALE);
	Map<String, Object> createdDoc = indexer.createDoc(ID, ENGLISH_TITLE, SPANISH_TITLE, ALT_TITLE, languages);
	Map<String, Object> expectedDoc = Maps.newHashMap();
	expectedDoc.put(Properties.idField.get(), ID + "_" + TEST1);
	expectedDoc.put(Properties.titleFields.get().get(0) + "_en", ENGLISH_TITLE);
	Set<Object> localizedTitles = Sets.newHashSet();
	localizedTitles.add(SPANISH_TITLE);
	expectedDoc.put(Properties.titleFields.get().get(0) + "_es", localizedTitles);
	expectedDoc.put(Properties.docTypeFieldName.get(), TEST1);
	Assert.assertEquals(createdDoc, expectedDoc);

	StringBuilder jsonStringOfDoc = indexer.getJsonStringOfDoc(new ObjectMapper().valueToTree(createdDoc));
	Assert.assertEquals(jsonStringOfDoc.toString(), "[{\"query_testing_type\":\"test1\",\"title_en\":\"title en\",\"id\":\"123_test1\",\"title_es\":[\"title es\"]}]");
	
	String urlForAddingDoc = indexer.getUrlForAddingDoc(createdDoc);
	Assert.assertEquals(urlForAddingDoc, "http://localhost:8983/solr/qtest/update");

	String urlForCommitting = indexer.getUrlForCommitting();
	Assert.assertEquals(urlForCommitting, "http://localhost:8983/solr/qtest/update?commit=true");
}
 
开发者ID:Netflix,项目名称:q,代码行数:26,代码来源:SolrIndexerTest.java

示例2: setup

import org.testng.collections.Maps; //导入依赖的package包/类
@Override
protected void setup() throws Exception {
    super.internalSetup();
    super.producerBaseSetup();

    pulsarSpoutConf = new PulsarSpoutConfiguration();
    pulsarSpoutConf.setServiceUrl(serviceUrl);
    pulsarSpoutConf.setTopic(topic);
    pulsarSpoutConf.setSubscriptionName(subscriptionName);
    pulsarSpoutConf.setMessageToValuesMapper(messageToValuesMapper);
    pulsarSpoutConf.setFailedRetriesTimeout(1, TimeUnit.SECONDS);
    pulsarSpoutConf.setMaxFailedRetries(2);
    pulsarSpoutConf.setSharedConsumerEnabled(true);
    pulsarSpoutConf.setMetricsTimeIntervalInSecs(60);
    consumerConf = new ConsumerConfiguration();
    consumerConf.setSubscriptionType(SubscriptionType.Shared);
    spout = new PulsarSpout(pulsarSpoutConf, new ClientConfiguration(), consumerConf);
    mockCollector = new MockSpoutOutputCollector();
    SpoutOutputCollector collector = new SpoutOutputCollector(mockCollector);
    TopologyContext context = mock(TopologyContext.class);
    when(context.getThisComponentId()).thenReturn("test-spout-" + methodName);
    when(context.getThisTaskId()).thenReturn(0);
    spout.open(Maps.newHashMap(), context, collector);
    producer = pulsarClient.createProducer(topic);
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:26,代码来源:PulsarSpoutTest.java

示例3: testSharedConsumer

import org.testng.collections.Maps; //导入依赖的package包/类
@Test
public void testSharedConsumer() throws Exception {
    PersistentTopicStats topicStats = admin.persistentTopics().getStats(topic);
    Assert.assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 1);
    PulsarSpout otherSpout = new PulsarSpout(pulsarSpoutConf, new ClientConfiguration(), consumerConf);
    MockSpoutOutputCollector otherMockCollector = new MockSpoutOutputCollector();
    SpoutOutputCollector collector = new SpoutOutputCollector(otherMockCollector);
    TopologyContext context = mock(TopologyContext.class);
    when(context.getThisComponentId()).thenReturn("test-spout-" + methodName);
    when(context.getThisTaskId()).thenReturn(1);
    otherSpout.open(Maps.newHashMap(), context, collector);

    topicStats = admin.persistentTopics().getStats(topic);
    Assert.assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 1);

    otherSpout.close();

    topicStats = admin.persistentTopics().getStats(topic);
    Assert.assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 1);
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:21,代码来源:PulsarSpoutTest.java

示例4: testNoSharedConsumer

import org.testng.collections.Maps; //导入依赖的package包/类
@Test
public void testNoSharedConsumer() throws Exception {
    PersistentTopicStats topicStats = admin.persistentTopics().getStats(topic);
    Assert.assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 1);
    pulsarSpoutConf.setSharedConsumerEnabled(false);
    PulsarSpout otherSpout = new PulsarSpout(pulsarSpoutConf, new ClientConfiguration(), consumerConf);
    MockSpoutOutputCollector otherMockCollector = new MockSpoutOutputCollector();
    SpoutOutputCollector collector = new SpoutOutputCollector(otherMockCollector);
    TopologyContext context = mock(TopologyContext.class);
    when(context.getThisComponentId()).thenReturn("test-spout-" + methodName);
    when(context.getThisTaskId()).thenReturn(1);
    otherSpout.open(Maps.newHashMap(), context, collector);

    topicStats = admin.persistentTopics().getStats(topic);
    Assert.assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 2);

    otherSpout.close();

    topicStats = admin.persistentTopics().getStats(topic);
    Assert.assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 1);
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:22,代码来源:PulsarSpoutTest.java

示例5: testFailedConsumer

import org.testng.collections.Maps; //导入依赖的package包/类
@Test
public void testFailedConsumer() throws Exception {
    PulsarSpoutConfiguration pulsarSpoutConf = new PulsarSpoutConfiguration();
    pulsarSpoutConf.setServiceUrl(serviceUrl);
    pulsarSpoutConf.setTopic("persistent://invalidTopic");
    pulsarSpoutConf.setSubscriptionName(subscriptionName);
    pulsarSpoutConf.setMessageToValuesMapper(messageToValuesMapper);
    pulsarSpoutConf.setFailedRetriesTimeout(1, TimeUnit.SECONDS);
    pulsarSpoutConf.setMaxFailedRetries(2);
    pulsarSpoutConf.setSharedConsumerEnabled(false);
    pulsarSpoutConf.setMetricsTimeIntervalInSecs(60);
    ConsumerConfiguration consumerConf = new ConsumerConfiguration();
    consumerConf.setSubscriptionType(SubscriptionType.Shared);
    PulsarSpout spout = new PulsarSpout(pulsarSpoutConf, new ClientConfiguration(), consumerConf);
    MockSpoutOutputCollector mockCollector = new MockSpoutOutputCollector();
    SpoutOutputCollector collector = new SpoutOutputCollector(mockCollector);
    TopologyContext context = mock(TopologyContext.class);
    when(context.getThisComponentId()).thenReturn("new-test" + methodName);
    when(context.getThisTaskId()).thenReturn(0);
    try {
        spout.open(Maps.newHashMap(), context, collector);
        fail("should have failed as consumer creation failed");
    } catch (IllegalStateException e) {
        // Ok
    }
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:27,代码来源:PulsarSpoutTest.java

示例6: setup

import org.testng.collections.Maps; //导入依赖的package包/类
@Override
protected void setup() throws Exception {
    super.internalSetup();
    super.producerBaseSetup();

    pulsarBoltConf = new PulsarBoltConfiguration();
    pulsarBoltConf.setServiceUrl(serviceUrl);
    pulsarBoltConf.setTopic(topic);
    pulsarBoltConf.setTupleToMessageMapper(tupleToMessageMapper);
    pulsarBoltConf.setMetricsTimeIntervalInSecs(60);
    bolt = new PulsarBolt(pulsarBoltConf, new ClientConfiguration());
    mockCollector = new MockOutputCollector();
    OutputCollector collector = new OutputCollector(mockCollector);
    TopologyContext context = mock(TopologyContext.class);
    when(context.getThisComponentId()).thenReturn("test-bolt-" + methodName);
    when(context.getThisTaskId()).thenReturn(0);
    bolt.prepare(Maps.newHashMap(), context, collector);
    consumer = pulsarClient.subscribe(topic, subscriptionName);
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:20,代码来源:PulsarBoltTest.java

示例7: testSharedProducer

import org.testng.collections.Maps; //导入依赖的package包/类
@Test
public void testSharedProducer() throws Exception {
    PersistentTopicStats topicStats = admin.persistentTopics().getStats(topic);
    Assert.assertEquals(topicStats.publishers.size(), 1);
    PulsarBolt otherBolt = new PulsarBolt(pulsarBoltConf, new ClientConfiguration());
    MockOutputCollector otherMockCollector = new MockOutputCollector();
    OutputCollector collector = new OutputCollector(otherMockCollector);
    TopologyContext context = mock(TopologyContext.class);
    when(context.getThisComponentId()).thenReturn("test-bolt-" + methodName);
    when(context.getThisTaskId()).thenReturn(1);
    otherBolt.prepare(Maps.newHashMap(), context, collector);

    topicStats = admin.persistentTopics().getStats(topic);
    Assert.assertEquals(topicStats.publishers.size(), 1);

    otherBolt.close();

    topicStats = admin.persistentTopics().getStats(topic);
    Assert.assertEquals(topicStats.publishers.size(), 1);
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:21,代码来源:PulsarBoltTest.java

示例8: testFailedProducer

import org.testng.collections.Maps; //导入依赖的package包/类
@Test
public void testFailedProducer() {
    PulsarBoltConfiguration pulsarBoltConf = new PulsarBoltConfiguration();
    pulsarBoltConf.setServiceUrl(serviceUrl);
    pulsarBoltConf.setTopic("persistent://invalid");
    pulsarBoltConf.setTupleToMessageMapper(tupleToMessageMapper);
    pulsarBoltConf.setMetricsTimeIntervalInSecs(60);
    PulsarBolt bolt = new PulsarBolt(pulsarBoltConf, new ClientConfiguration());
    MockOutputCollector mockCollector = new MockOutputCollector();
    OutputCollector collector = new OutputCollector(mockCollector);
    TopologyContext context = mock(TopologyContext.class);
    when(context.getThisComponentId()).thenReturn("new" + methodName);
    when(context.getThisTaskId()).thenReturn(0);
    try {
        bolt.prepare(Maps.newHashMap(), context, collector);
        fail("should have failed as producer creation failed");
    } catch (IllegalStateException ie) {
        // Ok.
    }
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:21,代码来源:PulsarBoltTest.java

示例9: createInstances

import org.testng.collections.Maps; //导入依赖的package包/类
private List<List<IMethodInstance>> createInstances(List<IMethodInstance> methodInstances) {
    Map<Object, List<IMethodInstance>> map = Maps.newHashMap();
//    MapList<IMethodInstance[], Object> map = new MapList<IMethodInstance[], Object>();
    for (IMethodInstance imi : methodInstances) {
      for (Object o : imi.getInstances()) {
        System.out.println(o);
        List<IMethodInstance> l = map.get(o);
        if (l == null) {
          l = Lists.newArrayList();
          map.put(o, l);
        }
        l.add(imi);
      }
//      for (Object instance : imi.getInstances()) {
//        map.put(imi, instance);
//      }
    }
//    return map.getKeys();
//    System.out.println(map);
    return new ArrayList<List<IMethodInstance>>(map.values());
  }
 
开发者ID:qmetry,项目名称:qaf,代码行数:22,代码来源:TestRunner.java

示例10: getNodeReplicas

import org.testng.collections.Maps; //导入依赖的package包/类
/** Returns all replicas per node. */
private Map<String, List<ReplicaInfo>> getNodeReplicas() {
    final ClusterState clusterState = getClusterState();
    final Map<String, List<ReplicaInfo>> result = Maps.newHashMap();
    for (final DocCollection collection : clusterState.getCollectionsMap().values()) {
        for (final Slice slice : collection.getSlices()) {
            for (final Replica replica : slice.getReplicas()) {
                List<ReplicaInfo> nodeReplicas = result.get(replica.getNodeName());
                if (nodeReplicas == null) {
                    nodeReplicas = Lists.newArrayList();
                    result.put(replica.getNodeName(), nodeReplicas);
                }
                nodeReplicas.add(new ReplicaInfo(replica, collection.getName(), slice.getName()));
            }
        }
    }
    return result;
}
 
开发者ID:shaie,项目名称:lucenelab,代码行数:19,代码来源:CollectionsStateHelper.java

示例11: checkDeletions

import org.testng.collections.Maps; //导入依赖的package包/类
@Test(dependsOnMethods = "getAndClearNotifications", groups = "eps")
public void checkDeletions() throws Exception
{
	waitForIndex(0, "nonExistantCountsAsAll?");

	JsonNode results = doNotificationsSearch("dontfindanything", null, Maps.newHashMap(), getToken());
	assertEquals(results.get("available").asInt(), 0, "Should be no notifications");
}
 
开发者ID:equella,项目名称:Equella,代码行数:9,代码来源:NotificationsApiTest.java

示例12: testInsertMany

import org.testng.collections.Maps; //导入依赖的package包/类
@Test
public void testInsertMany() throws Exception {
    List<Map<String, Object>> dataList = Lists.newArrayList();
    for (int i =0; i< 10; i++){
        Map<String, Object> map = Maps.newHashMap();
        map.put("number", i);
        dataList.add(map);
    }
    dataAccess.insertMany("testNumber", dataList);
}
 
开发者ID:wxz1211,项目名称:dooo,代码行数:11,代码来源:TestA.java

示例13: createDocTest

import org.testng.collections.Maps; //导入依赖的package包/类
@Test
void createDocTest()
{

	BaseIndexer indexer = new ElasticsearchIndexer("", TEST1);
	List<String> languages = Lists.newArrayList();
	languages.add(LOCALE);
	Map<String, Object> createdDoc = indexer.createDoc(ID, ENGLISH_TITLE, SPANISH_TITLE, ALT_TITLE, languages);
	Map<String, Object> expectedDoc = Maps.newHashMap();
	expectedDoc.put(Properties.idField.get(), ID + "_" + TEST1);
	expectedDoc.put(Properties.titleFields.get().get(0) + "_en", ENGLISH_TITLE);
	Set<Object> localizedTitles = Sets.newHashSet();
	localizedTitles.add(SPANISH_TITLE);
	expectedDoc.put(Properties.titleFields.get().get(0) + "_es", localizedTitles);
	expectedDoc.put(Properties.docTypeFieldName.get(), TEST1);

	Assert.assertEquals(createdDoc, expectedDoc);

	StringBuilder jsonStringOfDoc = indexer.getJsonStringOfDoc(new ObjectMapper().valueToTree(createdDoc));
	Assert.assertEquals(jsonStringOfDoc.toString(), "{\"query_testing_type\":\"test1\",\"title_en\":\"title en\",\"id\":\"123_test1\",\"title_es\":[\"title es\"]}");
	
	String urlForAddingDoc = indexer.getUrlForAddingDoc(createdDoc);
	Assert.assertEquals(urlForAddingDoc, "http://localhost:8983/solr/qtest/test_doc/123_test1");

	String urlForCommitting = indexer.getUrlForCommitting();
	Assert.assertEquals(urlForCommitting, "http://localhost:8983/solr/qtest/_flush");

}
 
开发者ID:Netflix,项目名称:q,代码行数:29,代码来源:ElasticsearchIndexerTest.java

示例14: createDocTest

import org.testng.collections.Maps; //导入依赖的package包/类
@Test
void createDocTest()
{
	GoogleDataExtractor titleExtractor = Mockito.mock(GoogleDataExtractor.class);
	Map<String, Map<Integer, TitleWithQueries>> mapOfQueriesToTitles = Maps.newHashMap();
	
	Map<Integer, TitleWithQueries> titlesWithQueries = Maps.newHashMap();
	TitleWithQueries titleWithQueries = new TitleWithQueries(DATASET_ID);
	titleWithQueries.setValue(TitleWithQueries.ID, ID1);
	titleWithQueries.setValue(TitleWithQueries.TITLE_EN, ENGLISH_TITLE);
	titleWithQueries.setValue(TitleWithQueries.TITLE_LOCALE, SPANISH_TITLE);
	titleWithQueries.setValue(TitleWithQueries.Q_ + "regular", Q1);
	titlesWithQueries.put(1, titleWithQueries);

	TitleWithQueries titleWithQueries2 = new TitleWithQueries(DATASET_ID);
	titleWithQueries2.setValue(TitleWithQueries.ID, ID2);
	titleWithQueries2.setValue(TitleWithQueries.TITLE_EN, ENGLISH_TITLE);
	titleWithQueries2.setValue(TitleWithQueries.TITLE_LOCALE, SPANISH_TITLE);
	titleWithQueries2.setValue(TitleWithQueries.Q_ + "regular", Q1);
	titlesWithQueries.put(2, titleWithQueries2);

	mapOfQueriesToTitles.put(DATASET_ID, titlesWithQueries);

	Mockito.when(titleExtractor.getTitlesWithQueriesPerDataset()).thenReturn(mapOfQueriesToTitles);

	Queries queries = new Queries(DATASET_ID, TEST1, titleExtractor);
	queries.populateFromGoogleSpreadsheets();

	Map<String, Set<String>> queryToIdMap = queries.getQueryToIdMap();

	Map<String, Set<String>> expectedQueryToIdMap = Maps.newHashMap();
	Set<String> titles = Sets.newHashSet();
	titles.add(ID1+"_"+DATASET_ID);
	titles.add(ID2+"_"+DATASET_ID);
	expectedQueryToIdMap.put(Q1, titles);

	Assert.assertEquals(queryToIdMap, expectedQueryToIdMap);
}
 
开发者ID:Netflix,项目名称:q,代码行数:39,代码来源:QueriesTest.java

示例15: createGroups

import org.testng.collections.Maps; //导入依赖的package包/类
private Map<String, String> createGroups(String[] groups) {
  Map<String, String> result = Maps.newHashMap();

  // Groups that were passed on the command line
  for (String group : groups) {
    result.put(group, group);
  }

  // See if we have any MetaGroups and
  // expand them if they match one of the groups
  // we have just been passed
  List<String> unfinishedGroups = Lists.newArrayList();

  if (m_metaGroups.size() > 0) {
    collectGroups(groups, unfinishedGroups, result);

    // Do we need to loop over unfinished groups?
    while (unfinishedGroups.size() > 0) {
      String[] uGroups = unfinishedGroups.toArray(new String[unfinishedGroups.size()]);
      unfinishedGroups = Lists.newArrayList();
      collectGroups(uGroups, unfinishedGroups, result);
    }
  }

  //    Utils.dumpMap(result);
  return result;
}
 
开发者ID:qmetry,项目名称:qaf,代码行数:28,代码来源:TestRunner.java


注:本文中的org.testng.collections.Maps类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。