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.rat.document.impl.guesser;
20  
21  import org.apache.rat.document.MockDocument;
22  import org.junit.Test;
23  
24  import static org.junit.Assert.assertTrue;
25  
26  public class ArchiveGuesserTest {
27  
28      @Test
29      public void matches() {
30          assertTrue(ArchiveGuesser.isArchive(new MockDocument("42.jar")));
31          assertTrue(ArchiveGuesser.isArchive(new MockDocument("42.tar.gz")));
32          assertTrue(ArchiveGuesser.isArchive(new MockDocument("42.zip")));
33          assertTrue(ArchiveGuesser.isArchive(new MockDocument("42.tar")));
34          assertTrue(ArchiveGuesser.isArchive(new MockDocument("42.bz")));
35          assertTrue(ArchiveGuesser.isArchive(new MockDocument("42.bz2")));
36          assertTrue(ArchiveGuesser.isArchive(new MockDocument("42.odb")));
37          assertTrue(ArchiveGuesser.isArchive(new MockDocument("42.odf")));
38          assertTrue(ArchiveGuesser.isArchive(new MockDocument("42.odg")));
39          assertTrue(ArchiveGuesser.isArchive(new MockDocument("42.odp")));
40          assertTrue(ArchiveGuesser.isArchive(new MockDocument("42.ods")));
41          assertTrue(ArchiveGuesser.isArchive(new MockDocument("42.odt")));
42          assertTrue(ArchiveGuesser.isArchive(new MockDocument("42.sar")));
43          assertTrue(ArchiveGuesser.isArchive(new MockDocument("42.har")));
44          assertTrue(ArchiveGuesser.isArchive(new MockDocument("42.wsr")));
45      }
46      
47      @Test
48      public void isArchive() {
49          assertTrue(ArchiveGuesser.isArchive("42.jar"));
50          assertTrue(ArchiveGuesser.isArchive("42.tar.gz"));
51          assertTrue(ArchiveGuesser.isArchive("42.zip"));
52          assertTrue(ArchiveGuesser.isArchive("42.tar"));
53          assertTrue(ArchiveGuesser.isArchive("42.bz"));
54          assertTrue(ArchiveGuesser.isArchive("42.bz2"));
55          assertTrue(ArchiveGuesser.isArchive("42.odb"));
56          assertTrue(ArchiveGuesser.isArchive("42.odf"));
57          assertTrue(ArchiveGuesser.isArchive("42.odg"));
58          assertTrue(ArchiveGuesser.isArchive("42.odp"));
59          assertTrue(ArchiveGuesser.isArchive("42.ods"));
60          assertTrue(ArchiveGuesser.isArchive("42.odt"));
61          assertTrue(ArchiveGuesser.isArchive("42.sar"));
62          assertTrue(ArchiveGuesser.isArchive("42.har"));
63          assertTrue(ArchiveGuesser.isArchive("42.wsr"));
64      }
65  
66  }