01: /*
02: * Created on 11/07/2005 00:25:19
03: */
04: package net.jforum.util;
05:
06: import junit.framework.TestCase;
07:
08: /**
09: * Remove special chars, spaces and etc from a string
10: * @author Rafael Steil
11: * @version $Id: URLNormalizerTest.java,v 1.4 2005/07/26 04:01:12 diegopires Exp $
12: */
13: public class URLNormalizerTest extends TestCase {
14: public void testReplaceSpaceByUnderline() {
15: String s = "this is a test";
16: String normalized = URLNormalizer.normalize(s);
17:
18: assertEquals("this_is_a_test", normalized);
19: }
20:
21: public void testFriendlyLimit() {
22: String s = "this is long string used for testing the limit";
23: String normalized = URLNormalizer.normalize(s);
24:
25: assertEquals("this_is_long_string_used_for_testing", normalized);
26: }
27:
28: public void testUnfriendlyLimit() {
29: String s = "this is long string used for testing the limit";
30: String normalized = URLNormalizer.normalize(s,
31: URLNormalizer.LIMIT, false);
32:
33: assertEquals("this_is_long_string_used_for_te", normalized);
34: }
35:
36: public void testFriendlyLimitWithParentesis() {
37: String s = "this is long string used for testing(the limit)";
38: String normalized = URLNormalizer.normalize(s);
39:
40: assertEquals("this_is_long_string_used_for_testing", normalized);
41: }
42:
43: public void testRemovePlusParentesis() {
44: String s = "a test + some + 2 thing(s)";
45: String normalized = URLNormalizer.normalize(s);
46:
47: assertEquals("a_test_some_2_things", normalized);
48: }
49:
50: public void testRemovePorcentageDollarStarEtc() {
51: String s = "!@#$%^&*";
52: String normalized = URLNormalizer.normalize(s);
53:
54: assertEquals("", normalized);
55: }
56: }
|