1 package hudson; 2 3 import junit.framework.TestCase; 4 import hudson.MarkupText.SubText; 5 6 import java.util.regex.Pattern ; 7 8 11 public class MarkupTextTest extends TestCase { 12 public void test1() { 13 MarkupText t = new MarkupText("I fixed issue #155. The rest is trick text: xissue #155 issue #123x"); 14 for (SubText st : t.findTokens(pattern)) 15 st.surroundWith("<$1>","<$1>"); 16 17 System.out.println(t); 18 assertEquals(t.toString(),"I fixed <155>issue #155<155>. The rest is trick text: xissue #155 issue #123x"); 19 } 20 21 public void testBoundary() { 22 MarkupText t = new MarkupText("issue #155---issue #123"); 23 for (SubText st : t.findTokens(pattern)) 24 st.surroundWith("<$1>","<$1>"); 25 26 System.out.println(t); 27 assertEquals(t.toString(),"<155>issue #155<155>---<123>issue #123<123>"); 28 } 29 30 private static final Pattern pattern = Pattern.compile("issue #([0-9]+)"); 31 } 32 | Popular Tags |