@Test void afterPropertiesSet_noUserNameSet_createsInstanceWithUserNameFromMetaData() throws Exception { AmazonRDS amazonRDS = mock(AmazonRDS.class); DataSourceFactory dataSourceFactory = mock(DataSourceFactory.class); DataSource dataSource = mock(DataSource.class); when(amazonRDS.describeDBInstances(new DescribeDBInstancesRequest() .withDBInstanceIdentifier("test"))).thenReturn( new DescribeDBInstancesResult().withDBInstances(new DBInstance() .withDBInstanceStatus("available").withDBName("test") .withDBInstanceIdentifier("test").withEngine("mysql") .withMasterUsername("admin").withEndpoint(new Endpoint() .withAddress("localhost").withPort(3306)))); when(dataSourceFactory.createDataSource(new DataSourceInformation( DatabaseType.MYSQL, "localhost", 3306, "test", "admin", "secret"))) .thenReturn(dataSource); AmazonRdsDataSourceFactoryBean amazonRdsDataSourceFactoryBean = new AmazonRdsDataSourceFactoryBean( amazonRDS, "test", "secret"); amazonRdsDataSourceFactoryBean.setDataSourceFactory(dataSourceFactory); amazonRdsDataSourceFactoryBean.afterPropertiesSet(); DataSource datasource = amazonRdsDataSourceFactoryBean.getObject(); assertThat(datasource).isNotNull(); verify(dataSourceFactory, times(1)).createDataSource(new DataSourceInformation( DatabaseType.MYSQL, "localhost", 3306, "test", "admin", "secret")); }
public void setDataSourceFactory(DataSourceFactory dataSourceFactory) { this.dataSourceFactory = dataSourceFactory; }
AmazonRdsDataSourceFactoryBean extends AbstractFactoryBean<DataSource> { public void setDataSourceFactory(DataSourceFactory dataSourceFactory) { this.dataSourceFactory = dataSourceFactory; } }
AmazonRdsDataSourceFactoryBean extends AbstractFactoryBean<DataSource> { public void setDataSourceFactory(DataSourceFactory dataSourceFactory) { this.dataSourceFactory = dataSourceFactory; } AmazonRdsDataSourceFactoryBean(AmazonRDS amazonRds,
			String dbInstanceIdentifier, String password); }
AmazonRdsDataSourceFactoryBean extends AbstractFactoryBean<DataSource> { public void setDataSourceFactory(DataSourceFactory dataSourceFactory) { this.dataSourceFactory = dataSourceFactory; } AmazonRdsDataSourceFactoryBean(AmazonRDS amazonRds,
			String dbInstanceIdentifier, String password); void setDataSourceFactory(DataSourceFactory dataSourceFactory); void setUsername(String username); void setDatabaseName(String databaseName); void setResourceIdResolver(ResourceIdResolver resourceIdResolver); @Override Class<DataSource> getObjectType(); }
AmazonRdsDataSourceFactoryBean extends AbstractFactoryBean<DataSource> { public void setDataSourceFactory(DataSourceFactory dataSourceFactory) { this.dataSourceFactory = dataSourceFactory; } AmazonRdsDataSourceFactoryBean(AmazonRDS amazonRds,
			String dbInstanceIdentifier, String password); void setDataSourceFactory(DataSourceFactory dataSourceFactory); void setUsername(String username); void setDatabaseName(String databaseName); void setResourceIdResolver(ResourceIdResolver resourceIdResolver); @Override Class<DataSource> getObjectType();  }