本文整理汇总了Java中org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java EmbeddedDataSourceConfiguration类的具体用法?Java EmbeddedDataSourceConfiguration怎么用?Java EmbeddedDataSourceConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EmbeddedDataSourceConfiguration类属于org.springframework.boot.autoconfigure.jdbc包,在下文中一共展示了EmbeddedDataSourceConfiguration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testUsingJpa
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; //导入依赖的package包/类
@Test
public void testUsingJpa() throws Exception {
this.context = new AnnotationConfigApplicationContext();
// The order is very important here: DataSource -> Hibernate -> Batch
this.context.register(TestConfiguration.class,
EmbeddedDataSourceConfiguration.class,
HibernateJpaAutoConfiguration.class, BatchAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
PlatformTransactionManager transactionManager = this.context
.getBean(PlatformTransactionManager.class);
// It's a lazy proxy, but it does render its target if you ask for toString():
assertThat(transactionManager.toString().contains("JpaTransactionManager"))
.isTrue();
assertThat(this.context.getBean(EntityManagerFactory.class)).isNotNull();
// Ensure the JobRepository can be used (no problem with isolation level)
assertThat(this.context.getBean(JobRepository.class).getLastJobExecution("job",
new JobParameters())).isNull();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:20,代码来源:BatchAutoConfigurationTests.java
示例2: testRenamePrefix
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; //导入依赖的package包/类
@Test
public void testRenamePrefix() throws Exception {
this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"spring.datasource.name:batchtest",
"spring.batch.schema:classpath:batch/custom-schema-hsql.sql",
"spring.batch.tablePrefix:PREFIX_");
this.context.register(TestConfiguration.class,
EmbeddedDataSourceConfiguration.class,
HibernateJpaAutoConfiguration.class, BatchAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(JobLauncher.class)).isNotNull();
assertThat(new JdbcTemplate(this.context.getBean(DataSource.class))
.queryForList("select * from PREFIX_JOB_EXECUTION")).isEmpty();
JobExplorer jobExplorer = this.context.getBean(JobExplorer.class);
assertThat(jobExplorer.findRunningJobExecutions("test")).isEmpty();
JobRepository jobRepository = this.context.getBean(JobRepository.class);
assertThat(jobRepository.getLastJobExecution("test", new JobParameters()))
.isNull();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:22,代码来源:BatchAutoConfigurationTests.java
示例3: testDefaultRepositoryConfiguration
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; //导入依赖的package包/类
@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();
}
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:18,代码来源:JpaWebAutoConfigurationTests.java
示例4: setupContextForGraph
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; //导入依赖的package包/类
private void setupContextForGraph(String graph) {
String[] ARGS = new String[] {CLOSE_CONTEXT_ARG, TASK_NAME_ARG, "--graph=" + graph};
this.applicationContext = SpringApplication.run(new Object[] {ComposedRunnerVisitorConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
EmbeddedDataSourceConfiguration.class,
BatchAutoConfiguration.class,
TaskBatchAutoConfiguration.class}, ARGS);
}
开发者ID:spring-cloud-task-app-starters,项目名称:composed-task-runner,代码行数:10,代码来源:ComposedRunnerVisitorTests.java
示例5: dataSourceHealthIndicator
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; //导入依赖的package包/类
@Test
public void dataSourceHealthIndicator() {
this.context.register(EmbeddedDataSourceConfiguration.class,
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context,
"management.health.diskspace.enabled:false");
this.context.refresh();
Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class);
assertThat(beans).hasSize(1);
assertThat(beans.values().iterator().next().getClass())
.isEqualTo(DataSourceHealthIndicator.class);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:HealthIndicatorAutoConfigurationTests.java
示例6: testOpenEntityManagerInViewInterceptorNotRegisteredWhenExplicitlyOff
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; //导入依赖的package包/类
@Test
public void testOpenEntityManagerInViewInterceptorNotRegisteredWhenExplicitlyOff()
throws Exception {
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
EnvironmentTestUtils.addEnvironment(context, "spring.jpa.open_in_view:false");
context.register(TestConfiguration.class, EmbeddedDataSourceConfiguration.class,
PropertyPlaceholderAutoConfiguration.class, getAutoConfigureClass());
context.refresh();
assertThat(getInterceptorBeans(context).length).isEqualTo(0);
context.close();
}
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:12,代码来源:AbstractJpaAutoConfigurationTests.java
示例7: healthEndpoint
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; //导入依赖的package包/类
@Test
public void healthEndpoint() {
load(EmbeddedDataSourceConfiguration.class, EndpointAutoConfiguration.class,
HealthIndicatorAutoConfiguration.class);
HealthEndpoint bean = this.context.getBean(HealthEndpoint.class);
assertThat(bean).isNotNull();
Health result = bean.invoke();
assertThat(result).isNotNull();
assertThat(result.getDetails().containsKey("db")).isTrue();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:EndpointAutoConfigurationTests.java
示例8: testFlywayEndpoint
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; //导入依赖的package包/类
@Test
public void testFlywayEndpoint() {
this.context = new AnnotationConfigApplicationContext();
this.context.register(EmbeddedDataSourceConfiguration.class,
FlywayAutoConfiguration.class, EndpointAutoConfiguration.class);
this.context.refresh();
FlywayEndpoint endpoint = this.context.getBean(FlywayEndpoint.class);
assertThat(endpoint).isNotNull();
assertThat(endpoint.invoke()).hasSize(1);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:EndpointAutoConfigurationTests.java
示例9: testOverrideParameters
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testOverrideParameters() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, "liquibase.parameters.foo:bar");
this.context.register(EmbeddedDataSourceConfiguration.class,
LiquibaseAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
SpringLiquibase liquibase = this.context.getBean(SpringLiquibase.class);
Map<String, String> parameters = (Map<String, String>) ReflectionTestUtils
.getField(liquibase, "parameters");
assertThat(parameters.containsKey("foo")).isTrue();
assertThat(parameters.get("foo")).isEqualTo("bar");
}
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:15,代码来源:LiquibaseAutoConfigurationTests.java
示例10: defaultConfig
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; //导入依赖的package包/类
@Test
public void defaultConfig() {
load(Arrays.asList(EmbeddedDataSourceConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class),
"spring.session.store-type=jdbc");
JdbcOperationsSessionRepository repository = validateSessionRepository(
JdbcOperationsSessionRepository.class);
assertThat(new DirectFieldAccessor(repository).getPropertyValue("tableName"))
.isEqualTo("SPRING_SESSION");
assertThat(this.context.getBean(JdbcOperations.class)
.queryForList("select * from SPRING_SESSION")).isEmpty();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:SessionAutoConfigurationJdbcTests.java
示例11: disableDatabaseInitializer
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; //导入依赖的package包/类
@Test
public void disableDatabaseInitializer() {
load(Arrays.asList(EmbeddedDataSourceConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class),
"spring.session.store-type=jdbc",
"spring.session.jdbc.initializer.enabled=false");
JdbcOperationsSessionRepository repository = validateSessionRepository(
JdbcOperationsSessionRepository.class);
assertThat(new DirectFieldAccessor(repository).getPropertyValue("tableName"))
.isEqualTo("SPRING_SESSION");
this.thrown.expect(BadSqlGrammarException.class);
assertThat(this.context.getBean(JdbcOperations.class)
.queryForList("select * from SPRING_SESSION")).isEmpty();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:15,代码来源:SessionAutoConfigurationJdbcTests.java
示例12: customTableName
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; //导入依赖的package包/类
@Test
public void customTableName() {
load(Arrays.asList(EmbeddedDataSourceConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class),
"spring.session.store-type=jdbc",
"spring.session.jdbc.table-name=FOO_BAR",
"spring.session.jdbc.schema=classpath:session/custom-schema-h2.sql");
JdbcOperationsSessionRepository repository = validateSessionRepository(
JdbcOperationsSessionRepository.class);
assertThat(new DirectFieldAccessor(repository).getPropertyValue("tableName"))
.isEqualTo("FOO_BAR");
assertThat(this.context.getBean(JdbcOperations.class)
.queryForList("select * from FOO_BAR")).isEmpty();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:15,代码来源:SessionAutoConfigurationJdbcTests.java
示例13: prepareApplicationContext
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; //导入依赖的package包/类
private void prepareApplicationContext(Class<?>... configurationClasses) {
this.context = new AnnotationConfigApplicationContext();
this.context.register(configurationClasses);
this.context.register(EmbeddedDataSourceConfiguration.class,
HibernateJpaAutoConfiguration.class,
JpaRepositoriesAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:JpaRepositoriesAutoConfigurationTests.java
示例14: persistOfNullThrowsIllegalArgumentExceptionWithoutExceptionTranslation
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void persistOfNullThrowsIllegalArgumentExceptionWithoutExceptionTranslation() {
this.context = new AnnotationConfigApplicationContext(
EmbeddedDataSourceConfiguration.class,
HibernateJpaAutoConfiguration.class, TestConfiguration.class);
this.context.getBean(TestRepository.class).doSomething();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:PersistenceExceptionTranslationAutoConfigurationTests.java
示例15: persistOfNullThrowsInvalidDataAccessApiUsageExceptionWithExceptionTranslation
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; //导入依赖的package包/类
@Test(expected = InvalidDataAccessApiUsageException.class)
public void persistOfNullThrowsInvalidDataAccessApiUsageExceptionWithExceptionTranslation() {
this.context = new AnnotationConfigApplicationContext(
EmbeddedDataSourceConfiguration.class,
HibernateJpaAutoConfiguration.class, TestConfiguration.class,
PersistenceExceptionTranslationAutoConfiguration.class);
this.context.getBean(TestRepository.class).doSomething();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:PersistenceExceptionTranslationAutoConfigurationTests.java
示例16: createDataSource
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; //导入依赖的package包/类
@Test
public void createDataSource() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context,
"flyway.url:jdbc:hsqldb:mem:flywaytest", "flyway.user:sa");
registerAndRefresh(EmbeddedDataSourceConfiguration.class,
FlywayAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
Flyway flyway = this.context.getBean(Flyway.class);
assertThat(flyway.getDataSource()).isNotNull();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:FlywayAutoConfigurationTests.java
示例17: flywayDataSource
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; //导入依赖的package包/类
@Test
public void flywayDataSource() throws Exception {
registerAndRefresh(FlywayDataSourceConfiguration.class,
EmbeddedDataSourceConfiguration.class, FlywayAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
Flyway flyway = this.context.getBean(Flyway.class);
assertThat(flyway.getDataSource()).isNotNull();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:FlywayAutoConfigurationTests.java
示例18: defaultFlyway
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; //导入依赖的package包/类
@Test
public void defaultFlyway() throws Exception {
registerAndRefresh(EmbeddedDataSourceConfiguration.class,
FlywayAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
Flyway flyway = this.context.getBean(Flyway.class);
assertThat(flyway.getLocations()).containsExactly("classpath:db/migration");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:FlywayAutoConfigurationTests.java
示例19: overrideLocations
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; //导入依赖的package包/类
@Test
public void overrideLocations() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context,
"flyway.locations:classpath:db/changelog,classpath:db/migration");
registerAndRefresh(EmbeddedDataSourceConfiguration.class,
FlywayAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
Flyway flyway = this.context.getBean(Flyway.class);
assertThat(flyway.getLocations()).containsExactly("classpath:db/changelog",
"classpath:db/migration");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:FlywayAutoConfigurationTests.java
示例20: testOpenEntityManagerInViewInterceptorNotRegisteredWhenFilterPresent
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; //导入依赖的package包/类
@Test
public void testOpenEntityManagerInViewInterceptorNotRegisteredWhenFilterPresent()
throws Exception {
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.register(TestFilterConfiguration.class,
EmbeddedDataSourceConfiguration.class,
PropertyPlaceholderAutoConfiguration.class, getAutoConfigureClass());
context.refresh();
assertThat(getInterceptorBeans(context).length).isEqualTo(0);
context.close();
}
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:12,代码来源:AbstractJpaAutoConfigurationTests.java
注:本文中的org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论