@Test public void testDefaultRepositoryConfiguration() throws Exception { this.context = new AnnotationConfigWebApplicationContext(); this.context.setServletContext(new MockServletContext()); this.context.register(TestConfiguration.class, EmbeddedDataSourceConfiguration.class, HibernateJpaAutoConfiguration.class, JpaRepositoriesAutoConfiguration.class, SpringDataWebAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); this.context.refresh(); assertThat(this.context.getBean(CityRepository.class)).isNotNull(); assertThat(this.context.getBean(PageableHandlerMethodArgumentResolver.class)) .isNotNull(); assertThat(this.context.getBean(FormattingConversionService.class) .canConvert(Long.class, City.class)).isTrue(); }
@Test public void testDefaultRepositoryConfiguration() throws Exception { this.context = new AnnotationConfigWebApplicationContext(); this.context.setServletContext(new MockServletContext()); this.context.register(TestConfiguration.class, EmbeddedDataSourceConfiguration.class, HibernateJpaAutoConfiguration.class, JpaRepositoriesAutoConfiguration.class, SpringDataWebAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); this.context.refresh(); assertNotNull(this.context.getBean(CityRepository.class)); assertNotNull(this.context.getBean(PageableHandlerMethodArgumentResolver.class)); assertTrue(this.context.getBean(FormattingConversionService.class) .canConvert(Long.class, City.class)); }
@Test public void testMixedRepositoryConfiguration() throws Exception { this.context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, "spring.datasource.initialize:false"); this.context.register(MixedConfiguration.class, BaseConfiguration.class); this.context.refresh(); assertThat(this.context.getBean(CountryRepository.class)).isNotNull(); assertThat(this.context.getBean(CityRepository.class)).isNotNull(); }
@Test public void testMixedRepositoryConfigurationWithDeprecatedEntityScan() throws Exception { this.context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, "spring.datasource.initialize:false"); this.context.register(MixedConfigurationWithDeprecatedEntityScan.class, BaseConfiguration.class); this.context.refresh(); assertThat(this.context.getBean(CountryRepository.class)).isNotNull(); assertThat(this.context.getBean(CityRepository.class)).isNotNull(); }
@Test public void testJpaRepositoryConfigurationWithMongoTemplate() throws Exception { this.context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, "spring.datasource.initialize:false"); this.context.register(JpaConfiguration.class, BaseConfiguration.class); this.context.refresh(); assertThat(this.context.getBean(CityRepository.class)).isNotNull(); }
@Test public void testJpaRepositoryConfigurationWithMongoTemplateAndDeprecatedEntityScan() throws Exception { this.context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, "spring.datasource.initialize:false"); this.context.register(JpaConfigurationWithDeprecatedEntityScan.class, BaseConfiguration.class); this.context.refresh(); assertThat(this.context.getBean(CityRepository.class)).isNotNull(); }
@Test public void testJpaRepositoryConfigurationWithMongoOverlap() throws Exception { this.context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, "spring.datasource.initialize:false"); this.context.register(OverlapConfiguration.class, BaseConfiguration.class); this.context.refresh(); assertThat(this.context.getBean(CityRepository.class)).isNotNull(); }
@Test public void testJpaRepositoryConfigurationWithMongoOverlapDisabled() throws Exception { this.context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, "spring.datasource.initialize:false", "spring.data.mongodb.repositories.enabled:false"); this.context.register(OverlapConfiguration.class, BaseConfiguration.class); this.context.refresh(); assertThat(this.context.getBean(CityRepository.class)).isNotNull(); }
@Test public void testMixedRepositoryConfiguration() throws Exception { EnvironmentTestUtils.addEnvironment(this.context, "spring.datasource.initialize:false"); this.context.register(MixedConfiguration.class, BaseConfiguration.class); this.context.refresh(); assertThat(this.context.getBean(CountryRepository.class)).isNotNull(); assertThat(this.context.getBean(CityRepository.class)).isNotNull(); }
@Test public void testJpaRepositoryConfigurationWithNeo4jTemplate() throws Exception { EnvironmentTestUtils.addEnvironment(this.context, "spring.datasource.initialize:false"); this.context.register(JpaConfiguration.class, BaseConfiguration.class); this.context.refresh(); assertThat(this.context.getBean(CityRepository.class)).isNotNull(); }
@Test @Ignore public void testJpaRepositoryConfigurationWithNeo4jOverlap() throws Exception { EnvironmentTestUtils.addEnvironment(this.context, "spring.datasource.initialize:false"); this.context.register(OverlapConfiguration.class, BaseConfiguration.class); this.context.refresh(); assertThat(this.context.getBean(CityRepository.class)).isNotNull(); }
@Test public void testJpaRepositoryConfigurationWithNeo4jOverlapDisabled() throws Exception { EnvironmentTestUtils.addEnvironment(this.context, "spring.datasource.initialize:false", "spring.data.neo4j.repositories.enabled:false"); this.context.register(OverlapConfiguration.class, BaseConfiguration.class); this.context.refresh(); assertThat(this.context.getBean(CityRepository.class)).isNotNull(); }
@Test public void testDefaultRepositoryConfiguration() throws Exception { prepareApplicationContext(TestConfiguration.class); assertThat(this.context.getBean(CityRepository.class)).isNotNull(); assertThat(this.context.getBean(PlatformTransactionManager.class)).isNotNull(); assertThat(this.context.getBean(EntityManagerFactory.class)).isNotNull(); }
@Test public void testMixedRepositoryConfiguration() throws Exception { this.context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, "spring.datasource.initialize:false"); this.context.register(MixedConfiguration.class, BaseConfiguration.class); this.context.refresh(); assertNotNull(this.context.getBean(CountryRepository.class)); assertNotNull(this.context.getBean(CityRepository.class)); }
@Test public void testJpaRepositoryConfigurationWithMongoTemplate() throws Exception { this.context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, "spring.datasource.initialize:false"); this.context.register(JpaConfiguration.class, BaseConfiguration.class); this.context.refresh(); assertNotNull(this.context.getBean(CityRepository.class)); }
@Test public void testJpaRepositoryConfigurationWithMongoOverlap() throws Exception { this.context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, "spring.datasource.initialize:false"); this.context.register(OverlapConfiguration.class, BaseConfiguration.class); this.context.refresh(); assertNotNull(this.context.getBean(CityRepository.class)); }
@Test public void testJpaRepositoryConfigurationWithMongoOverlapDisabled() throws Exception { this.context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, "spring.datasource.initialize:false", "spring.data.mongodb.repositories.enabled:false"); this.context.register(OverlapConfiguration.class, BaseConfiguration.class); this.context.refresh(); assertNotNull(this.context.getBean(CityRepository.class)); }
@Test public void testDefaultRepositoryConfiguration() throws Exception { prepareApplicationContext(TestConfiguration.class); assertNotNull(this.context.getBean(CityRepository.class)); assertNotNull(this.context.getBean(PlatformTransactionManager.class)); assertNotNull(this.context.getBean(EntityManagerFactory.class)); }
@Test(expected = NoSuchBeanDefinitionException.class) public void autoConfigurationShouldNotKickInEvenIfManualConfigDidNotCreateAnyRepositories() { prepareApplicationContext(SortOfInvalidCustomConfiguration.class); this.context.getBean(CityRepository.class); }