View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.plugins.ejb;
20  
21  import java.util.Arrays;
22  import java.util.Collections;
23  
24  import org.junit.Test;
25  
26  import static org.junit.Assert.assertArrayEquals;
27  
28  public class IncludesExcludesTest {
29  
30      @Test
31      public void emptyListsShouldResultInZeroSizeResults() {
32          IncludesExcludes ie = new IncludesExcludes(
33                  Collections.<String>emptyList(), Collections.<String>emptyList(),
34                  Collections.<String>emptyList(), Collections.<String>emptyList());
35  
36          assertArrayEquals(new String[0], ie.resultingIncludes());
37          assertArrayEquals(new String[0], ie.resultingExcludes());
38      }
39  
40      @Test
41      public void nullForIncludesShouldResultInZeroSizeResults() {
42          IncludesExcludes ie = new IncludesExcludes(
43                  null,
44                  Collections.<String>emptyList(),
45                  Collections.<String>emptyList(),
46                  Collections.<String>emptyList());
47  
48          assertArrayEquals(new String[0], ie.resultingIncludes());
49          assertArrayEquals(new String[0], ie.resultingExcludes());
50      }
51  
52      @Test
53      public void nullForExcludesShouldResultInZeroSizeResults() {
54          IncludesExcludes ie = new IncludesExcludes(
55                  Collections.<String>emptyList(),
56                  null,
57                  Collections.<String>emptyList(),
58                  Collections.<String>emptyList());
59  
60          assertArrayEquals(new String[0], ie.resultingIncludes());
61          assertArrayEquals(new String[0], ie.resultingExcludes());
62      }
63  
64      @Test
65      public void nonNullForDefaultExcludesShouldResultInExcludesWithDefaultExcludes() {
66          IncludesExcludes ie =
67                  new IncludesExcludes(null, null, Collections.<String>emptyList(), Arrays.asList("**/package.html"));
68  
69          assertArrayEquals(new String[0], ie.resultingIncludes());
70          assertArrayEquals(new String[] {"**/package.html"}, ie.resultingExcludes());
71      }
72  
73      @Test
74      public void nonNullForDefaultIncludesShouldResultInIncludesWithDefaultIncludes() {
75          IncludesExcludes ie =
76                  new IncludesExcludes(null, null, Arrays.asList("**/package.html"), Collections.<String>emptyList());
77  
78          assertArrayEquals(new String[] {"**/package.html"}, ie.resultingIncludes());
79          assertArrayEquals(new String[0], ie.resultingExcludes());
80      }
81  
82      @Test
83      public void nonNullIncludesShouldResultInTheSameIncludes() {
84          IncludesExcludes ie = new IncludesExcludes(
85                  Arrays.asList("**/package.html"), null,
86                  Arrays.asList("**/site.html"), null);
87  
88          assertArrayEquals(new String[] {"**/package.html"}, ie.resultingIncludes());
89      }
90  
91      @Test
92      public void nonNullExcludesShouldResultInTheSameExcludes() {
93          IncludesExcludes ie = new IncludesExcludes(
94                  null, Arrays.asList("**/package.html"),
95                  null, Arrays.asList("**/site.html"));
96  
97          assertArrayEquals(new String[] {"**/package.html"}, ie.resultingExcludes());
98      }
99  }