コード例 #1
0
  @Test
  public void shouldProvideSeperatedLocksByKey() {
    long a = 1L;
    long b = 2L;
    long c = 3L;

    final int lockCount = 3;
    sut = new HashBasedMutexProvider(lockCount);

    assertThat(sut.get(a), is(not(sut.get(b))));
    assertThat(sut.get(b), is(not(sut.get(c))));
    assertThat(sut.get(c), is(not(sut.get(a))));
    assertThat(sut.get(a), is(sut.get(a)));
  }
コード例 #2
0
  @Test
  public void shouldProvideLocksBySpecialKey() {
    final int lockCount = 25;
    String key = "polygenelubricants";
    sut = new HashBasedMutexProvider(lockCount);

    assertThat(sut.get(key), is(notNullValue()));
  }