當前位置: 首頁>>代碼示例>>Java>>正文


Java Lists類代碼示例

本文整理匯總了Java中org.testng.collections.Lists的典型用法代碼示例。如果您正苦於以下問題:Java Lists類的具體用法?Java Lists怎麽用?Java Lists使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Lists類屬於org.testng.collections包,在下文中一共展示了Lists類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getMethodsThatBelongTo

import org.testng.collections.Lists; //導入依賴的package包/類
public List<ITestNGMethod> getMethodsThatBelongTo(String group, ITestNGMethod fromMethod) {
  Set<String> uniqueKeys = m_groups.keySet();

  List<ITestNGMethod> result = Lists.newArrayList();

  for (String k : uniqueKeys) {
    if (Pattern.matches(group, k)) {
      result.addAll(m_groups.get(k));
    }
  }

  if (result.isEmpty() && !fromMethod.ignoreMissingDependencies()) {
    throw new TestNGException("DependencyMap::Method \"" + fromMethod
        + "\" depends on nonexistent group \"" + group + "\"");
  } else {
    return result;
  }
}
 
開發者ID:qmetry,項目名稱:qaf,代碼行數:19,代碼來源:DependencyMap.java

示例2: createTestMethods

import org.testng.collections.Lists; //導入依賴的package包/類
/**
 * Create the test methods that belong to this class (rejects
 * all those that belong to a different class).
 */
private ITestNGMethod[] createTestMethods(ITestNGMethod[] methods) {
  List<ITestNGMethod> vResult = Lists.newArrayList();
  for (ITestNGMethod tm : methods) {
    ConstructorOrMethod m = tm.getConstructorOrMethod();
    if (m.getDeclaringClass().isAssignableFrom(m_testClass)) {
      for (Object o : m_iClass.getInstances(false)) {
        log(4, "Adding method " + tm + " on TestClass " + m_testClass);
        vResult.add(new TestNGScenario(/* tm.getRealClass(), */ m.getMethod(), m_annotationFinder, m_xmlTest,
            o));
      }
    }
    else {
      log(4, "Rejecting method " + tm + " for TestClass " + m_testClass);
    }
  }

  ITestNGMethod[] result = vResult.toArray(new ITestNGMethod[vResult.size()]);
  return result;
}
 
開發者ID:qmetry,項目名稱:qaf,代碼行數:24,代碼來源:TestClass.java

示例3: intercept

import org.testng.collections.Lists; //導入依賴的package包/類
/**
 * Apply the method interceptor (if applicable) to the list of methods.
 */
private ITestNGMethod[] intercept(ITestNGMethod[] methods) {
  List<IMethodInstance> methodInstances = methodsToMethodInstances(Arrays.asList(methods));

  // add built-in interceptor (PreserveOrderMethodInterceptor or InstanceOrderingMethodInterceptor at the end of the list
  m_methodInterceptors.add(builtinInterceptor);
  for (IMethodInterceptor m_methodInterceptor : m_methodInterceptors) {
    methodInstances = m_methodInterceptor.intercept(methodInstances, this);
  }

  List<ITestNGMethod> result = Lists.newArrayList();
  for (IMethodInstance imi : methodInstances) {
    result.add(imi.getMethod());
  }

  //Since an interceptor is involved, we would need to ensure that the ClassMethodMap object is in sync with the
  //output of the interceptor, else @AfterClass doesn't get executed at all when interceptors are involved.
  //so let's update the current classMethodMap object with the list of methods obtained from the interceptor.
  this.m_classMethodMap = new ClassMethodMap(result, null);

  return result.toArray(new ITestNGMethod[result.size()]);
}
 
開發者ID:qmetry,項目名稱:qaf,代碼行數:25,代碼來源:TestRunner.java

示例4: createInstances

import org.testng.collections.Lists; //導入依賴的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

示例5: getInjector

