KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > javacoding > jspider > mod > rule > NoURLParamsRuleTest


1 package net.javacoding.jspider.mod.rule;
2
3 import junit.framework.TestCase;
4 import net.javacoding.jspider.spi.Rule;
5 import net.javacoding.jspider.api.model.Decision;
6
7 import java.net.URL JavaDoc;
8
9 /**
10  * $Id: NoURLParamsRuleTest.java,v 1.1 2003/04/07 15:51:06 vanrogu Exp $
11  */

12 public class NoURLParamsRuleTest extends TestCase {
13
14     protected Rule rule;
15
16     public NoURLParamsRuleTest ( ) {
17       super ( "NoURLParamsRuleTest" );
18     }
19
20     protected void setUp() throws Exception JavaDoc {
21         rule = new NoURLParamsRule();
22     }
23
24     public void testNoParams ( ) throws Exception JavaDoc {
25         String JavaDoc urlString = "http://j-spider.sourceforge.net/index.html";
26         int expected = Decision.RULE_ACCEPT;
27
28         applyTest ( urlString, expected);
29     }
30
31     public void testRootNoParams ( ) throws Exception JavaDoc {
32         String JavaDoc urlString = "http://j-spider.sourceforge.net";
33         int expected = Decision.RULE_ACCEPT;
34
35         applyTest ( urlString, expected);
36     }
37
38     public void testRootNoParamsWithSlash ( ) throws Exception JavaDoc {
39         String JavaDoc urlString = "http://j-spider.sourceforge.net/";
40         int expected = Decision.RULE_ACCEPT;
41
42         applyTest ( urlString, expected);
43     }
44
45     public void testSingleParam ( ) throws Exception JavaDoc {
46         String JavaDoc urlString = "http://j-spider.sourceforge.net/index.html?param=value";
47         int expected = Decision.RULE_IGNORE;
48
49         applyTest ( urlString, expected);
50     }
51
52     public void testDoubleParam ( ) throws Exception JavaDoc {
53         String JavaDoc urlString = "http://j-spider.sourceforge.net/index.html?param=value&param2=value2";
54         int expected = Decision.RULE_IGNORE;
55
56         applyTest ( urlString, expected);
57     }
58
59     public void testQuestionMarkOnly ( ) throws Exception JavaDoc {
60         String JavaDoc urlString = "http://j-spider.sourceforge.net/index.html?";
61         int expected = Decision.RULE_ACCEPT;
62
63         applyTest ( urlString, expected);
64     }
65
66     public void testQuestionMarkOnlyOnFolder ( ) throws Exception JavaDoc {
67         String JavaDoc urlString = "http://j-spider.sourceforge.net/test?";
68         int expected = Decision.RULE_ACCEPT;
69
70         applyTest ( urlString, expected);
71     }
72
73     public void testQuestionMarkOnlyOnFolderWithSlash ( ) throws Exception JavaDoc {
74         String JavaDoc urlString = "http://j-spider.sourceforge.net/test/?";
75         int expected = Decision.RULE_ACCEPT;
76
77         applyTest ( urlString, expected);
78     }
79
80     public void applyTest ( String JavaDoc urlString, int expected ) throws Exception JavaDoc {
81         URL JavaDoc url = new URL JavaDoc(urlString);
82         Decision decision = rule.apply(null,null,url);
83         assertEquals("decision not as expected", expected, decision.getDecision());
84     }
85
86 }
87
Popular Tags