View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      https://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.commons.net.nntp;
19  
20  import static org.junit.jupiter.api.Assertions.assertNull;
21  
22  import java.util.Arrays;
23  import java.util.List;
24  
25  import org.junit.jupiter.api.Test;
26  
27  /**
28   * Test the Threader
29   */
30  class TestThreader {
31  
32      private static final Threadable[] EMPTY_THREADABLE_ARRAY = {};
33  
34      @SuppressWarnings("deprecation") // test of deprecated method
35      @Test
36      void testEmptyArray() { // NET-539
37          final Threader t = new Threader();
38          final Threadable[] messages = EMPTY_THREADABLE_ARRAY;
39          assertNull(t.thread(messages));
40      }
41  
42      @Test
43      void testEmptyIterable() { // NET-539
44          final Threader t = new Threader();
45          final Threadable[] messages = EMPTY_THREADABLE_ARRAY;
46          final Iterable<Threadable> asList = Arrays.asList(messages);
47          assertNull(t.thread(asList));
48      }
49  
50      @Test
51      void testEmptyList() { // NET-539
52          final Threader t = new Threader();
53          final Threadable[] messages = EMPTY_THREADABLE_ARRAY;
54          final List<Threadable> asList = Arrays.asList(messages);
55          assertNull(t.thread(asList));
56      }
57  
58      @Test
59      @SuppressWarnings("deprecation") // test of deprecated method
60      void testNullArray() { // NET-539
61          final Threader t = new Threader();
62          final Threadable[] messages = null;
63          assertNull(t.thread(messages));
64      }
65  
66      @Test
67      void testNullIterable() {
68          final Threader t = new Threader();
69          final Iterable<Threadable> messages = null;
70          assertNull(t.thread(messages));
71      }
72  
73      @Test
74      void testNullList() {
75          final Threader t = new Threader();
76          final List<Threadable> messages = null;
77          assertNull(t.thread(messages));
78      }
79  
80  }