@Test public void testReplaceWholeWordsOnly() { String text = "This is"; String exp = "This is"; String actual = MiscUtils.replaceWholeWordOnly(text, "test", "TEST"); assertEquals("No replace", exp, actual); text = "This is a test"; exp = "This is a TEST"; actual = MiscUtils.replaceWholeWordOnly(text, "test", "TEST"); assertEquals("Single replace", exp, actual); text = "This is a\ntesting\ttested \n test"; exp = "This is a\ntesting\ttested \n TEST"; actual = MiscUtils.replaceWholeWordOnly(text, "test", "TEST"); assertEquals("Only whole word", exp, actual); text = " \n\t "; exp = " \n\t "; actual = MiscUtils.replaceWholeWordOnly(text, "test", "TEST"); assertEquals("No replace (spaces)", exp, actual); text = ""; exp = ""; actual = MiscUtils.replaceWholeWordOnly(text, "test", "TEST"); assertEquals("Empty", exp, actual); }