BAEL-6264 added class to show how to instantiate ArrayBlockingQueue a… (#13851)
* BAEL-6264 added class to show how to instantiate ArrayBlockingQueue and LinkedBlockingQueue * BAEL-6264 added unit test case * modified test case * BAEL-6264 deleted BlockingQueueImplExample file not needed anymore * BAEL-6264 code review changes moved class file to different module --------- Co-authored-by: Vartika_Nigam <Vartika_Nigam@DellTeam.com>
This commit is contained in:
parent
535d967fd9
commit
e1272ca8fe
|
@ -0,0 +1,26 @@
|
|||
package com.baeldung.concurrent.queue;
|
||||
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class BlockingQueueUnitTest {
|
||||
|
||||
@Test
|
||||
public void givenArrayBlockingQueue_whenAddedElements_thenReturnQueueRemainingCapacity() {
|
||||
BlockingQueue<String> arrayBlockingQueue = new ArrayBlockingQueue<>(10);
|
||||
arrayBlockingQueue.add("TestString1");
|
||||
arrayBlockingQueue.add("TestString2");
|
||||
assertEquals(8, arrayBlockingQueue.remainingCapacity());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenLinkedBlockingQueue_whenAddedElements_thenReturnQueueRemainingCapacity() {
|
||||
BlockingQueue<String> linkedBlockingQueue = new LinkedBlockingQueue<>(10);
|
||||
linkedBlockingQueue.add("TestString1");
|
||||
assertEquals(9, linkedBlockingQueue.remainingCapacity());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue