DistributedLockServiceMySqlImpl implements DistributedLockService { @Autowired(required = false) @Qualifier("distLockingDataSource") public void setSmartDataSource(DataSource dataSource) { if (dataSource != null) this.jdbcTemplate = new JdbcTemplate( dataSource); }  @Autowired(required = false) @Qualifier("distLockingDataSource") void setSmartDataSource(DataSource dataSource); @Override boolean tryLock(String key); @Override boolean tryReleaseLock(String key); void setJdbcTemplate(JdbcTemplate jdbcTemplate);  }
@Test public void setDataSourceNull() { service.setSmartDataSource(null); assertThat(service.jdbcTemplate, is(template)); }
@Test public void setDataSource() { service.setSmartDataSource(mock(SmartDataSource.class)); assertThat(service.jdbcTemplate, not(template)); }