mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-15 13:02:19 +00:00
[FIXED HUDSON-2238]
I think the essnce of the problem is that the similarity between MarkupText and SubText isn't appropriately captured in the design, so I fixed it such. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@11657 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
e711a04509
commit
81c48c604a
3 files changed
+131
-56
No files matched your search
@@ -3,6 +3,7 @@ package hudson;
|
||||
import junit.framework.TestCase;
|
||||
import hudson.MarkupText.SubText;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
@@ -14,8 +15,7 @@ public class MarkupTextTest extends TestCase {
|
||||
for (SubText st : t.findTokens(pattern))
|
||||
st.surroundWith("<$1>","<$1>");
|
||||
|
||||
System.out.println(t);
|
||||
assertEquals(t.toString(),"I fixed <155>issue #155<155>. The rest is trick text: xissue #155 issue #123x");
|
||||
assertEquals("I fixed <155>issue #155<155>. The rest is trick text: xissue #155 issue #123x", t.toString());
|
||||
}
|
||||
|
||||
public void testBoundary() {
|
||||
@@ -23,8 +23,18 @@ public class MarkupTextTest extends TestCase {
|
||||
for (SubText st : t.findTokens(pattern))
|
||||
st.surroundWith("<$1>","<$1>");
|
||||
|
||||
System.out.println(t);
|
||||
assertEquals(t.toString(),"<155>issue #155<155>---<123>issue #123<123>");
|
||||
assertEquals("<155>issue #155<155>---<123>issue #123<123>", t.toString());
|
||||
}
|
||||
|
||||
public void testFindTokensOnSubText() {
|
||||
MarkupText t = new MarkupText("Fixed 2 issues in this commit, fixing issue 155, 145");
|
||||
List<SubText> tokens = t.findTokens(Pattern.compile("issue .*"));
|
||||
assertEquals("Expected one token", 1, tokens.size());
|
||||
assertEquals("Expected single token was incorrect", "issue 155, 145", tokens.get(0).group(0));
|
||||
for (SubText st : tokens.get(0).findTokens(Pattern.compile("([0-9]+)")))
|
||||
st.surroundWith("<$1>","<$1>");
|
||||
|
||||
assertEquals("Fixed 2 issues in this commit, fixing issue <155>155<155>, <145>145<145>", t.toString());
|
||||
}
|
||||
|
||||
private static final Pattern pattern = Pattern.compile("issue #([0-9]+)");
|
||||
|
||||
Reference in new issue
Block a user