Use Matcher from pre-compiled Pattern rather than String for replaceAll

Closes gh-14483
This commit is contained in:
durigon
2018-09-16 11:42:49 +09:00
committed by Andy Wilkinson
parent 11016bc7f4
commit 7aaeefbc0e
8 changed files with 44 additions and 10 deletions

View File

@@ -21,6 +21,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
@@ -36,12 +37,14 @@ import org.springframework.util.StringUtils;
*/
class JvmLauncher implements TestRule {
private static final Pattern NON_ALPHABET_PATTERN = Pattern.compile("[^A-Za-z]+");
private File outputDirectory;
@Override
public Statement apply(Statement base, Description description) {
this.outputDirectory = new File("target/output/"
+ description.getMethodName().replaceAll("[^A-Za-z]+", ""));
this.outputDirectory = new File("target/output/" + NON_ALPHABET_PATTERN
.matcher(description.getMethodName()).replaceAll(""));
this.outputDirectory.mkdirs();
return base;
}