@Test public void shouldParseUrlWithPort() { JdbcUrl jdbcUrl = JdbcUrlParser.parse("jdbc:mysql: assertEquals("192.168.99.101", jdbcUrl.getHost()); assertEquals(3306, jdbcUrl.getPort()); assertEquals("eventuate", jdbcUrl.getDatabase()); }
public static JdbcUrl parse(String dataSourceURL) { Pattern p = Pattern.compile("jdbc:[a-zA-Z0-9]+: Matcher m = p.matcher(dataSourceURL); if (!m.matches()) throw new RuntimeException(dataSourceURL); String host = m.group(1); String port = m.group(2); String database = m.group(3); return new JdbcUrl(host, port == null ? 3306 : Integer.parseInt(port.substring(1)), database); }
JdbcUrlParser { public static JdbcUrl parse(String dataSourceURL) { Pattern p = Pattern.compile("jdbc:[a-zA-Z0-9]+: Matcher m = p.matcher(dataSourceURL); if (!m.matches()) throw new RuntimeException(dataSourceURL); String host = m.group(1); String port = m.group(2); String database = m.group(3); return new JdbcUrl(host, port == null ? 3306 : Integer.parseInt(port.substring(1)), database); } }
JdbcUrlParser { public static JdbcUrl parse(String dataSourceURL) { Pattern p = Pattern.compile("jdbc:[a-zA-Z0-9]+: Matcher m = p.matcher(dataSourceURL); if (!m.matches()) throw new RuntimeException(dataSourceURL); String host = m.group(1); String port = m.group(2); String database = m.group(3); return new JdbcUrl(host, port == null ? 3306 : Integer.parseInt(port.substring(1)), database); }  }
JdbcUrlParser { public static JdbcUrl parse(String dataSourceURL) { Pattern p = Pattern.compile("jdbc:[a-zA-Z0-9]+: Matcher m = p.matcher(dataSourceURL); if (!m.matches()) throw new RuntimeException(dataSourceURL); String host = m.group(1); String port = m.group(2); String database = m.group(3); return new JdbcUrl(host, port == null ? 3306 : Integer.parseInt(port.substring(1)), database); }  static JdbcUrl parse(String dataSourceURL); }
JdbcUrlParser { public static JdbcUrl parse(String dataSourceURL) { Pattern p = Pattern.compile("jdbc:[a-zA-Z0-9]+: Matcher m = p.matcher(dataSourceURL); if (!m.matches()) throw new RuntimeException(dataSourceURL); String host = m.group(1); String port = m.group(2); String database = m.group(3); return new JdbcUrl(host, port == null ? 3306 : Integer.parseInt(port.substring(1)), database); }  static JdbcUrl parse(String dataSourceURL);  }