DatabaseInit implements BeanDefinitionRegistryPostProcessor { @Override public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) { createRegisterDbRelatedBdf(registry); }  @Override void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory); @Override void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry);  }
@Test public void testPropertiesNotFound() throws IOException { new Expectations() { { OperateProperties.loadProperties(anyString); result = new IOException("file not found"); } }; try { databaseInit.postProcessBeanDefinitionRegistry(registry); fail("Must have exception"); } catch (BeansException e) { assertThat(e.getMessage(), is("Failed to load properties file, file name : localCache; nested exception is java.io.IOException: file not found")); } }
@Test public void testNoDataSourceCfg(@Mocked DataSourceCfgUtil dataSourceCfgUtil, @Mocked ZebraShardingConfigurationUtil zebraShardingConfigurationUtil) { new Expectations() { { DataSourceCfgUtil.getDataSourceCfgList(); result = Collections.emptyList(); } }; databaseInit.postProcessBeanDefinitionRegistry(registry); new Verifications() { { ZebraShardingConfigurationUtil.getZebraShardingConfiguration(); times = 0; } }; }