コード例 #1
0
  @Test
  public void testSimple_100_0() {
    updateAllocations(RANGES_100_0);
    final StandardTestChooser rtc = newChooser();

    final Map<String, Object> values = Collections.emptyMap();
    for (int i = 0; i < 100; i++) {
      final TestBucket chosen = rtc.choose(String.valueOf(i), values);
      assertNotNull(chosen);
      assertEquals(1, chosen.getValue());
    }
  }
コード例 #2
0
  private void exerciseChooser(final StandardTestChooser rtc) {
    final int num = 10000000;

    final Map<String, Object> values = Collections.emptyMap();
    for (int accountId = 1; accountId < num; accountId++) { // deliberately skipping 0
      final TestBucket chosen = rtc.choose(String.valueOf(accountId), values);
      assertNotNull(chosen);

      counts[chosen.getValue()]++;
      hashes[chosen.getValue()] = 31 * hashes[chosen.getValue()] + accountId;
    }
  }