@Test public void testGetNextHtmlWord() { String text = "This is < html >text</html>"; String exp = "< html >text</html>"; int[] expIndices = new int[2]; expIndices[0] = text.indexOf('<'); expIndices[1] = text.lastIndexOf('>') + 1; int[] actIndices = new int[2]; String token; token = MiscUtils.getNextHtmlWord(text, 0, actIndices); assertEquals("Html word", exp, token); assertTrue( "Html indicies: expIndices=" + Arrays.toString(expIndices) + "; actIndices=" + Arrays.toString(actIndices), Arrays.equals(expIndices, actIndices)); text = "This is <html />"; exp = "<html />"; expIndices[0] = text.indexOf('<'); expIndices[1] = text.lastIndexOf('>') + 1; token = MiscUtils.getNextHtmlWord(text, 0, actIndices); assertEquals("Html word", exp, token); assertTrue( "Html indicies: expIndices=" + Arrays.toString(expIndices) + "; actIndices=" + Arrays.toString(actIndices), Arrays.equals(expIndices, actIndices)); text = "This is not html\n"; exp = null; expIndices[0] = expIndices[1] = -1; token = MiscUtils.getNextHtmlWord(text, 0, actIndices); assertEquals("Html word", exp, token); assertTrue( "Html indicies: expIndices=" + Arrays.toString(expIndices) + "; actIndices=" + Arrays.toString(actIndices), Arrays.equals(expIndices, actIndices)); }