@Test public void shouldSetDbNameOnDataSourceWhenConnectionPropertiesSupportedAndDbNameNotEmpty() throws Exception { given(config.getDataSourceType()).willReturn(XQueryDataSourceType.SEDNA); given(config.getDatabaseName()).willReturn(DB_NAME); factory.getDataSource(); verify(dataSource).setProperty(DATABASE_NAME, DB_NAME); }
public XQDataSource getDataSource() throws Exception { XQueryDataSourceType dataSourceType = config.getDataSourceType(); XQDataSource dataSource = getXQDataSource(dataSourceType, config); if (dataSourceType.connectionPropertiesAreSupported()) { if (config.getHost() != null && config.getHost().length() > 0) { dataSource.setProperty(SERVER_NAME, config.getHost()); } if (config.getPort() != null && config.getPort().length() > 0) { dataSource.setProperty(PORT, config.getPort()); } if (config.getDatabaseName() != null && config.getDatabaseName().length() > 0) { dataSource.setProperty(DATABASE_NAME, config.getDatabaseName()); } } return dataSource; }
DataSourceFactory { public XQDataSource getDataSource() throws Exception { XQueryDataSourceType dataSourceType = config.getDataSourceType(); XQDataSource dataSource = getXQDataSource(dataSourceType, config); if (dataSourceType.connectionPropertiesAreSupported()) { if (config.getHost() != null && config.getHost().length() > 0) { dataSource.setProperty(SERVER_NAME, config.getHost()); } if (config.getPort() != null && config.getPort().length() > 0) { dataSource.setProperty(PORT, config.getPort()); } if (config.getDatabaseName() != null && config.getDatabaseName().length() > 0) { dataSource.setProperty(DATABASE_NAME, config.getDatabaseName()); } } return dataSource; } }
DataSourceFactory { public XQDataSource getDataSource() throws Exception { XQueryDataSourceType dataSourceType = config.getDataSourceType(); XQDataSource dataSource = getXQDataSource(dataSourceType, config); if (dataSourceType.connectionPropertiesAreSupported()) { if (config.getHost() != null && config.getHost().length() > 0) { dataSource.setProperty(SERVER_NAME, config.getHost()); } if (config.getPort() != null && config.getPort().length() > 0) { dataSource.setProperty(PORT, config.getPort()); } if (config.getDatabaseName() != null && config.getDatabaseName().length() > 0) { dataSource.setProperty(DATABASE_NAME, config.getDatabaseName()); } } return dataSource; } DataSourceFactory(XQueryRunConfig config); }
DataSourceFactory { public XQDataSource getDataSource() throws Exception { XQueryDataSourceType dataSourceType = config.getDataSourceType(); XQDataSource dataSource = getXQDataSource(dataSourceType, config); if (dataSourceType.connectionPropertiesAreSupported()) { if (config.getHost() != null && config.getHost().length() > 0) { dataSource.setProperty(SERVER_NAME, config.getHost()); } if (config.getPort() != null && config.getPort().length() > 0) { dataSource.setProperty(PORT, config.getPort()); } if (config.getDatabaseName() != null && config.getDatabaseName().length() > 0) { dataSource.setProperty(DATABASE_NAME, config.getDatabaseName()); } } return dataSource; } DataSourceFactory(XQueryRunConfig config); XQDataSource getDataSource(); }
DataSourceFactory { public XQDataSource getDataSource() throws Exception { XQueryDataSourceType dataSourceType = config.getDataSourceType(); XQDataSource dataSource = getXQDataSource(dataSourceType, config); if (dataSourceType.connectionPropertiesAreSupported()) { if (config.getHost() != null && config.getHost().length() > 0) { dataSource.setProperty(SERVER_NAME, config.getHost()); } if (config.getPort() != null && config.getPort().length() > 0) { dataSource.setProperty(PORT, config.getPort()); } if (config.getDatabaseName() != null && config.getDatabaseName().length() > 0) { dataSource.setProperty(DATABASE_NAME, config.getDatabaseName()); } } return dataSource; } DataSourceFactory(XQueryRunConfig config); XQDataSource getDataSource(); static final String SERVER_NAME; static final String PORT; static final String DATABASE_NAME; }