import org.testng.collections.Lists; //導入依賴的package包/類
@Override
public Injector getInjector(IClass iClass) {
  Annotation annotation = AnnotationHelper.findAnnotationSuperClasses(Guice.class, iClass.getRealClass());
  if (annotation == null) return null;
  if (iClass instanceof TestClass) {
    iClass = ((TestClass)iClass).getIClass();
  }
  if (!(iClass instanceof ClassImpl)) return null;
  Injector parentInjector = ((ClassImpl)iClass).getParentInjector();

  Guice guice = (Guice) annotation;
  List<Module> moduleInstances = Lists.newArrayList(getModules(guice, parentInjector, iClass.getRealClass()));

  // Reuse the previous injector, if any
  Injector injector = getInjector(moduleInstances);
  if (injector == null) {
    injector = parentInjector.createChildInjector(moduleInstances);
    addInjector(moduleInstances, injector);
  }
  return injector;
}
 
開發者ID:qmetry,項目名稱:qaf,代碼行數:22,代碼來源:TestRunner.java

示例6: collectAndOrderMethods

import org.testng.collections.Lists; //導入依賴的package包/類
/**
 * Collects and orders test or configuration methods
 * @param methods methods to be worked on
 * @param forTests true for test methods, false for configuration methods
 * @param runInfo
 * @param finder annotation finder
 * @param unique true for unique methods, false otherwise
 * @param outExcludedMethods
 * @return list of ordered methods
 */
public static ITestNGMethod[] collectAndOrderMethods(List<ITestNGMethod> methods,
    boolean forTests, RunInfo runInfo, IAnnotationFinder finder,
    boolean unique, List<ITestNGMethod> outExcludedMethods)
{
  List<ITestNGMethod> includedMethods = Lists.newArrayList();
  MethodGroupsHelper.collectMethodsByGroup(methods.toArray(new ITestNGMethod[methods.size()]),
      forTests,
      includedMethods,
      outExcludedMethods,
      runInfo,
      finder,
      unique);

  return sortMethods(forTests, includedMethods, finder).toArray(new ITestNGMethod[]{});
}
 
開發者ID:qmetry,項目名稱:qaf,代碼行數:26,代碼來源:MethodHelper.java

示例7: sortMethods

import org.testng.collections.Lists; //導入依賴的package包/類
private static List<ITestNGMethod> sortMethods(boolean forTests,
    List<ITestNGMethod> allMethods, IAnnotationFinder finder) {
  List<ITestNGMethod> sl = Lists.newArrayList();
  List<ITestNGMethod> pl = Lists.newArrayList();
  ITestNGMethod[] allMethodsArray = allMethods.toArray(new ITestNGMethod[allMethods.size()]);

  // Fix the method inheritance if these are @Configuration methods to make
  // sure base classes are invoked before child classes if 'before' and the
  // other way around if they are 'after'
  if (!forTests && allMethodsArray.length > 0) {
    ITestNGMethod m = allMethodsArray[0];
    boolean before = m.isBeforeClassConfiguration()
        || m.isBeforeMethodConfiguration() || m.isBeforeSuiteConfiguration()
        || m.isBeforeTestConfiguration();
    MethodInheritance.fixMethodInheritance(allMethodsArray, before);
  }

  topologicalSort(allMethodsArray, sl, pl);

  List<ITestNGMethod> result = Lists.newArrayList();
  result.addAll(sl);
  result.addAll(pl);
  return result;
}
 
開發者ID:qmetry,項目名稱:qaf,代碼行數:25,代碼來源:MethodHelper.java

示例8: createAnnotationParameters

import org.testng.collections.Lists; //導入依賴的package包/類
/**
 * Process testResult to create parameters provided via {@link Parameters}
 *
 * @param testResult           TestNG's testResult context
 * @param parametersAnnotation Annotation with parameters
 * @return Step Parameters being sent to Report Portal
 */
private List<ParameterResource> createAnnotationParameters(ITestResult testResult, Parameters parametersAnnotation) {
	List<ParameterResource> params = Lists.newArrayList();
	String[] keys = parametersAnnotation.value();
	Object[] parameters = testResult.getParameters();
	if (parameters.length != keys.length) {
		return params;
	}
	for (int i = 0; i < keys.length; i++) {
		ParameterResource parameter = new ParameterResource();
		parameter.setKey(keys[i]);
		parameter.setValue(parameters[i] != null ? parameters[i].toString() : null);
		params.add(parameter);
	}
	return params;
}
 
