@Test public void testExtractVersion() throws Exception { JsfVersionInspector enforcer = new JsfVersionInspector(""); String version; version = enforcer.extractVersion("This sentence contains the version 2.1.4-jbossorg-2 in the middle"); Assert.assertEquals("2.1.4-jbossorg-2", version); version = enforcer.extractVersion("This sentence contains the version 2.2.6 in the middle"); Assert.assertEquals("2.2.6", version); }
String extractVersion(String string) { Pattern pattern = Pattern.compile("([0-9][0-9\\.\\-a-z]*)"); Matcher matcher = pattern.matcher(string); if (matcher.find()) { return matcher.group(); } else { return "no match"; } }
JsfVersionInspector { String extractVersion(String string) { Pattern pattern = Pattern.compile("([0-9][0-9\\.\\-a-z]*)"); Matcher matcher = pattern.matcher(string); if (matcher.find()) { return matcher.group(); } else { return "no match"; } } }
JsfVersionInspector { String extractVersion(String string) { Pattern pattern = Pattern.compile("([0-9][0-9\\.\\-a-z]*)"); Matcher matcher = pattern.matcher(string); if (matcher.find()) { return matcher.group(); } else { return "no match"; } } JsfVersionInspector();   JsfVersionInspector(String versionString); }
JsfVersionInspector { String extractVersion(String string) { Pattern pattern = Pattern.compile("([0-9][0-9\\.\\-a-z]*)"); Matcher matcher = pattern.matcher(string); if (matcher.find()) { return matcher.group(); } else { return "no match"; } } JsfVersionInspector();   JsfVersionInspector(String versionString); boolean verifyJsfImplVersion(); String getVersionString(); }
JsfVersionInspector { String extractVersion(String string) { Pattern pattern = Pattern.compile("([0-9][0-9\\.\\-a-z]*)"); Matcher matcher = pattern.matcher(string); if (matcher.find()) { return matcher.group(); } else { return "no match"; } } JsfVersionInspector();   JsfVersionInspector(String versionString); boolean verifyJsfImplVersion(); String getVersionString();  }