Source Code Cross Referenced for RobotsTXTLineTest.java in  » Web-Crawler » jspider » net » javacoding » jspider » core » util » html » 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 » jspider » net.javacoding.jspider.core.util.html 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.javacoding.jspider.core.util.html;
002:
003:        import junit.framework.TestCase;
004:
005:        import java.net.URL;
006:
007:        /**
008:         * $Id: RobotsTXTLineTest.java,v 1.1 2003/02/11 17:33:04 vanrogu Exp $
009:         */
010:        public class RobotsTXTLineTest extends TestCase {
011:
012:            public RobotsTXTLineTest() {
013:                super ("RobotsTXTLineTest");
014:            }
015:
016:            public void testSimpleAllow() {
017:                RobotsTXTLine l = RobotsTXTLine.parse("allow: index.html");
018:
019:                assertNotNull("line returned for correct info is null", l);
020:
021:                String resource = l.getResourceURI();
022:                int type = l.getType();
023:
024:                assertEquals("type parsed incorrect",
025:                        RobotsTXTLine.ROBOTSTXT_RULE_ALLOW, type);
026:                assertEquals("resourceURI parsed incorrect", "index.html",
027:                        resource);
028:
029:            }
030:
031:            public void testSimpleAllowCaseSensitivity() {
032:                RobotsTXTLine l = RobotsTXTLine.parse("AlLoW: index.html");
033:
034:                assertNotNull("line returned for correct info is null", l);
035:
036:                String resource = l.getResourceURI();
037:                int type = l.getType();
038:
039:                assertEquals("type parsed incorrect",
040:                        RobotsTXTLine.ROBOTSTXT_RULE_ALLOW, type);
041:                assertEquals("resourceURI parsed incorrect", "index.html",
042:                        resource);
043:
044:            }
045:
046:            public void testSimpleDisallow() {
047:                RobotsTXTLine l = RobotsTXTLine.parse("disallow: index.html");
048:
049:                assertNotNull("line returned for correct info is null", l);
050:
051:                String resource = l.getResourceURI();
052:                int type = l.getType();
053:
054:                assertEquals("type parsed incorrect",
055:                        RobotsTXTLine.ROBOTSTXT_RULE_DISALLOW, type);
056:                assertEquals("resourceURI parsed incorrect", "index.html",
057:                        resource);
058:
059:            }
060:
061:            public void testSimpleDisallowCaseSensitivity() {
062:                RobotsTXTLine l = RobotsTXTLine.parse("dIsAlLoW: index.html");
063:
064:                assertNotNull("line returned for correct info is null", l);
065:
066:                String resource = l.getResourceURI();
067:                int type = l.getType();
068:
069:                assertEquals("type parsed incorrect",
070:                        RobotsTXTLine.ROBOTSTXT_RULE_DISALLOW, type);
071:                assertEquals("resourceURI parsed incorrect", "index.html",
072:                        resource);
073:
074:            }
075:
076:            public void testSimpleAllowWithoutSpace() {
077:                RobotsTXTLine l = RobotsTXTLine.parse("allow:index.html");
078:
079:                assertNotNull("line returned for correct info is null", l);
080:
081:                String resource = l.getResourceURI();
082:                int type = l.getType();
083:
084:                assertEquals("type parsed incorrect",
085:                        RobotsTXTLine.ROBOTSTXT_RULE_ALLOW, type);
086:                assertEquals("resourceURI parsed incorrect", "index.html",
087:                        resource);
088:
089:            }
090:
091:            public void testSimpleDisallowWithoutSpace() {
092:                RobotsTXTLine l = RobotsTXTLine.parse("disallow:index.html");
093:
094:                assertNotNull("line returned for correct info is null", l);
095:
096:                String resource = l.getResourceURI();
097:                int type = l.getType();
098:
099:                assertEquals("type parsed incorrect",
100:                        RobotsTXTLine.ROBOTSTXT_RULE_DISALLOW, type);
101:                assertEquals("resourceURI parsed incorrect", "index.html",
102:                        resource);
103:
104:            }
105:
106:            public void testErroneousAllowDisallow() {
107:                RobotsTXTLine l = RobotsTXTLine.parse("alow:index.html");
108:                assertNull("line returned for incorrect info is not null", l);
109:            }
110:
111:            public void testEmptyString() {
112:                RobotsTXTLine l = RobotsTXTLine.parse("");
113:                assertNull("line returned for empty string is not null", l);
114:            }
115:
116:            public void testOnlyAllow() {
117:                RobotsTXTLine l = RobotsTXTLine.parse("allow:");
118:                assertNull("line returned for 'allow:' string is not null", l);
119:            }
120:
121:            public void testOnlyDisAllow() {
122:                RobotsTXTLine l = RobotsTXTLine.parse("disallow:");
123:                assertNull("line returned for 'disallow:' string is not null",
124:                        l);
125:            }
126:
127:            public void testNullString() {
128:                RobotsTXTLine l = RobotsTXTLine.parse(null);
129:                assertNull("line returned for null string is not null", l);
130:            }
131:
132:            public void testSimpleMatch() throws Exception {
133:                URL url = new URL("http://j-spider.sourceforge.net/index.html");
134:                RobotsTXTLine line = new RobotsTXTLine("/index.html",
135:                        RobotsTXTLine.ROBOTSTXT_RULE_DISALLOW);
136:                boolean matches = line.matches(url);
137:
138:                assertTrue("simple match didn't work", matches);
139:            }
140:
141:            public void testSimpleMatchWithFolder() throws Exception {
142:                URL url = new URL(
143:                        "http://j-spider.sourceforge.net/manual/index.html");
144:                RobotsTXTLine line = new RobotsTXTLine("/manual",
145:                        RobotsTXTLine.ROBOTSTXT_RULE_DISALLOW);
146:                boolean matches = line.matches(url);
147:
148:                assertTrue("simple match didn't work", matches);
149:            }
150:
151:            public void testSimpleMatchCaseSensitivity() throws Exception {
152:                URL url = new URL("http://j-spider.sourceforge.net/index.HTML");
153:                RobotsTXTLine line = new RobotsTXTLine("/index.html",
154:                        RobotsTXTLine.ROBOTSTXT_RULE_DISALLOW);
155:                boolean matches = line.matches(url);
156:
157:                assertFalse("cases were different, yet a match was given",
158:                        matches);
159:            }
160:
161:            public void testSimpleNoMatch() throws Exception {
162:                URL url = new URL("http://j-spider.sourceforge.net/index.htm");
163:                RobotsTXTLine line = new RobotsTXTLine("/index.html",
164:                        RobotsTXTLine.ROBOTSTXT_RULE_DISALLOW);
165:                boolean matches = line.matches(url);
166:
167:                assertFalse("simple nomatch didn't work", matches);
168:            }
169:
170:            public void testRootMatch() throws Exception {
171:                URL url = new URL("http://j-spider.sourceforge.net");
172:                RobotsTXTLine line = new RobotsTXTLine("/",
173:                        RobotsTXTLine.ROBOTSTXT_RULE_DISALLOW);
174:                boolean matches = line.matches(url);
175:
176:                assertTrue("root match didn't work", matches);
177:            }
178:
179:            public void testRootMatchWithTrailingSlash() throws Exception {
180:                URL url = new URL("http://j-spider.sourceforge.net/");
181:                RobotsTXTLine line = new RobotsTXTLine("/",
182:                        RobotsTXTLine.ROBOTSTXT_RULE_DISALLOW);
183:                boolean matches = line.matches(url);
184:
185:                assertTrue("root match didn't work", matches);
186:            }
187:
188:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.