@Test public void herokuToJava() { SystemInstance.get().setProperty("DATABASE_URL", "postgres: assertEquals( new PropertiesBuilder() .p("Password", "pwd") .p("JdbcUrl", "jdbc:postgresql: .p("UserName", "user") .p("JdbcDriver", "org.postgresql.Driver") .build(), new HerokuDatabasePropertiesProvider().provides()); }
@Override public Properties provides() { try { final URI url = new URI(PropertyPlaceHolderHelper.simpleValue("${DATABASE_URL}")); final String userInfo = url.getUserInfo(); final String jdbcUrl = "jdbc:" + (jdbcMapping.containsKey(url.getScheme()) ? jdbcMapping.get(url.getScheme()) : url.getScheme()) + ": url.getPath(); final PropertiesBuilder builder = new PropertiesBuilder().p("JdbcUrl", jdbcUrl); if (userInfo != null) { final int sep = userInfo.indexOf(':'); if (sep > 0) { builder.p("UserName", userInfo.substring(0, sep)) .p("Password", userInfo.substring(sep + 1, userInfo.length())); } else { builder.p("UserName", userInfo); } } if (properties == null || "org.hsqldb.jdbcDriver".equals(properties.getProperty("JdbcDriver"))) { if ("postgres".equalsIgnoreCase(url.getScheme())) { builder.p("JdbcDriver", "org.postgresql.Driver"); } } return builder.build(); } catch (final URISyntaxException e) { throw new IllegalArgumentException(e); } }
HerokuDatabasePropertiesProvider implements PropertiesResourceProvider { @Override public Properties provides() { try { final URI url = new URI(PropertyPlaceHolderHelper.simpleValue("${DATABASE_URL}")); final String userInfo = url.getUserInfo(); final String jdbcUrl = "jdbc:" + (jdbcMapping.containsKey(url.getScheme()) ? jdbcMapping.get(url.getScheme()) : url.getScheme()) + ": url.getPath(); final PropertiesBuilder builder = new PropertiesBuilder().p("JdbcUrl", jdbcUrl); if (userInfo != null) { final int sep = userInfo.indexOf(':'); if (sep > 0) { builder.p("UserName", userInfo.substring(0, sep)) .p("Password", userInfo.substring(sep + 1, userInfo.length())); } else { builder.p("UserName", userInfo); } } if (properties == null || "org.hsqldb.jdbcDriver".equals(properties.getProperty("JdbcDriver"))) { if ("postgres".equalsIgnoreCase(url.getScheme())) { builder.p("JdbcDriver", "org.postgresql.Driver"); } } return builder.build(); } catch (final URISyntaxException e) { throw new IllegalArgumentException(e); } } }
HerokuDatabasePropertiesProvider implements PropertiesResourceProvider { @Override public Properties provides() { try { final URI url = new URI(PropertyPlaceHolderHelper.simpleValue("${DATABASE_URL}")); final String userInfo = url.getUserInfo(); final String jdbcUrl = "jdbc:" + (jdbcMapping.containsKey(url.getScheme()) ? jdbcMapping.get(url.getScheme()) : url.getScheme()) + ": url.getPath(); final PropertiesBuilder builder = new PropertiesBuilder().p("JdbcUrl", jdbcUrl); if (userInfo != null) { final int sep = userInfo.indexOf(':'); if (sep > 0) { builder.p("UserName", userInfo.substring(0, sep)) .p("Password", userInfo.substring(sep + 1, userInfo.length())); } else { builder.p("UserName", userInfo); } } if (properties == null || "org.hsqldb.jdbcDriver".equals(properties.getProperty("JdbcDriver"))) { if ("postgres".equalsIgnoreCase(url.getScheme())) { builder.p("JdbcDriver", "org.postgresql.Driver"); } } return builder.build(); } catch (final URISyntaxException e) { throw new IllegalArgumentException(e); } }  }
HerokuDatabasePropertiesProvider implements PropertiesResourceProvider { @Override public Properties provides() { try { final URI url = new URI(PropertyPlaceHolderHelper.simpleValue("${DATABASE_URL}")); final String userInfo = url.getUserInfo(); final String jdbcUrl = "jdbc:" + (jdbcMapping.containsKey(url.getScheme()) ? jdbcMapping.get(url.getScheme()) : url.getScheme()) + ": url.getPath(); final PropertiesBuilder builder = new PropertiesBuilder().p("JdbcUrl", jdbcUrl); if (userInfo != null) { final int sep = userInfo.indexOf(':'); if (sep > 0) { builder.p("UserName", userInfo.substring(0, sep)) .p("Password", userInfo.substring(sep + 1, userInfo.length())); } else { builder.p("UserName", userInfo); } } if (properties == null || "org.hsqldb.jdbcDriver".equals(properties.getProperty("JdbcDriver"))) { if ("postgres".equalsIgnoreCase(url.getScheme())) { builder.p("JdbcDriver", "org.postgresql.Driver"); } } return builder.build(); } catch (final URISyntaxException e) { throw new IllegalArgumentException(e); } }  @Override Properties provides(); }
HerokuDatabasePropertiesProvider implements PropertiesResourceProvider { @Override public Properties provides() { try { final URI url = new URI(PropertyPlaceHolderHelper.simpleValue("${DATABASE_URL}")); final String userInfo = url.getUserInfo(); final String jdbcUrl = "jdbc:" + (jdbcMapping.containsKey(url.getScheme()) ? jdbcMapping.get(url.getScheme()) : url.getScheme()) + ": url.getPath(); final PropertiesBuilder builder = new PropertiesBuilder().p("JdbcUrl", jdbcUrl); if (userInfo != null) { final int sep = userInfo.indexOf(':'); if (sep > 0) { builder.p("UserName", userInfo.substring(0, sep)) .p("Password", userInfo.substring(sep + 1, userInfo.length())); } else { builder.p("UserName", userInfo); } } if (properties == null || "org.hsqldb.jdbcDriver".equals(properties.getProperty("JdbcDriver"))) { if ("postgres".equalsIgnoreCase(url.getScheme())) { builder.p("JdbcDriver", "org.postgresql.Driver"); } } return builder.build(); } catch (final URISyntaxException e) { throw new IllegalArgumentException(e); } }  @Override Properties provides();  }