1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.web.comparator;
17
18 import org.displaytag.model.Cell;
19 import org.junit.Test;
20 import org.kuali.rice.kns.web.comparator.CellComparatorHelper;
21 import org.kuali.test.KNSTestCase;
22
23 public class CellComparatorHelperTest extends KNSTestCase {
24
25 @Test public void testExtractFromHref() {
26
27 String href = "<a style=\"color: red;\" href=\"inquiry.do?businessObjectClassName=org.kuali.rice.kns.bo.Options&universityFiscalYear=2004&methodToCall=start\" target=\"blank\">needle</a>";
28
29 Cell cell = new Cell(href);
30
31 assertEquals(CellComparatorHelper.getSanitizedStaticValue(cell), "needle");
32
33 }
34
35 @Test public void testExtractFromHrefAndRemoveNbsp() {
36
37 String href = "<a href=\"haystack\">needle </a>";
38
39 Cell cell = new Cell(href);
40
41 assertEquals(CellComparatorHelper.getSanitizedStaticValue(cell), "needle");
42
43 }
44
45 @Test public void testRemoveNbsp() {
46
47 String bad = "needle ";
48
49 Cell cell = new Cell(bad);
50
51 assertEquals(CellComparatorHelper.getSanitizedStaticValue(cell), "needle");
52
53 }
54
55 @Test public void testLeaveSimpleValueAlone() {
56
57 String good = "needle";
58 Cell cell = new Cell(good);
59 assertEquals(CellComparatorHelper.getSanitizedStaticValue(cell), "needle");
60
61 }
62
63 @Test public void testMessyHref() {
64
65 String href = "<a onClick=\"foo();\" href=\"haystack\" class=\"my favorite class\" >needle</a> ";
66
67 Cell cell = new Cell(href);
68
69 assertEquals(CellComparatorHelper.getSanitizedStaticValue(cell), "needle");
70
71 }
72
73 }