RegexMapper { public String map(String s) { assert pattern != null; assert replacement != null; return Pattern.compile(pattern).matcher(s).replaceAll(replacement); } RegexMapper();  RegexMapper(String pattern, String replacement); String getPattern(); void setPattern(String pattern); String getReplacement(); void setReplacement(String replacement); String map(String s);  }
@Test public void testMap() { final String[][] TESTS = { {"com/ibm/g11n/Test.java", "(.+)\\.java", "$1", "com/ibm/g11n/Test"}, {"com/ibm/g11n/Test", "/", "\\.", "com.ibm.g11n.Test"}, {"abc-123", "def", "xyz", "abc-123"}, }; for (String[] test : TESTS) { RegexMapper mapper = new RegexMapper(test[1], test[2]); String result = mapper.map(test[0]); Assert.assertEquals(result, test[3]); } }