@Test public void should_extract_version_from_sonar_welcome_page_v201() { URL resource = classLoader.getResource("sonar_2.0.1.html"); String version = sve.welcomePageVersion(resource); assertEquals("2.0.1", version); }
public String welcomePageVersion(URL url) { try { byte[] byteArray = ByteStreams.toByteArray(url.openStream()); String htmlContent = new String(byteArray); Pattern p = Pattern.compile(".* - v\\.([0-9]\\.[0-9]*.[0-9]*) - .*"); Matcher m = p.matcher(htmlContent); while (m.find()) { return m.group(1); } } catch (IOException e) { return "unknown"; } return "unknown"; }
SonarVersionExtractor { public String welcomePageVersion(URL url) { try { byte[] byteArray = ByteStreams.toByteArray(url.openStream()); String htmlContent = new String(byteArray); Pattern p = Pattern.compile(".* - v\\.([0-9]\\.[0-9]*.[0-9]*) - .*"); Matcher m = p.matcher(htmlContent); while (m.find()) { return m.group(1); } } catch (IOException e) { return "unknown"; } return "unknown"; } }
SonarVersionExtractor { public String welcomePageVersion(URL url) { try { byte[] byteArray = ByteStreams.toByteArray(url.openStream()); String htmlContent = new String(byteArray); Pattern p = Pattern.compile(".* - v\\.([0-9]\\.[0-9]*.[0-9]*) - .*"); Matcher m = p.matcher(htmlContent); while (m.find()) { return m.group(1); } } catch (IOException e) { return "unknown"; } return "unknown"; }  }
SonarVersionExtractor { public String welcomePageVersion(URL url) { try { byte[] byteArray = ByteStreams.toByteArray(url.openStream()); String htmlContent = new String(byteArray); Pattern p = Pattern.compile(".* - v\\.([0-9]\\.[0-9]*.[0-9]*) - .*"); Matcher m = p.matcher(htmlContent); while (m.find()) { return m.group(1); } } catch (IOException e) { return "unknown"; } return "unknown"; }  String propertiesVersion(Properties properties); String welcomePageVersion(URL url); }
SonarVersionExtractor { public String welcomePageVersion(URL url) { try { byte[] byteArray = ByteStreams.toByteArray(url.openStream()); String htmlContent = new String(byteArray); Pattern p = Pattern.compile(".* - v\\.([0-9]\\.[0-9]*.[0-9]*) - .*"); Matcher m = p.matcher(htmlContent); while (m.find()) { return m.group(1); } } catch (IOException e) { return "unknown"; } return "unknown"; }  String propertiesVersion(Properties properties); String welcomePageVersion(URL url);  }