DatasourceConfig { @Bean @Primary DataSource datasource(final DataSourceProperties datasourceProperties) { final DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName(datasourceProperties.getDriverClassName()); dataSource.setUsername(datasourceProperties.getUsername()); dataSource.setPassword(datasourceProperties.getPassword()); dataSource.setUrl(datasourceProperties.getUrl()); return dataSource; }    }
@Test public void test() { Mockito.when(mockDataSourceProperties.getDriverClassName()).thenReturn(DRIVER_CLASS_NAME); Mockito.when(mockDataSourceProperties.getUsername()).thenReturn(USERNAME); Mockito.when(mockDataSourceProperties.getPassword()).thenReturn(PASSWORD); Mockito.when(mockDataSourceProperties.getUrl()).thenReturn(URL); datasourceConfig.datasource(mockDataSourceProperties); Mockito.verify(mockDataSourceProperties).getDriverClassName(); Mockito.verify(mockDataSourceProperties).getUsername(); Mockito.verify(mockDataSourceProperties).getPassword(); Mockito.verify(mockDataSourceProperties).getUrl(); }