UtilsTest.java revision 05b42f00b813c3dc70cbb80d62089f9cc0f6f549
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter * CDDL HEADER START
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter * The contents of this file are subject to the terms of the
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter * Common Development and Distribution License, Version 1.0 only
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter * (the "License"). You may not use this file except in compliance
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter * with the License.
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter * You can obtain a copy of the license at
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter * trunk/opends/resource/legal-notices/OpenDS.LICENSE
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter * See the License for the specific language governing permissions
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter * and limitations under the License.
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter * When distributing Covered Code, include this CDDL HEADER in each
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter * file and include the License file at
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter * add the following below this CDDL HEADER, with the fields enclosed
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter * by brackets "[]" replaced with your own identifying information:
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter * Portions Copyright [yyyy] [name of copyright owner]
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter * CDDL HEADER END
05b42f00b813c3dc70cbb80d62089f9cc0f6f549ludovicp * Copyright 2006-2008 Sun Microsystems, Inc.
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter * Utils Tester.
24d6db06810f2ea747f6dff60d483e4fca3aaa13davidelypublic class UtilsTest extends DirectoryServerTestCase {
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter // Test data should not contain words longer that
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter // the maximum line length value.
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter return new Object[][]{
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter "Hi my<br>name<br>is<br>Bingo"},
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter "Hi<br>my<br>name<br>is<br>Bingo"},
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter "Hi<br>my<br>name<br>is<br>Bingo"},
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter public void testBreakHtmlString(String s, int maxll, String expectedValue) {
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter assertTrue(Utils.breakHtmlString(s, maxll).equals(expectedValue));
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter return new Object[][]{
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter {"Hi<input value=\"abc\"></input> Ho", "Hi Ho"},
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter // {"Hi<tag attr=\"1 > 0\"> Ho", "Hi Ho"}, // broken case
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter // {"Hi <your name here>", "Hi <your name here>"} // broken case
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter @Test(enabled = false, dataProvider = "stripHtmlData")
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter public void testStripHtml(String html, String expectedResult) {
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter assertTrue(expectedResult.equals(Utils.stripHtml(html)));
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter return new Object[][]{
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter {"Hi <i>Ho</i>", true},
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter // {"Hello <your name here>", false}, // broken case
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter @Test(enabled = false, dataProvider = "containsHtmlData")
c4872f44c4ebc3317f3cb6bd44baf674f18e0088kenneth_suter public void testContainsHtml(String s, boolean expectedResult) {