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