// KNL-526 - testing that targets are not destroyed or replaced public void testTargetNotOverridden() { // method 1 - processAnchor (kills all A attribs and only works on the first part of the tag assertEquals( "<a href=\"other.html\" target=\"_blank\">", FormattedText.processAnchor("<a href=\"other.html\">")); assertEquals( "<a href=\"other.html\" target=\"_blank\">", FormattedText.processAnchor("<a target=\"_blank\" href=\"other.html\">")); assertEquals( "<a href=\"other.html\" target=\"_AZ\">", FormattedText.processAnchor("<a href=\"other.html\" target=\"_AZ\">")); // destroys other attributes though... assertEquals( "<a href=\"other.html\" target=\"_AZ\">", FormattedText.processAnchor("<a href=\"other.html\" target=\"_AZ\" class=\"azeckoski\">")); // method 2 - escapeHtmlFormattedText (saves other A attribs) assertEquals( "<a href=\"other.html\" target=\"_blank\">link</a>", FormattedText.escapeHtmlFormattedText("<a href=\"other.html\">link</a>")); assertEquals( "<a href=\"other.html\" class=\"azeckoski\" target=\"_blank\">link</a>", FormattedText.escapeHtmlFormattedText( "<a href=\"other.html\" class=\"azeckoski\">link</a>")); assertEquals( "<b>simple</b><b class=\"AZ\">bold</b>", FormattedText.escapeHtmlFormattedText("<b>simple</b><b class=\"AZ\">bold</b>")); assertEquals( "<a href=\"other.html\" target=\"_AZ\">link</a>", FormattedText.escapeHtmlFormattedText("<a href=\"other.html\" target=\"_AZ\">link</a>")); assertEquals( "<a href=\"other.html\" target=\"_AZ\" class=\"azeckoski\">link</a>", FormattedText.escapeHtmlFormattedText( "<a href=\"other.html\" target=\"_AZ\" class=\"azeckoski\">link</a>")); assertEquals( "<a href=\"other.html\" class=\"azeckoski\" target=\"_blank\">link</a><a href=\"other.html\" target=\"_AZ\" class=\"azeckoski\">link</a>", FormattedText.escapeHtmlFormattedText( "<a href=\"other.html\" class=\"azeckoski\">link</a><a href=\"other.html\" target=\"_AZ\" class=\"azeckoski\">link</a>")); assertEquals( "<b>simple</b><b class=\"AZ\">bold</b><a href=\"other.html\" class=\"azeckoski\" target=\"_blank\">link</a><a href=\"other.html\" target=\"_AZ\" class=\"azeckoski\">link</a>", FormattedText.escapeHtmlFormattedText( "<b>simple</b><b class=\"AZ\">bold</b><a href=\"other.html\" class=\"azeckoski\">link</a><a href=\"other.html\" target=\"_AZ\" class=\"azeckoski\">link</a>")); }
public void testProcessAnchor() { // Check we add the target attribute assertEquals( "<a href=\"http://sakaiproject.org/\" target=\"_blank\">", FormattedText.processAnchor("<a href=\"http://sakaiproject.org/\">")); }
public void testProcessAnchorName() { assertEquals( "<a href=\"#anchor\" target=\"_blank\">", FormattedText.processAnchor("<a href=\"#anchor\">")); }
public void testProcessAnchorMailto() { assertEquals( "<a href=\"mailto:[email protected]\" target=\"_blank\">", FormattedText.processAnchor("<a href=\"mailto:[email protected]\">")); }
public void testProcessAnchorRelative() { // Check we add the target attribute assertEquals( "<a href=\"other.html\" target=\"_blank\">", FormattedText.processAnchor("<a href=\"other.html\">")); }