import static org.testng.AssertJUnit.assertNull;
import static org.testng.AssertJUnit.assertTrue;
+import jalview.gui.JvOptionPane;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class StringUtilsTest
{
+ @BeforeClass(alwaysRun = true)
+ public void setUpJvOptionPane()
+ {
+ JvOptionPane.setInteractiveMode(false);
+ JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+ }
+
@Test(groups = { "Functional" })
public void testInsertCharAt()
{
assertEquals(1, StringUtils.compareVersions("12", "2"));
assertEquals(1, StringUtils.compareVersions("3.12.11", "3.2.4"));
}
+
+ @Test(groups = { "Functional" })
+ public void testToSentenceCase()
+ {
+ assertEquals("John", StringUtils.toSentenceCase("john"));
+ assertEquals("John", StringUtils.toSentenceCase("JOHN"));
+ assertEquals("John and james",
+ StringUtils.toSentenceCase("JOHN and JAMES"));
+ assertEquals("J", StringUtils.toSentenceCase("j"));
+ assertEquals("", StringUtils.toSentenceCase(""));
+ assertNull(StringUtils.toSentenceCase(null));
+ }
+
+ @Test(groups = { "Functional" })
+ public void testStripHtmlTags()
+ {
+ assertNull(StringUtils.stripHtmlTags(null));
+ assertEquals("", StringUtils.stripHtmlTags(""));
+ assertEquals(
+ "<a href=\"something\">label</href>",
+ StringUtils
+ .stripHtmlTags("<html><a href=\"something\">label</href></html>"));
+
+ // if no "<html>" tag, < and > get html-encoded (not sure why)
+ assertEquals("<a href=\"something\">label</href>",
+ StringUtils.stripHtmlTags("<a href=\"something\">label</href>"));
+
+ // </body> gets removed but not <body> (is this intentional?)
+ assertEquals("<body><p>hello",
+ StringUtils.stripHtmlTags("<html><body><p>hello</body></html>"));
+
+ assertEquals("kdHydro < 12.53",
+ StringUtils.stripHtmlTags("kdHydro < 12.53"));
+ }
}