示例#1
0
  @GwtIncompatible("too slow")
  public void testCombinationsExhaustively_startingFromArbitrary() {
    Ordering<Object> arbitrary = Ordering.arbitrary();
    Object[] array = {1, "foo", new Object()};

    // There's no way to tell what the order should be except empirically
    Arrays.sort(array, arbitrary);
    testExhaustively(arbitrary, array);
  }
  /**
   * @param executorService the {@link ScheduledExecutorService} to provide the threads that execute
   *     the operations for reliability.
   */
  public IncomingMessageReliabilityHandler(ScheduledExecutorService executorService) {
    this.shutdown = false;
    this.emptyAcknowledgementSchedule =
        TreeMultimap.create(
            Ordering.<Long>natural(), Ordering.<IncomingReliableMessageExchange>arbitrary());

    this.ongoingMessageExchanges = HashBasedTable.create();

    executorService.scheduleAtFixedRate(
        new ReliabilityTask(),
        RELIABILITY_TASK_PERIOD_MILLIS,
        RELIABILITY_TASK_PERIOD_MILLIS,
        TimeUnit.MILLISECONDS);
  }
示例#3
0
  // A more limited test than the one that follows, but this one uses the
  // actual public API.
  public void testArbitrary_withoutCollisions() {
    List<Object> list = Lists.newArrayList();
    for (int i = 0; i < 50; i++) {
      list.add(new Object());
    }

    Ordering<Object> arbitrary = Ordering.arbitrary();
    Collections.sort(list, arbitrary);

    // Now we don't care what order it's put the list in, only that
    // comparing any pair of elements gives the answer we expect.
    Helpers.testComparator(arbitrary, list);

    assertEquals("Ordering.arbitrary()", arbitrary.toString());
  }
示例#4
0
  private void identifyDuplicates(List<ModContainer> mods) {
    TreeMultimap<ModContainer, File> dupsearch =
        TreeMultimap.create(new ModIdComparator(), Ordering.arbitrary());
    for (ModContainer mc : mods) {
      if (mc.getSource() != null) {
        dupsearch.put(mc, mc.getSource());
      }
    }

    ImmutableMultiset<ModContainer> duplist = Multisets.copyHighestCountFirst(dupsearch.keys());
    SetMultimap<ModContainer, File> dupes = LinkedHashMultimap.create();
    for (Entry<ModContainer> e : duplist.entrySet()) {
      if (e.getCount() > 1) {
        FMLLog.severe(
            "Found a duplicate mod %s at %s",
            e.getElement().getModId(), dupsearch.get(e.getElement()));
        dupes.putAll(e.getElement(), dupsearch.get(e.getElement()));
      }
    }
    if (!dupes.isEmpty()) {
      throw new DuplicateModsFoundException(dupes);
    }
  }