2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.openflowplugin.openflow.md.util;
10 import java.util.ArrayList;
11 import java.util.List;
12 import java.util.Queue;
13 import java.util.concurrent.LinkedBlockingQueue;
15 import org.junit.Assert;
16 import org.junit.Test;
17 import org.opendaylight.openflowplugin.api.openflow.md.util.PollableQueuesPriorityZipper;
19 import com.google.common.collect.Lists;
22 * test for {@link PollableQueuesPriorityZipper}
24 public class PollableQueuesPriorityZipperTest {
28 * {@link org.opendaylight.openflowplugin.api.openflow.md.util.PollableQueuesPriorityZipper#poll()}
32 public void testPoll3() {
33 Queue<String> l1 = new LinkedBlockingQueue<String>(Lists.newArrayList(
35 Queue<String> l2 = new LinkedBlockingQueue<String>(Lists.newArrayList(
37 Queue<String> l3 = new LinkedBlockingQueue<String>(Lists.newArrayList(
40 PollableQueuesPriorityZipper<String> zipper = new PollableQueuesPriorityZipper<>();
41 zipper.setPrioritizedSource(l1);
45 String[] expected = new String[] { "1", "2", "3", "a", "A", "b", "B",
46 "c", "d", null, "XXX" };
47 List<String> result = new ArrayList<>();
49 String data = zipper.poll();
56 result.add(zipper.poll());
57 Assert.assertArrayEquals(expected, result.toArray());
62 * {@link org.opendaylight.openflowplugin.api.openflow.md.util.PollableQueuesPriorityZipper#poll()}
66 public void testPoll2() {
67 Queue<String> l1 = new LinkedBlockingQueue<String>(Lists.newArrayList(
69 Queue<String> l3 = new LinkedBlockingQueue<String>(Lists.newArrayList(
72 PollableQueuesPriorityZipper<String> zipper = new PollableQueuesPriorityZipper<>();
73 zipper.setPrioritizedSource(l1);
76 String[] expected = new String[] { "1", "2", "3", "A", "B", null, "XXX" };
77 List<String> result = new ArrayList<>();
79 String data = zipper.poll();
86 result.add(zipper.poll());
87 Assert.assertArrayEquals(expected, result.toArray());