    1   /*
    2    * FilePatternFilterTest
    3    *
    4    * $Id: FilePatternFilterTest.java 4652 2006-09-25 18:41:10Z paul_jack $
    5    *
    6    * Created on Mar 11, 2004
    7    *
    8    * Copyright (C) 2004 Internet Archive.
    9    *
    10   * This file is part of the Heritrix web crawler (crawler.archive.org).
    11   *
    12   * Heritrix is free software; you can redistribute it and/or modify
    13   * it under the terms of the GNU Lesser Public License as published by
    14   * the Free Software Foundation; either version 2.1 of the License, or
    15   * any later version.
    16   *
    17   * Heritrix is distributed in the hope that it will be useful,
    18   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    19   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    20   * GNU Lesser Public License for more details.
    21   *
    22   * You should have received a copy of the GNU Lesser Public License
    23   * along with Heritrix; if not, write to the Free Software
    24   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    25   */
    26
    27  package org.archive.crawler.filter;
    28
    29  import junit.framework.TestCase;
    30
    31  /***
    32   * Tests FilePatternFilter default pattern (all default file extension) and
    33   * separate subgroups patterns such as images, audio, video, and
    34   * miscellaneous groups.
    35   *
    36   * @author Igor Ranitovic
    37   * @deprecated  The tested class is deprecated, so this test
    38   * will eventually go away
    39   */
    40  public class FilePatternFilterTest extends TestCase {
    41          FilePatternFilter filter = new FilePatternFilter("File Pattern Filter");
    42
    43      /***
    44       * Tests FilePatternFilter default pattern (all default file extension) and
    45       * separate subgroups patterns such as images, audio, video, and
    46       * miscellaneous groups.
    47       *
    48       */
    49      public final void testPatterns() {
    50
    51         String stringURI = "http://foo.boo/moo.avi";
    52         assertTrue(filter.accepts(stringURI));
    53         assertTrue(stringURI.matches(FilePatternFilter.VIDEO_PATTERNS));
    54         stringURI.toUpperCase();
    55         assertTrue(filter.accepts(stringURI));
    56         assertTrue(stringURI.matches(FilePatternFilter.VIDEO_PATTERNS));
    57
    58         stringURI = "http://foo.boo/moo.bmp";
    59         assertTrue(filter.accepts(stringURI));
    60         assertTrue(stringURI.matches(FilePatternFilter.IMAGES_PATTERNS));
    61         stringURI.toUpperCase();
    62         assertTrue(filter.accepts(stringURI));
    63         assertTrue(stringURI.matches(FilePatternFilter.IMAGES_PATTERNS));
    64
    65         stringURI = "http://foo.boo/moo.doc";
    66         assertTrue(filter.accepts(stringURI));
    67         assertTrue(stringURI.matches(FilePatternFilter.MISC_PATTERNS));
    68         stringURI.toUpperCase();
    69         assertTrue(filter.accepts(stringURI));
    70         assertTrue(stringURI.matches(FilePatternFilter.MISC_PATTERNS));
    71
    72         stringURI = "http://foo.boo/moo.gif";
    73         assertTrue(filter.accepts(stringURI));
    74         assertTrue(stringURI.matches(FilePatternFilter.IMAGES_PATTERNS));
    75         stringURI.toUpperCase();
    76         assertTrue(filter.accepts(stringURI));
    77         assertTrue(stringURI.matches(FilePatternFilter.IMAGES_PATTERNS));
    78
    79         stringURI = "http://foo.boo/moo.jpg";
    80         assertTrue(filter.accepts(stringURI));
    81         assertTrue(stringURI.matches(FilePatternFilter.IMAGES_PATTERNS));
    82         stringURI.toUpperCase();
    83         assertTrue(filter.accepts(stringURI));
    84         assertTrue(stringURI.matches(FilePatternFilter.IMAGES_PATTERNS));
    85
    86         stringURI = "http://foo.boo/moo.jpeg";
    87         assertTrue(filter.accepts(stringURI));
    88         assertTrue(stringURI.matches(FilePatternFilter.IMAGES_PATTERNS));
    89         stringURI.toUpperCase();
    90         assertTrue(filter.accepts(stringURI));
    91         assertTrue(stringURI.matches(FilePatternFilter.IMAGES_PATTERNS));
    92
    93         stringURI = "http://foo.boo/moo.mid";
    94         assertTrue(filter.accepts(stringURI));
    95         assertTrue(stringURI.matches(FilePatternFilter.AUDIO_PATTERNS));
    96         stringURI.toUpperCase();
    97         assertTrue(filter.accepts(stringURI));
    98         assertTrue(stringURI.matches(FilePatternFilter.AUDIO_PATTERNS));
    99
    100        stringURI = "http://foo.boo/moo.mov";
    101        assertTrue(filter.accepts(stringURI));
    102        assertTrue(stringURI.matches(FilePatternFilter.VIDEO_PATTERNS));
    103        stringURI.toUpperCase();
    104        assertTrue(filter.accepts(stringURI));
    105        assertTrue(stringURI.matches(FilePatternFilter.VIDEO_PATTERNS));
    106
    107        stringURI = "http://foo.boo/moo.mp2";
    108        assertTrue(filter.accepts(stringURI));
    109        assertTrue(stringURI.matches(FilePatternFilter.AUDIO_PATTERNS));
    110        stringURI.toUpperCase();
    111        assertTrue(filter.accepts(stringURI));
    112        assertTrue(stringURI.matches(FilePatternFilter.AUDIO_PATTERNS));
    113
    114        stringURI = "http://foo.boo/moo.mp3";
    115        assertTrue(filter.accepts(stringURI));
    116        assertTrue(stringURI.matches(FilePatternFilter.AUDIO_PATTERNS));
    117        stringURI.toUpperCase();
    118        assertTrue(filter.accepts(stringURI));
    119        assertTrue(stringURI.matches(FilePatternFilter.AUDIO_PATTERNS));
    120
    121        stringURI = "http://foo.boo/moo.mp4";
    122        assertTrue(filter.accepts(stringURI));
    123        assertTrue(stringURI.matches(FilePatternFilter.AUDIO_PATTERNS));
    124        stringURI.toUpperCase();
    125        assertTrue(filter.accepts(stringURI));
    126        assertTrue(stringURI.matches(FilePatternFilter.AUDIO_PATTERNS));
    127
    128        stringURI = "http://foo.boo/moo.mpeg";
    129        assertTrue(filter.accepts(stringURI));
    130        assertTrue(stringURI.matches(FilePatternFilter.VIDEO_PATTERNS));
    131        stringURI.toUpperCase();
    132        assertTrue(filter.accepts(stringURI));
    133        assertTrue(stringURI.matches(FilePatternFilter.VIDEO_PATTERNS));
    134
    135        stringURI = "http://foo.boo/moo.pdf";
    136        assertTrue(filter.accepts(stringURI));
    137        assertTrue(stringURI.matches(FilePatternFilter.MISC_PATTERNS));
    138        stringURI.toUpperCase();
    139        assertTrue(filter.accepts(stringURI));
    140        assertTrue(stringURI.matches(FilePatternFilter.MISC_PATTERNS));
    141
    142        stringURI = "http://foo.boo/moo.png";
    143        assertTrue(filter.accepts(stringURI));
    144        assertTrue(stringURI.matches(FilePatternFilter.IMAGES_PATTERNS));
    145        stringURI.toUpperCase();
    146        assertTrue(filter.accepts(stringURI));
    147        assertTrue(stringURI.matches(FilePatternFilter.IMAGES_PATTERNS));
    148
    149        stringURI = "http://foo.boo/moo.ppt";
    150        assertTrue(filter.accepts(stringURI));
    151        assertTrue(stringURI.matches(FilePatternFilter.MISC_PATTERNS));
    152        stringURI.toUpperCase();
    153        assertTrue(filter.accepts(stringURI));
    154        assertTrue(stringURI.matches(FilePatternFilter.MISC_PATTERNS));
    155
    156        stringURI = "http://foo.boo/moo.ram";
    157        assertTrue(filter.accepts(stringURI));
    158        assertTrue(stringURI.matches(FilePatternFilter.VIDEO_PATTERNS));
    159        stringURI.toUpperCase();
    160        assertTrue(filter.accepts(stringURI));
    161        assertTrue(stringURI.matches(FilePatternFilter.VIDEO_PATTERNS));
    162
    163        stringURI = "http://foo.boo/moo.rm";
    164        assertTrue(filter.accepts(stringURI));
    165        stringURI.toUpperCase();
    166        assertTrue(filter.accepts(stringURI));
    167
    168        stringURI = "http://foo.boo/moo.smil";
    169        assertTrue(filter.accepts(stringURI));
    170        assertTrue(stringURI.matches(FilePatternFilter.VIDEO_PATTERNS));
    171        stringURI.toUpperCase();
    172        assertTrue(filter.accepts(stringURI));
    173        assertTrue(stringURI.matches(FilePatternFilter.VIDEO_PATTERNS));
    174
    175        stringURI = "http://foo.boo/moo.swf";
    176        assertTrue(filter.accepts(stringURI));
    177        assertTrue(stringURI.matches(FilePatternFilter.MISC_PATTERNS));
    178        stringURI.toUpperCase();
    179        assertTrue(filter.accepts(stringURI));
    180        assertTrue(stringURI.matches(FilePatternFilter.MISC_PATTERNS));
    181
    182        stringURI = "http://foo.boo/moo.tif";
    183        assertTrue(filter.accepts(stringURI));
    184        assertTrue(stringURI.matches(FilePatternFilter.IMAGES_PATTERNS));
    185        stringURI.toUpperCase();
    186        assertTrue(filter.accepts(stringURI));
    187        assertTrue(stringURI.matches(FilePatternFilter.IMAGES_PATTERNS));
    188
    189        stringURI = "http://foo.boo/moo.tiff";
    190        assertTrue(filter.accepts(stringURI));
    191        assertTrue(stringURI.matches(FilePatternFilter.IMAGES_PATTERNS));
    192        stringURI.toUpperCase();
    193        assertTrue(filter.accepts(stringURI));
    194        assertTrue(stringURI.matches(FilePatternFilter.IMAGES_PATTERNS));
    195
    196        stringURI = "http://foo.boo/moo.wav";
    197        assertTrue(filter.accepts(stringURI));
    198        assertTrue(stringURI.matches(FilePatternFilter.AUDIO_PATTERNS));
    199        stringURI.toUpperCase();
    200        assertTrue(filter.accepts(stringURI));
    201        assertTrue(stringURI.matches(FilePatternFilter.AUDIO_PATTERNS));
    202
    203        stringURI = "http://foo.boo/moo.wmv";
    204        assertTrue(filter.accepts(stringURI));
    205        assertTrue(stringURI.matches(FilePatternFilter.VIDEO_PATTERNS));
    206        stringURI.toUpperCase();
    207        assertTrue(filter.accepts(stringURI));
    208        assertTrue(stringURI.matches(FilePatternFilter.VIDEO_PATTERNS));
    209
    210        stringURI = "http://foo.boo/moo.asf";
    211        assertFalse(filter.accepts(stringURI));
    212        assertFalse(stringURI.matches(FilePatternFilter.MISC_PATTERNS));
    213        stringURI.toUpperCase();
    214        assertFalse(filter.accepts(stringURI));
    215        assertFalse(stringURI.matches(FilePatternFilter.MISC_PATTERNS));
    216
    217     }
    218 }