blob: 2286ec46aeeae01ddffc5acb27191d58bb4e708f [file] [log] [blame]
Madan Jampani7a7ef6d2016-01-26 22:01:13 -08001/*
2 * Copyright 2016 Open Networking Laboratory
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 */
16package org.onlab.util;
17
18import static org.junit.Assert.*;
19
20import java.util.concurrent.atomic.AtomicBoolean;
21
22import org.junit.Test;
23
24/**
25 * Unit tests for CountDownCompleter.
26 */
27public class CountDownCompleterTest {
28
29 @Test
30 public void testCountDown() {
31 AtomicBoolean callbackInvoked = new AtomicBoolean(false);
32 CountDownCompleter<String> completer = new CountDownCompleter<>("foo", 2L, v -> callbackInvoked.set(true));
33 completer.countDown();
34 assertFalse(callbackInvoked.get());
35 assertFalse(completer.isComplete());
36 completer.countDown();
37 assertTrue(callbackInvoked.get());
38 assertTrue(completer.isComplete());
39 }
40}