KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > roller > util > BlacklistTest


1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. The ASF licenses this file to You
4 * under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License. For additional information regarding
15 * copyright in this work, please see the NOTICE file in the top level
16 * directory of this distribution.
17 */

18 /*
19  * Created on Nov 12, 2003
20  */

21 package org.apache.roller.util;
22
23 import java.io.File JavaDoc;
24
25 import org.apache.roller.business.FileManagerTest;
26 import org.apache.roller.config.RollerConfig;
27
28 import junit.framework.Test;
29 import junit.framework.TestCase;
30 import junit.framework.TestSuite;
31
32 /**
33  * @author lance
34  */

35 public class BlacklistTest extends TestCase
36 {
37     private Blacklist blacklist;
38
39     /**
40      *
41      */

42     public BlacklistTest()
43     {
44         super();
45     }
46
47     /**
48      * @param arg0
49      */

50     public BlacklistTest(String JavaDoc arg0)
51     {
52         super(arg0);
53     }
54     
55     /**
56      * @see TestCase#setUp()
57      */

58     protected void setUp() throws Exception JavaDoc
59     {
60         super.setUp();
61         blacklist = Blacklist.getBlacklist();
62         String JavaDoc FS = File.separator;
63         blacklist.loadBlacklistFromFile(
64             ".." + FS + "WEB-INF" + FS + "classes" + FS + "blacklist.txt");
65     }
66
67     /**
68      * @see TestCase#tearDown()
69      */

70     protected void tearDown() throws Exception JavaDoc
71     {
72         super.tearDown();
73         //System.out.println(blacklist);
74
}
75     
76     public void testIsBlacklisted0()
77     {
78         assertFalse(blacklist.isBlacklisted("four score and seven years ago.com"));
79     }
80     
81     // test non-regex
82
public void testIsBlacklisted1()
83     {
84         assertTrue(blacklist.isBlacklisted("00000-online-casino.com"));
85     }
86     
87     // test the regex patterns
88
public void testIsBlacklisted2()
89     {
90         assertTrue(blacklist.isBlacklisted("www.lsotr.com"));
91     }
92     
93     // test the regex patterns
94
public void testIsBlacklisted3()
95     {
96         assertTrue(blacklist.isBlacklisted("www.lsotr.com"));
97     }
98     
99     // test the regex patterns
100
public void testIsBlacklisted4()
101     {
102         assertTrue(blacklist.isBlacklisted("blow-job.com"));
103     }
104     
105     // test the regex patterns
106
public void testIsBlacklisted5()
107     {
108         assertTrue(blacklist.isBlacklisted("buymoreonline.com"));
109     }
110     
111     // test the regex patterns
112
public void testIsBlacklisted6()
113     {
114         assertTrue(blacklist.isBlacklisted("diet-enlargement.com"));
115     }
116     
117     // test the regex patterns
118
public void testIsBlacklisted7()
119     {
120         assertTrue(blacklist.isBlacklisted("viagra.com"));
121     }
122     
123     // test the regex patterns
124
public void testIsBlacklisted8()
125     {
126         assertTrue(blacklist.isBlacklisted("ragazze-something.com"));
127     }
128
129     public static Test suite()
130     {
131         return new TestSuite(BlacklistTest.class);
132     }
133 }
134
Popular Tags