Source Code Cross Referenced for LongFPSetTestCase.java in  » Web-Crawler » heritrix » org » archive » util » fingerprint » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Crawler » heritrix » org.archive.util.fingerprint 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* LongFPSetTestCase
002:         *
003:         * $Id: LongFPSetTestCase.java 3437 2005-05-06 02:49:04Z stack-sf $
004:         *
005:         * Created Wed Jan 21 09:00:29 CET 2004
006:         *
007:         * Copyright (C) 2004 Internet Archive.
008:         *
009:         * This file is part of the Heritrix web crawler (crawler.archive.org).
010:         *
011:         * Heritrix is free software; you can redistribute it and/or modify
012:         * it under the terms of the GNU Lesser Public License as published by
013:         * the Free Software Foundation; either version 2.1 of the License, or
014:         * any later version.
015:         *
016:         * Heritrix is distributed in the hope that it will be useful,
017:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
018:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
019:         * GNU Lesser Public License for more details.
020:         *
021:         * You should have received a copy of the GNU Lesser Public License
022:         * along with Heritrix; if not, write to the Free Software
023:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
024:         */
025:
026:        package org.archive.util.fingerprint;
027:
028:        import junit.framework.TestCase;
029:
030:        /**
031:         * JUnit test suite for LongFPSet.  This is an abstract class which defines
032:         * the generic tests that test the {@link LongFPSet} interface.  Subclasses
033:         * may test specifics of {@link LongFPSet} subclass implementations
034:         *
035:         * @author <a href="mailto:me@jamesc.net">James Casey</a>
036:         * @version $ Id:$
037:         */
038:        abstract public class LongFPSetTestCase extends TestCase {
039:
040:            /** the unerlying FPSet we wish to test */
041:            private LongFPSet fpSet;
042:
043:            /**
044:             * Create a new LongFPSetTest object
045:             *
046:             * @param testName the name of the test
047:             */
048:            public LongFPSetTestCase(final String testName) {
049:                super (testName);
050:            }
051:
052:            public void setUp() {
053:                fpSet = makeLongFPSet();
054:            }
055:
056:            abstract LongFPSet makeLongFPSet();
057:
058:            /** check that we can add fingerprints */
059:            public void testAdd() {
060:                long l1 = (long) 1234;
061:                long l2 = (long) 2345;
062:
063:                assertEquals("empty set to start", 0, fpSet.count());
064:                assertTrue("set changed on addition of l1", fpSet.add(l1));
065:                assertTrue("set changed on addition of l2", fpSet.add(l2));
066:                assertFalse("set didn't change on re-addition of l1", fpSet
067:                        .add(l1));
068:            }
069:
070:            /** check we can call add/remove/contains() with 0 as a value */
071:            public void testWithZero() {
072:                long zero = (long) 0;
073:
074:                assertEquals("empty set to start", 0, fpSet.count());
075:                assertFalse("zero is not there", fpSet.contains(zero));
076:                assertTrue("zero added", fpSet.add(zero));
077:
078:                // now one element
079:                assertEquals("one fp in set", 1, fpSet.count());
080:                assertTrue("zero is the element", fpSet.contains(zero));
081:
082:                // and remove
083:                assertTrue("zero removed", fpSet.remove(zero));
084:                assertEquals("empty set again", 0, fpSet.count());
085:            }
086:
087:            /** check that contains() does what we expect */
088:            public void testContains() {
089:                long l1 = (long) 1234;
090:                long l2 = (long) 2345;
091:                long l3 = (long) 1334;
092:
093:                assertEquals("empty set to start", 0, fpSet.count());
094:                fpSet.add(l1);
095:                fpSet.add(l2);
096:
097:                assertTrue("contains l1", fpSet.contains(l1));
098:                assertTrue("contains l2", fpSet.contains(l2));
099:                assertFalse("does not contain l3", fpSet.contains(l3));
100:            }
101:
102:            /** test remove() works as expected */
103:            public void testRemove() {
104:                long l1 = (long) 1234;
105:
106:                assertEquals("empty set to start", 0, fpSet.count());
107:
108:                // remove before it's there
109:                assertFalse("fp not in set", fpSet.remove(l1));
110:                // now add
111:                fpSet.add(l1);
112:                // and remove again
113:                assertTrue("fp was in set", fpSet.remove(l1));
114:                // check set is empty again
115:                assertEquals("empty set again", 0, fpSet.count());
116:            }
117:
118:            /** check count works ok */
119:            public void testCount() {
120:                final int NUM = 1000;
121:                assertEquals("empty set to start", 0, fpSet.count());
122:
123:                for (int i = 1; i < NUM; ++i) {
124:                    fpSet.add((long) i);
125:                    assertEquals("correct num", i, fpSet.count());
126:                }
127:                for (int i = NUM - 1; i > 0; --i) {
128:                    fpSet.remove((long) i);
129:                    assertEquals("correct num", i - 1, fpSet.count());
130:                }
131:                assertEquals("empty set to start", 0, fpSet.count());
132:
133:            }
134:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.