View Javadoc

    1   /* LongFPSetCacheTest
    2    *
    3    * $Id: LongFPSetCacheTest.java 3437 2005-05-06 02:49:04Z stack-sf $
    4    *
    5    * Created Wed Jan 21 09:00:29 CET 2004
    6    *
    7    *  Copyright (C) 2004 Internet Archive.
    8    *
    9    * This file is part of the Heritrix web crawler (crawler.archive.org).
    10   *
    11   * Heritrix is free software; you can redistribute it and/or modify
    12   * it under the terms of the GNU Lesser Public License as published by
    13   * the Free Software Foundation; either version 2.1 of the License, or
    14   * any later version.
    15   *
    16   * Heritrix is distributed in the hope that it will be useful,
    17   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19   * GNU Lesser Public License for more details.
    20   *
    21   * You should have received a copy of the GNU Lesser Public License
    22   * along with Heritrix; if not, write to the Free Software
    23   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    24   */
    25
    26  package org.archive.util.fingerprint;
    27
    28  import junit.framework.Test;
    29  import junit.framework.TestSuite;
    30
    31  /***
    32   * JUnit test suite for LongFPSetCache
    33   *
    34   * @author <a href="mailto:me@jamesc.net">James Casey</a>
    35   * @version $ Id:$
    36   */
    37  public class LongFPSetCacheTest extends LongFPSetTestCase {
    38      /***
    39       * Create a new LongFPSetCacheTest object
    40       *
    41       * @param testName the name of the test
    42       */
    43      public LongFPSetCacheTest(final String testName) {
    44          super(testName);
    45      }
    46
    47      /***
    48       * run all the tests for LongFPSetCacheTest
    49       *
    50       * @param argv the command line arguments
    51       */
    52      public static void main(String argv[]) {
    53          junit.textui.TestRunner.run(suite());
    54      }
    55
    56      /***
    57       * return the suite of tests for LongFPSetCacheTest
    58       *
    59       * @return the suite of test
    60       */
    61      public static Test suite() {
    62          return new TestSuite(LongFPSetCacheTest.class);
    63      }
    64
    65      LongFPSet makeLongFPSet() {
    66          return new LongFPSetCache();
    67      }
    68
    69      /***
    70       *  This is a cache buffer, which does not grow,
    71       * but chucks out old values.  Therefore it has a different behaviour
    72       * from all the other LongFPSets.  We do a different test here.
    73       */
    74
    75      public void testCount() {
    76          LongFPSet fpSet = new LongFPSetCache();
    77          // TODO: for some reason, when run in a debugger,
    78          // the cache-item-discard is glacially slow. It's
    79          // reasonable when executing.) So, reducing the
    80          // number of past-saturation tests in order to let
    81          // full-unit-tests complete more quickly.
    82          final int NUM = 800; // was 1000
    83          final int MAX_ENTRIES = 768;
    84
    85          assertEquals("empty set to start", 0, fpSet.count());
    86
    87          for (int i = 1; i < NUM; ++i) {
    88              fpSet.add((long) i);
    89              assertEquals("correct num on add",
    90                      i<MAX_ENTRIES?i:MAX_ENTRIES, fpSet.count());
    91          }
    92      }
    93
    94      // TODO - implement test methods in LongFPSetCacheTest
    95  }
    96