DataSourceFactory { static Properties createDataSourceProperties(List<ConfigProperty> props) { Properties result = new Properties(); if (props != null) { for (ConfigProperty prop : props) { if (prop.getName().toLowerCase().startsWith(POOL_PREFIX)) { continue; } result.setProperty(prop.getName(), prop.getValue()); } } return result; } DataSourceFactory(); DataSource getSimpleDataSource(Map configMap); ClientConnectionFactoryWrapper getManagedDataSource(Map configMap,
      List<ConfigProperty> props); DataSource getPooledDataSource(Map configMap, List<ConfigProperty> props); DataSource getTranxDataSource(Map configMap, List<ConfigProperty> props); static void setTestConnectionUrl(String url); static void setTestConnectionHost(String host); static void setTestConnectionPort(String port);  }
@Test public void createDataSourcePropertiesWithNullReturnsEmpty() { Properties output = DataSourceFactory.createDataSourceProperties(null); assertThat(output).isEmpty(); }
@Test public void createDataSourcePropertiesWithEmptyListReturnsEmpty() { Properties output = DataSourceFactory.createDataSourceProperties(configProperties); assertThat(output).isEmpty(); }
@Test public void createDataSourcePropertiesWithPoolPropertyReturnsEmpty() { configProperties.add(new ConfigProperty("pool.n1", "v1", null)); Properties output = DataSourceFactory.createDataSourceProperties(configProperties); assertThat(output).isEmpty(); }
@Test public void createDataSourcePropertiesWithNonPoolPropertyReturnsOne() { configProperties.add(new ConfigProperty("n1", "v1", null)); Properties output = DataSourceFactory.createDataSourceProperties(configProperties); assertThat(output.size()).isEqualTo(1); assertThat(output.getProperty("n1")).isEqualTo("v1"); }
@Test public void createDataSourcePropertiesWithMuliplePropertiesReturnsJustNonPool() { configProperties.add(new ConfigProperty("n1", "v1", null)); configProperties.add(new ConfigProperty("pool.n3", "v3", null)); configProperties.add(new ConfigProperty("n2", "v2", null)); Properties output = DataSourceFactory.createDataSourceProperties(configProperties); assertThat(output.size()).isEqualTo(2); assertThat(output.getProperty("n1")).isEqualTo("v1"); assertThat(output.getProperty("n2")).isEqualTo("v2"); }