開發者ID:reportportal,項目名稱:agent-java-testNG,代碼行數:23,代碼來源:TestNGService.java

示例9: createSuiteMessage

import org.testng.collections.Lists; //導入依賴的package包/類
public static SuiteMessage createSuiteMessage(final String message) {
  int type = getMessageType(message);
  String[] messageParts = parseMessage(message);

  SuiteMessage result = new SuiteMessage(messageParts[1],
                          MessageHelper.SUITE_START == type,
                          Integer.parseInt(messageParts[2]));
  // Any excluded methods?
  if (messageParts.length > 3) {
    int count = Integer.parseInt(messageParts[3]);
    if (count > 0) {
      List<String> methods = Lists.newArrayList();
      int i = 4;
      while (count-- > 0) {
        methods.add(messageParts[i++]);
      }
      result.setExcludedMethods(methods);
    }
  }

  return result;
}
 
開發者ID:testng-team,項目名稱:testng-remote,代碼行數:23,代碼來源:MessageHelper.java

示例10: tokenize

import org.testng.collections.Lists; //導入依賴的package包/類
private static String[] tokenize(final String message, final char separator) {
  if(null == message) {
    return new String[0];
  }

  List<String> tokens = Lists.newArrayList();
  int start = 0;
  for(int i = 0; i < message.length(); i++) {
    if(separator == message.charAt(i)) {
      tokens.add(message.substring(start, i));
      start = i + 1;
    }
  }
  if(start < message.length()) {
    tokens.add(message.substring(start, message.length()));
  }

  return tokens.toArray(new String[tokens.size()]);
}
 
開發者ID:testng-team,項目名稱:testng-remote,代碼行數:20,代碼來源:MessageHelper.java

示例11: runTest

import org.testng.collections.Lists; //導入依賴的package包/類
private void runTest(String arg, int portValue, IMessageSender sms) {
  p("Launching RemoteTestNG on port " + portValue);
  String protocol = null;
  if (sms instanceof JsonMessageSender) {
    protocol = "json";
  }
  launchRemoteTestNG(arg, portValue, protocol);
  MessageHub mh = new MessageHub(sms);
  List<String> received = Lists.newArrayList();
  try {
    mh.initReceiver();
    IMessage message = mh.receiveMessage();
    while (message != null) {
      received.add(message.getClass().getSimpleName());
      message = mh.receiveMessage();
    }

    Assert.assertEquals(received, EXPECTED_MESSAGES);
  }
  catch(SocketTimeoutException ex) {
    Assert.fail("Time out");
  }
}
 
開發者ID:testng-team,項目名稱:testng-remote,代碼行數:24,代碼來源:RemoteTest.java

示例12: testParseLogFiles

import org.testng.collections.Lists; //導入依賴的package包/類
@Test
public void testParseLogFiles() throws Exception
{
  // setup initial state
  File baseFolder = createBaseFolder();
  File folder = new File(baseFolder, "folder");
  Files.createDirectory(folder.toPath());
  File log1 = LogFileHelper.getValidRLLogFile("ranked.log");
  File log2 = LogFileHelper.getValidRLLogFile("mixed.log");
  Path path1 = Files.copy(log1.toPath(), new File(baseFolder, log1.getName()).toPath());
  Path path2 = Files.copy(log2.toPath(), new File(baseFolder, log2.getName()).toPath());

  List<File> files = Lists.newArrayList(baseFolder.listFiles());
  SortedSet<MatchResult> results = new TreeSet<>();

  ScanTask.parseLogFiles(files, results);

  assertEquals(results.size(), 15);

  Files.delete(path1);
  Files.delete(path2);
  Files.delete(folder.toPath());
  Files.delete(baseFolder.toPath());
}
 
開發者ID:trew,項目名稱:RankTracker,代碼行數:25,代碼來源:ScanTaskTest.java

示例13: benchmark

