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.openflow.md.util.PollableQueuesZipper;
19 import com.google.common.collect.Lists;
22 * test for {@link PollableQueuesZipper}
24 public class PollableQueuesZipperTest {
27 * Test method for {@link org.opendaylight.openflowplugin.openflow.md.util.PollableQueuesZipper#poll()}.
30 public void testPoll() {
31 Queue<String> l1 = new LinkedBlockingQueue<String>(Lists.newArrayList("1", "2", "3"));
32 Queue<String> l2 = new LinkedBlockingQueue<String>(Lists.newArrayList("a", "b", "c", "d"));
33 Queue<String> l3 = new LinkedBlockingQueue<String>(Lists.newArrayList("A", "B"));
35 PollableQueuesZipper<String> zipper = new PollableQueuesZipper<>();
40 String[] expected = new String[] {
41 "1", "a", "A", "2", "b", "B", "3", "c", "d", null, "XXX"
43 List<String> result = new ArrayList<>();
45 String data = zipper.poll();
52 result.add(zipper.poll());
53 Assert.assertArrayEquals(expected, result.toArray());