コード例 #1
0
  @Test
  public void testInitSequence() {
    UIDSequencer seq = uidGeneratorService.getSequencer();

    seq.getNext("mySequence");
    seq.getNext("mySequence");

    seq.initSequence("mySequence", 1);
    assertTrue(seq.getNext("mySequence") > 1);
    seq.initSequence("mySequence", 10);
    assertTrue(seq.getNext("mySequence") > 10);
    assertTrue(seq.getNextLong("mySequence") > 10);
  }
コード例 #2
0
  @Test
  public void testIncrement() throws Exception {
    UIDSequencer seq = uidGeneratorService.getSequencer();
    assertNotNull(seq);
    assertTrue(seq.getClass().isAssignableFrom(ESUIDSequencer.class));

    assertEquals(1, seq.getNext("myseq"));
    assertEquals(2, seq.getNext("myseq"));
    assertEquals(3L, seq.getNextLong("myseq"));
    assertEquals(1, seq.getNext("myseq2"));
    assertEquals(4, seq.getNext("myseq"));
    assertEquals(2, seq.getNext("myseq2"));
  }