blob: ce6f3eafcf8ce0d1e8d8c1f20211a3abf215baeb [file] [log] [blame]
Sho SHIMIZUfc932d52014-08-15 11:22:37 -07001package net.onrc.onos.core.util;
Sho SHIMIZU9257b0c2014-08-13 15:00:10 -07002
Sho SHIMIZU9257b0c2014-08-13 15:00:10 -07003import org.junit.Test;
4
5import static org.hamcrest.Matchers.is;
6import static org.junit.Assert.*;
7
8/**
9 * Suites of test of {@link IdBlock}.
10 */
11public class IdBlockTest {
12
13 private final IdBlock sut = new IdBlock(0, 3);
14
15 /**
16 * Tests generated sequences. Also checks occurrence of {@link UnavailableIdException},
17 * when the number of generated IDs exceeds the block size.
18 */
19 @Test
20 public void basics() {
21 assertThat(sut.getNextId(), is(0L));
22 assertThat(sut.getNextId(), is(1L));
23 assertThat(sut.getNextId(), is(2L));
24
25 try {
26 sut.getNextId();
27 fail("UnavailableIdException should be thrown");
28 } catch (UnavailableIdException e) {
29 assertTrue(true);
30 }
31 }
32}