SfcServicePathId { public static long check_and_allocate_pathid(long pathid) { if (SfcConcurrencyAPI.getPathIdLock()) { try { if (check_suitable_pathid(pathid) && allocate_pathid(pathid)) { return pathid; } else { return -1; } } finally { SfcConcurrencyAPI.releasePathIdLock(); } } else { return -1; } }  static int generatePathIdRandomIncrements(); static int generatePathIdSequentialIncrements(); static long check_and_allocate_pathid(long pathid); static long check_and_allocate_symmetric_pathid(long pathid); static long check_and_allocate_pathid(); static boolean check_suitable_pathid(long pathid); static boolean allocate_pathid(long pathid); static boolean free_pathid(long pathid); static GenerationAlgorithmEnum getGenerationAlgorithm(); static boolean setGenerationAlgorithm(int genAlgorithm); static boolean setGenerationAlgorithm(GenerationAlgorithmEnum genAlgorithm);  }
@Test public void testCheck_and_allocate_pathId() throws Exception { for (int i = 0; i < 20; i++) { final int pathId; pathId = SfcServicePathId.generatePathIdRandomIncrements(); assertNotEquals(-1, pathId); assertTrue(pathIdSet.add(pathId)); assertTrue(SfcServicePathId.allocate_pathid(pathId)); } for (Integer pathId : pathIdSet) { assertFalse(SfcServicePathId.check_suitable_pathid(pathId)); } for (Integer pathId : pathIdSet) { assertTrue(SfcServicePathId.free_pathid(pathId)); } pathIdSet.clear(); }