001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. The ASF licenses this file to You
004: * under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License. For additional information regarding
015: * copyright in this work, please see the NOTICE file in the top level
016: * directory of this distribution.
017: */
018:
019: package org.apache.roller.util;
020:
021: import junit.framework.Test;
022: import junit.framework.TestCase;
023: import junit.framework.TestSuite;
024:
025: /**
026: * Test utilities.
027: */
028: public class UtilitiesTest extends TestCase {
029:
030: /**
031: * Constructor for LinkbackExtractorTest.
032: * @param arg0
033: */
034: public UtilitiesTest(String arg0) {
035: super (arg0);
036: }
037:
038: public static void main(String[] args) {
039: }
040:
041: /**
042: * @see TestCase#setUp()
043: */
044: protected void setUp() throws Exception {
045: super .setUp();
046: }
047:
048: /**
049: * @see TestCase#tearDown()
050: */
051: protected void tearDown() throws Exception {
052: super .tearDown();
053: }
054:
055: public void testExtractHTML() {
056: String test = "<a>keep me</a>";
057: String expect = "<a></a>";
058: String result = Utilities.extractHTML(test);
059: assertEquals(expect, result);
060: }
061:
062: public void testRemoveHTML() {
063: String test = "<br><br><p>a <b>bold</b> sentence with a <a href=\"http://example.com\">link</a></p>";
064: String expect = "a bold sentence with a link";
065: String result = Utilities.removeHTML(test, false);
066: assertEquals(expect, result);
067: }
068:
069: public void testTruncateNicely1() {
070: String test = "blah blah blah blah blah";
071: String expect = "blah blah blah";
072: String result = Utilities.truncateNicely(test, 11, 15, "");
073: assertEquals(expect, result);
074: }
075:
076: public void testTruncateNicely2() {
077: String test = "<p><b>blah1 blah2</b> <i>blah3 blah4 blah5</i></p>";
078: String expect = "<p><b>blah1 blah2</b> <i>blah3</i></p>";
079: String result = Utilities.truncateNicely(test, 15, 20, "");
080: //System.out.println(result);
081: assertEquals(expect, result);
082: }
083:
084: /* broken because it uses UtilitiesModel which is part of .ui.* package
085: public void testAddNoFollow() {
086: String test1 = "<p>this some text with a <a href=\"http://example.com\">link</a>";
087: String expect1 = "<p>this some text with a <a href=\"http://example.com\" rel=\"nofollow\">link</a>";
088: String result1 = UtilitiesModel.addNofollow(test1);
089: assertEquals(expect1, result1);
090:
091: String test2 = "<p>this some text with a <A href=\"http://example.com\">link</a>";
092: String expect2 = "<p>this some text with a <A href=\"http://example.com\" rel=\"nofollow\">link</a>";
093: String result2 = UtilitiesModel.addNofollow(test2);
094: assertEquals(expect2, result2);
095:
096: }
097: */
098:
099: public static Test suite() {
100: return new TestSuite(UtilitiesTest.class);
101: }
102:
103: }
|