import org.testng.collections.Lists; //導入依賴的package包/類
@Test(groups = "efficiency")
@Parameters({"capacity", "passes", "generatorMultipler", "workingSetMultiplier"})
public void benchmark(int capacity, int passes, int generatorMultipler,
    int workingSetMultiplier) {
  Generator generator = new ScrambledZipfianGenerator(generatorMultipler * capacity);
  List<List<String>> workingSets = Lists.newArrayList();
  for (int i = 1; i <= passes; i++) {
    int size = i * workingSetMultiplier * capacity;
    workingSets.add(createWorkingSet(generator, size));
  }

  Set<Policy> seen = EnumSet.noneOf(Policy.class);
  for (CacheType cache : CacheType.values()) {
    if (!seen.add(cache.policy())) {
      continue;
    }
    Map<String, String> map = new CacheFactory()
        .maximumCapacity(capacity)
        .makeCache(cache);
    System.out.println(cache.policy().toString() + ":");
    for (List<String> workingSet : workingSets) {
      System.out.println(determineEfficiency(map, workingSet));
    }
  }
}
 
開發者ID:ben-manes,項目名稱:concurrentlinkedhashmap,代碼行數:26,代碼來源:EfficiencyBenchmark.java

示例14: testListCopyableVersions

import org.testng.collections.Lists; //導入依賴的package包/類
@Test
public void testListCopyableVersions() {
  Properties props = new Properties();
  Path dummyPath = new Path("dummy");
  DateTime dt1 = new DateTime().minusDays(8);
  DateTime dt2 = new DateTime().minusDays(6);

  props.put(SelectAfterTimeBasedPolicy.TIME_BASED_SELECTION_LOOK_BACK_TIME_KEY, "7d");
  SelectAfterTimeBasedPolicy policyLookback7Days = new SelectAfterTimeBasedPolicy(props);
  TimestampedDatasetVersion version1 = new TimestampedDatasetVersion(dt1, dummyPath);
  TimestampedDatasetVersion version2 = new TimestampedDatasetVersion(dt2, dummyPath);
  Assert.assertEquals(policyLookback7Days.listSelectedVersions(Lists.newArrayList(version1, version2)).size(), 1);

  props.put(SelectAfterTimeBasedPolicy.TIME_BASED_SELECTION_LOOK_BACK_TIME_KEY, "1h");
  SelectAfterTimeBasedPolicy policyLookback1Hour = new SelectAfterTimeBasedPolicy(props);
  Assert.assertEquals(policyLookback1Hour.listSelectedVersions(Lists.newArrayList(version1, version2)).size(), 0);

  props.put(SelectAfterTimeBasedPolicy.TIME_BASED_SELECTION_LOOK_BACK_TIME_KEY, "9d");
  SelectAfterTimeBasedPolicy policyLookback8Days = new SelectAfterTimeBasedPolicy(props);
  Assert.assertEquals(policyLookback8Days.listSelectedVersions(Lists.newArrayList(version1, version2)).size(), 2);
}
 
開發者ID:apache,項目名稱:incubator-gobblin,代碼行數:22,代碼來源:TimeBasedSelectionPolicyTest.java

示例15: testFailJobWhenPreviousStateExistsButDoesNotHaveSnapshot

import org.testng.collections.Lists; //導入依賴的package包/類
@Test
public void testFailJobWhenPreviousStateExistsButDoesNotHaveSnapshot() {
    try {
        DummyFileBasedSource source = new DummyFileBasedSource();

        WorkUnitState workUnitState = new WorkUnitState();
        workUnitState.setId("priorState");
        List<WorkUnitState> workUnitStates = Lists.newArrayList(workUnitState);

        State state = new State();
        state.setProp(ConfigurationKeys.EXTRACT_TABLE_TYPE_KEY, Extract.TableType.SNAPSHOT_ONLY.toString());
        state.setProp(ConfigurationKeys.SOURCE_FILEBASED_FS_PRIOR_SNAPSHOT_REQUIRED, true);

        SourceState sourceState = new SourceState(state, workUnitStates);

        source.getWorkunits(sourceState);
        Assert.fail("Expected RuntimeException, but no exceptions were thrown.");
    } catch (RuntimeException e) {
        Assert.assertEquals("No 'source.filebased.fs.snapshot' found on state of prior job",
            e.getMessage());
    }
}
 
開發者ID:apache,項目名稱:incubator-gobblin,代碼行數:23,代碼來源:FileBasedSourceTest.java


注:本文中的org.testng.collections.Lists類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。