@Test public void jdbcDriverLocatedInMavenRepository() { Locators locators = mock(Locators.class); File driverFile = getDriverFile(); when(locators.locate(MavenLocation.create("oracle", "oracle", "10.1"))).thenReturn(driverFile); Configuration config = Configuration.builder() .setProperty("sonar.jdbc.url", "jdbc:oracle:thin:@localhost/XE") .setProperty("sonar.jdbc.driverMavenKey", "oracle:oracle:10.1") .build(); DatabaseClient client = DatabaseFactory.create(config, locators); assertThat(client.getDriverFile()).isEqualTo(driverFile); }
public static DatabaseClient create(Configuration config, Locators locators) { String url = config.getString("sonar.jdbc.url"); DatabaseClient.Builder builder = newBuilderForUrl(url); String s = config.getString("sonar.jdbc.schema"); if (!isEmpty(s)) { builder.setSchema(s); } s = config.getString("sonar.jdbc.username"); if (!isEmpty(s)) { builder.setLogin(s); } s = config.getString("sonar.jdbc.password"); if (!isEmpty(s)) { builder.setPassword(s); } s = config.getString("sonar.jdbc.rootUrl"); if (!isEmpty(s)) { builder.setRootUrl(s); } s = config.getString("sonar.jdbc.rootUsername"); if (!isEmpty(s)) { builder.setRootLogin(s); } s = config.getString("sonar.jdbc.rootPassword"); if (!isEmpty(s)) { builder.setRootPassword(s); } s = config.getString("sonar.jdbc.driverFile"); if (!isEmpty(s)) { builder.setDriverFile(new File(s)); } s = config.getString("sonar.jdbc.driverMavenKey"); if (!isEmpty(s)) { feedDriverMavenKey(locators, builder, s); } String value = config.getString("orchestrator.keepDatabase", "false"); boolean keepDatabase = !isEmpty(value) ? Boolean.valueOf(value) : false; if (keepDatabase) { builder.setDropAndCreate(false); } return builder.build(); }
DatabaseFactory { public static DatabaseClient create(Configuration config, Locators locators) { String url = config.getString("sonar.jdbc.url"); DatabaseClient.Builder builder = newBuilderForUrl(url); String s = config.getString("sonar.jdbc.schema"); if (!isEmpty(s)) { builder.setSchema(s); } s = config.getString("sonar.jdbc.username"); if (!isEmpty(s)) { builder.setLogin(s); } s = config.getString("sonar.jdbc.password"); if (!isEmpty(s)) { builder.setPassword(s); } s = config.getString("sonar.jdbc.rootUrl"); if (!isEmpty(s)) { builder.setRootUrl(s); } s = config.getString("sonar.jdbc.rootUsername"); if (!isEmpty(s)) { builder.setRootLogin(s); } s = config.getString("sonar.jdbc.rootPassword"); if (!isEmpty(s)) { builder.setRootPassword(s); } s = config.getString("sonar.jdbc.driverFile"); if (!isEmpty(s)) { builder.setDriverFile(new File(s)); } s = config.getString("sonar.jdbc.driverMavenKey"); if (!isEmpty(s)) { feedDriverMavenKey(locators, builder, s); } String value = config.getString("orchestrator.keepDatabase", "false"); boolean keepDatabase = !isEmpty(value) ? Boolean.valueOf(value) : false; if (keepDatabase) { builder.setDropAndCreate(false); } return builder.build(); } }
DatabaseFactory { public static DatabaseClient create(Configuration config, Locators locators) { String url = config.getString("sonar.jdbc.url"); DatabaseClient.Builder builder = newBuilderForUrl(url); String s = config.getString("sonar.jdbc.schema"); if (!isEmpty(s)) { builder.setSchema(s); } s = config.getString("sonar.jdbc.username"); if (!isEmpty(s)) { builder.setLogin(s); } s = config.getString("sonar.jdbc.password"); if (!isEmpty(s)) { builder.setPassword(s); } s = config.getString("sonar.jdbc.rootUrl"); if (!isEmpty(s)) { builder.setRootUrl(s); } s = config.getString("sonar.jdbc.rootUsername"); if (!isEmpty(s)) { builder.setRootLogin(s); } s = config.getString("sonar.jdbc.rootPassword"); if (!isEmpty(s)) { builder.setRootPassword(s); } s = config.getString("sonar.jdbc.driverFile"); if (!isEmpty(s)) { builder.setDriverFile(new File(s)); } s = config.getString("sonar.jdbc.driverMavenKey"); if (!isEmpty(s)) { feedDriverMavenKey(locators, builder, s); } String value = config.getString("orchestrator.keepDatabase", "false"); boolean keepDatabase = !isEmpty(value) ? Boolean.valueOf(value) : false; if (keepDatabase) { builder.setDropAndCreate(false); } return builder.build(); } private  DatabaseFactory(); }
DatabaseFactory { public static DatabaseClient create(Configuration config, Locators locators) { String url = config.getString("sonar.jdbc.url"); DatabaseClient.Builder builder = newBuilderForUrl(url); String s = config.getString("sonar.jdbc.schema"); if (!isEmpty(s)) { builder.setSchema(s); } s = config.getString("sonar.jdbc.username"); if (!isEmpty(s)) { builder.setLogin(s); } s = config.getString("sonar.jdbc.password"); if (!isEmpty(s)) { builder.setPassword(s); } s = config.getString("sonar.jdbc.rootUrl"); if (!isEmpty(s)) { builder.setRootUrl(s); } s = config.getString("sonar.jdbc.rootUsername"); if (!isEmpty(s)) { builder.setRootLogin(s); } s = config.getString("sonar.jdbc.rootPassword"); if (!isEmpty(s)) { builder.setRootPassword(s); } s = config.getString("sonar.jdbc.driverFile"); if (!isEmpty(s)) { builder.setDriverFile(new File(s)); } s = config.getString("sonar.jdbc.driverMavenKey"); if (!isEmpty(s)) { feedDriverMavenKey(locators, builder, s); } String value = config.getString("orchestrator.keepDatabase", "false"); boolean keepDatabase = !isEmpty(value) ? Boolean.valueOf(value) : false; if (keepDatabase) { builder.setDropAndCreate(false); } return builder.build(); } private  DatabaseFactory(); static DatabaseClient create(Configuration config, Locators locators); }
DatabaseFactory { public static DatabaseClient create(Configuration config, Locators locators) { String url = config.getString("sonar.jdbc.url"); DatabaseClient.Builder builder = newBuilderForUrl(url); String s = config.getString("sonar.jdbc.schema"); if (!isEmpty(s)) { builder.setSchema(s); } s = config.getString("sonar.jdbc.username"); if (!isEmpty(s)) { builder.setLogin(s); } s = config.getString("sonar.jdbc.password"); if (!isEmpty(s)) { builder.setPassword(s); } s = config.getString("sonar.jdbc.rootUrl"); if (!isEmpty(s)) { builder.setRootUrl(s); } s = config.getString("sonar.jdbc.rootUsername"); if (!isEmpty(s)) { builder.setRootLogin(s); } s = config.getString("sonar.jdbc.rootPassword"); if (!isEmpty(s)) { builder.setRootPassword(s); } s = config.getString("sonar.jdbc.driverFile"); if (!isEmpty(s)) { builder.setDriverFile(new File(s)); } s = config.getString("sonar.jdbc.driverMavenKey"); if (!isEmpty(s)) { feedDriverMavenKey(locators, builder, s); } String value = config.getString("orchestrator.keepDatabase", "false"); boolean keepDatabase = !isEmpty(value) ? Boolean.valueOf(value) : false; if (keepDatabase) { builder.setDropAndCreate(false); } return builder.build(); } private  DatabaseFactory(); static DatabaseClient create(Configuration config, Locators locators);  }