org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration Java Examples
The following examples show how to use
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: N2oAutoConfigurationTest.java From n2o-framework with Apache License 2.0 | 6 votes |
@Test public void sql() { new ApplicationContextRunner() .withPropertyValues("spring.datasource.driver-class-name=org.h2.Driver", "spring.datasource.url=jdbc:h2:mem:test", "spring.datasource.username=sa", "spring.datasource.password=sa") // .withClassLoader(new FilteredClassLoader(JdbcTemplate.class)) .withConfiguration(AutoConfigurations.of( DataSourceAutoConfiguration.class, JdbcTemplateAutoConfiguration.class, N2oSqlAutoConfiguration.class)).run(ctx -> { assertThat(ctx).hasSingleBean(SqlInvocationEngine.class); assertThat(ctx).hasSingleBean(SqlDataProviderEngine.class); assertThat(ctx).hasSingleBean(PostgresIndexRowMapper.class); }); }
Example #2
Source File: ProcessEngineAutoConfigurationTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Test public void processEngineWithJpaEntityManager() throws Exception { AnnotationConfigApplicationContext context = this.context(DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class, JpaProcessEngineAutoConfiguration.JpaConfiguration.class); Assert.assertNotNull("entityManagerFactory should not be null", context.getBean(EntityManagerFactory.class)); Assert.assertNotNull("the processEngine should not be null!", context.getBean(ProcessEngine.class)); SpringProcessEngineConfiguration configuration = context.getBean(SpringProcessEngineConfiguration.class); Assert.assertNotNull("the " + SpringProcessEngineConfiguration.class.getName() + " should not be null", configuration); Assert.assertNotNull(configuration.getJpaEntityManagerFactory()); }
Example #3
Source File: ProcessEngineAutoConfigurationTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Test public void launchProcessDefinition() throws Exception { AnnotationConfigApplicationContext applicationContext = this.context( DataSourceAutoConfiguration.class, DataSourceProcessEngineAutoConfiguration.DataSourceProcessEngineConfiguration.class); RepositoryService repositoryService = applicationContext.getBean(RepositoryService.class); Assert.assertNotNull("we should have a default repositoryService included", repositoryService); Assert.assertEquals(2, repositoryService.createProcessDefinitionQuery().count()); List<ProcessDefinition> processDefinitionList = repositoryService.createProcessDefinitionQuery() .processDefinitionKey("waiter") .list(); Assert.assertNotNull(processDefinitionList); Assert.assertTrue(!processDefinitionList.isEmpty()); ProcessDefinition processDefinition = processDefinitionList.iterator().next(); Assert.assertEquals("waiter", processDefinition.getKey()); }
Example #4
Source File: FlowableJpaAutoConfigurationTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void withEntityManagerFactoryBeanAndMissingSpringProcessEngineConfigurationClass() { contextRunner .withConfiguration(AutoConfigurations.of( DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class )) .withClassLoader(new FilteredClassLoader(SpringProcessEngineConfiguration.class)) .run(context -> { assertThat(context).doesNotHaveBean(FlowableJpaAutoConfiguration.class); }); }
Example #5
Source File: ShellCommandsTests.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
/** * Runs shell with given command files, waits 1 min for completion * @param commandFiles */ private boolean runShell(String commandFiles) { String dataFlowUri = applicationContext.getEnvironment().getProperty("dataflow.uri"); ExecutorService executorService = Executors.newFixedThreadPool(1); Future<?> completed = executorService.submit(() -> { new SpringApplicationBuilder(ShellApp.class) .web(WebApplicationType.NONE) .bannerMode(Banner.Mode.OFF) .run( "--spring.shell.command-file=" + commandFiles, "--spring.cloud.config.enabled=false", "--spring.autoconfigure.exclude=" + Stream.of(SessionAutoConfiguration.class, DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class) .map(Class::getName) .collect(Collectors.joining(",")), "--dataflow.uri=" + dataFlowUri ); }); try { completed.get(60, TimeUnit.SECONDS); return true; } catch (Throwable e) { // return false; // TODO: BOOT2 we're getting app run error. Might be something to do with reordering of events when boot runs an app. // There's checks for app run result so for now just return true. // o.s.b.SpringApplication:845 - Application run failed // java.lang.IllegalStateException: org.springframework.context.annotation.AnnotationConfigApplicationContext@377f9cb6 has been closed already // return true; } finally { executorService.shutdownNow(); } }
Example #6
Source File: DataFlowServerConfigurationTests.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
@Before public void setup() { context = new AnnotationConfigApplicationContext(); context.setId("testDataFlowConfig"); context.register(DataFlowServerConfigurationTests.TestConfiguration.class, SecurityAutoConfiguration.class, DataFlowServerAutoConfiguration.class, DataFlowControllerAutoConfiguration.class, DataSourceAutoConfiguration.class, DataFlowServerConfiguration.class, PropertyPlaceholderAutoConfiguration.class, RestTemplateAutoConfiguration.class, HibernateJpaAutoConfiguration.class, WebConfiguration.class, SchedulerConfiguration.class, JacksonAutoConfiguration.class, SimpleTaskAutoConfiguration.class, ResourceLoadingAutoConfiguration.class); environment = new StandardEnvironment(); propertySources = environment.getPropertySources(); }
Example #7
Source File: ProcessEngineAutoConfigurationTest.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
@Test public void processEngineWithBasicDataSource() throws Exception { AnnotationConfigApplicationContext context = this.context( DataSourceAutoConfiguration.class, DataSourceProcessEngineAutoConfiguration.DataSourceProcessEngineConfiguration.class); Assert.assertNotNull("the processEngine should not be null!", context.getBean(ProcessEngine.class)); }
Example #8
Source File: FlowableJpaAutoConfigurationTest.java From flowable-engine with Apache License 2.0 | 4 votes |
@Test public void withEntityManagerFactoryBeanAndSpringProcessEngineConfigurationClass() { contextRunner .withConfiguration(AutoConfigurations.of( DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class )) .run(context -> { assertThat(context) .hasSingleBean(FlowableJpaAutoConfiguration.class) .hasBean("jpaProcessEngineConfigurer"); EntityManagerFactory entityManagerFactory = context.getBean(EntityManagerFactory.class); @SuppressWarnings("unchecked") EngineConfigurationConfigurer<SpringProcessEngineConfiguration> jpaProcessEngineConfigurer = (EngineConfigurationConfigurer<SpringProcessEngineConfiguration>) context .getBean("jpaProcessEngineConfigurer", EngineConfigurationConfigurer.class); SpringProcessEngineConfiguration configuration = new SpringProcessEngineConfiguration(); assertThat(configuration.getJpaEntityManagerFactory()) .as("Process JPA Entity Manager Factory") .isNull(); assertThat(configuration.isJpaHandleTransaction()) .as("Process JPA handle transaction") .isFalse(); assertThat(configuration.isJpaCloseEntityManager()) .as("Process JPA close entity manager") .isFalse(); jpaProcessEngineConfigurer.configure(configuration); assertThat(configuration.getJpaEntityManagerFactory()) .as("Process JPA Entity Manager Factory") .isSameAs(entityManagerFactory); assertThat(configuration.isJpaHandleTransaction()) .as("Process JPA handle transaction") .isFalse(); assertThat(configuration.isJpaCloseEntityManager()) .as("Process JPA close entity manager") .isFalse(); }); }
Example #9
Source File: CamundaBpmWebappAutoConfigurationIntegrationTest.java From camunda-bpm-spring-boot-starter with Apache License 2.0 | 4 votes |
@Before public void setUp() { AutoConfigurations autoConfigurationsUnderTest = AutoConfigurations.of(CamundaBpmAutoConfiguration.class, CamundaBpmWebappAutoConfiguration.class); AutoConfigurations additionalAutoConfigurations = AutoConfigurations.of(DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class); contextRunner = new WebApplicationContextRunner().withConfiguration(autoConfigurationsUnderTest).withConfiguration(additionalAutoConfigurations); }
Example #10
Source File: CamundaBpmWebappAutoConfigurationIntegrationTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Before public void setUp() { AutoConfigurations autoConfigurationsUnderTest = AutoConfigurations.of(CamundaBpmAutoConfiguration.class, CamundaBpmWebappAutoConfiguration.class); AutoConfigurations additionalAutoConfigurations = AutoConfigurations.of(DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class); contextRunner = new WebApplicationContextRunner().withConfiguration(autoConfigurationsUnderTest).withConfiguration(additionalAutoConfigurations); }