01: /*
02: * Copyright 2006 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.
15: */
16: package org.kuali.core.web.comparator;
17:
18: import junit.framework.TestCase;
19:
20: import org.displaytag.model.Cell;
21:
22: public class CellComparatorHelperTest extends TestCase {
23:
24: public void testExtractFromHref() {
25:
26: String href = "<a style=\"color: red;\" href=\"inquiry.do?businessObjectClassName=org.kuali.core.bo.Options&universityFiscalYear=2004&methodToCall=start\" target=\"blank\">needle</a>";
27:
28: Cell cell = new Cell(href);
29:
30: assertEquals(
31: CellComparatorHelper.getSanitizedStaticValue(cell),
32: "needle");
33:
34: }
35:
36: public void testExtractFromHrefAndRemoveNbsp() {
37:
38: String href = "<a href=\"haystack\">needle </a>";
39:
40: Cell cell = new Cell(href);
41:
42: assertEquals(
43: CellComparatorHelper.getSanitizedStaticValue(cell),
44: "needle");
45:
46: }
47:
48: public void testRemoveNbsp() {
49:
50: String bad = "needle ";
51:
52: Cell cell = new Cell(bad);
53:
54: assertEquals(
55: CellComparatorHelper.getSanitizedStaticValue(cell),
56: "needle");
57:
58: }
59:
60: public void testLeaveSimpleValueAlone() {
61:
62: String good = "needle";
63: Cell cell = new Cell(good);
64: assertEquals(
65: CellComparatorHelper.getSanitizedStaticValue(cell),
66: "needle");
67:
68: }
69:
70: public void testMessyHref() {
71:
72: String href = "<a onClick=\"foo();\" href=\"haystack\" class=\"my favorite class\" >needle</a> ";
73:
74: Cell cell = new Cell(href);
75:
76: assertEquals(
77: CellComparatorHelper.getSanitizedStaticValue(cell),
78: "needle");
79:
80: }
81:
82: }
|