blob: 890f2c69d8941faf0a01288d8899267efcb592ed [file] [log] [blame]
Matteo Scandoloe033c262020-10-14 11:37:39 -07001/*
2 * Copyright 2017-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17package org.opencord.aaa.impl;
18
19import org.junit.After;
20import org.junit.Before;
21import org.junit.Test;
22import org.slf4j.Logger;
23
24import static org.junit.Assert.assertNotEquals;
25import static org.slf4j.LoggerFactory.getLogger;
26
27public class IdentifierManagerTest {
28
29 IdentifierManager idManager = null;
30 private final Logger log = getLogger(getClass());
31
32 @Before
33 public void setUp() {
34 System.out.print("Set up");
35 idManager = new IdentifierManager();
36 }
37
38 @After
39 public void tearDown() {
40 System.out.print("Tear down");
41 idManager = null;
42 }
43
44 @Test
45 /**
46 * Make sure that we never get ID 1 or 0 as they are reserved for RadiusOperationalStatusManager
47 */
48 public void testIdSequence() {
49 for (int i = 1; i <= 300; i++) {
50 RequestIdentifier id = idManager.getNewIdentifier(Integer.toString(i));
51 log.trace("Id: {}", id.identifier() & 0xff);
52 assertNotEquals(id.identifier(), 0);
53 assertNotEquals(id.identifier(), 1);
54 idManager.releaseIdentifier(id);
55 }
56 }
57}