Java 类org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SecurityAutoConfigurationTests.java   
@Test
public void testJpaCoexistsHappily() throws Exception {
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.setServletContext(new MockServletContext());
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.datasource.url:jdbc:hsqldb:mem:testsecdb");
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.datasource.initialize:false");
    this.context.register(EntityConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class,
            DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
            SecurityAutoConfiguration.class, ServerPropertiesAutoConfiguration.class);
    // This can fail if security @Conditionals force early instantiation of the
    // HibernateJpaAutoConfiguration (e.g. the EntityManagerFactory is not found)
    this.context.refresh();
    assertThat(this.context.getBean(JpaTransactionManager.class)).isNotNull();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:JpaWebAutoConfigurationTests.java   
@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();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:BatchAutoConfigurationTests.java   
@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();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:BatchAutoConfigurationTests.java   
@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();
}
项目:flowable-engine    文件:ProcessEngineAutoConfigurationTest.java   
@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());
}
项目:spring-boot-concourse    文件:SecurityAutoConfigurationTests.java   
@Test
public void testJpaCoexistsHappily() throws Exception {
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.setServletContext(new MockServletContext());
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.datasource.url:jdbc:hsqldb:mem:testsecdb");
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.datasource.initialize:false");
    this.context.register(EntityConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class,
            DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
            SecurityAutoConfiguration.class, ServerPropertiesAutoConfiguration.class);
    // This can fail if security @Conditionals force early instantiation of the
    // HibernateJpaAutoConfiguration (e.g. the EntityManagerFactory is not found)
    this.context.refresh();
    assertThat(this.context.getBean(JpaTransactionManager.class)).isNotNull();
}
项目:spring-boot-concourse    文件:JpaWebAutoConfigurationTests.java   
@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();
}
项目:spring-boot-concourse    文件:BatchAutoConfigurationTests.java   
@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();
}
项目:spring-boot-concourse    文件:BatchAutoConfigurationTests.java   
@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();
}
项目:contestparser    文件:SecurityAutoConfigurationTests.java   
@Test
public void testJpaCoexistsHappily() throws Exception {
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.setServletContext(new MockServletContext());
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.datasource.url:jdbc:hsqldb:mem:testsecdb");
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.datasource.initialize:false");
    this.context.register(EntityConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class,
            DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
            SecurityAutoConfiguration.class, ServerPropertiesAutoConfiguration.class);
    // This can fail if security @Conditionals force early instantiation of the
    // HibernateJpaAutoConfiguration (e.g. the EntityManagerFactory is not found)
    this.context.refresh();
    assertNotNull(this.context.getBean(JpaTransactionManager.class));
}
项目:contestparser    文件:JpaWebAutoConfigurationTests.java   
@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));
}
项目:contestparser    文件:BatchAutoConfigurationTests.java   
@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():
    assertTrue(transactionManager.toString().contains("JpaTransactionManager"));
    assertNotNull(this.context.getBean(EntityManagerFactory.class));
    // Ensure the JobRepository can be used (no problem with isolation level)
    assertNull(this.context.getBean(JobRepository.class).getLastJobExecution("job",
            new JobParameters()));
}
项目:contestparser    文件:BatchAutoConfigurationTests.java   
@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();
    assertNotNull(this.context.getBean(JobLauncher.class));
    assertEquals(0, new JdbcTemplate(this.context.getBean(DataSource.class))
            .queryForList("select * from PREFIX_JOB_EXECUTION").size());
    JobExplorer jobExplorer = this.context.getBean(JobExplorer.class);
    assertEquals(0, jobExplorer.findRunningJobExecutions("test").size());
    JobRepository jobRepository = this.context.getBean(JobRepository.class);
    assertNull(jobRepository.getLastJobExecution("test", new JobParameters()));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:MixedMongoRepositoriesAutoConfigurationTests.java   
@Override
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
    List<String> names = new ArrayList<String>();
    for (Class<?> type : new Class<?>[] { DataSourceAutoConfiguration.class,
            HibernateJpaAutoConfiguration.class,
            JpaRepositoriesAutoConfiguration.class, MongoAutoConfiguration.class,
            MongoDataAutoConfiguration.class,
            MongoRepositoriesAutoConfiguration.class }) {
        names.add(type.getName());
    }
    return names.toArray(new String[0]);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:MixedNeo4jRepositoriesAutoConfigurationTests.java   
@Override
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
    List<String> names = new ArrayList<String>();
    for (Class<?> type : new Class<?>[] { DataSourceAutoConfiguration.class,
            HibernateJpaAutoConfiguration.class,
            JpaRepositoriesAutoConfiguration.class,
            Neo4jDataAutoConfiguration.class,
            Neo4jRepositoriesAutoConfiguration.class }) {
        names.add(type.getName());
    }
    return names.toArray(new String[names.size()]);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:JpaRepositoriesAutoConfigurationTests.java   
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();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PersistenceExceptionTranslationAutoConfigurationTests.java   
@Test(expected = IllegalArgumentException.class)
public void persistOfNullThrowsIllegalArgumentExceptionWithoutExceptionTranslation() {
    this.context = new AnnotationConfigApplicationContext(
            EmbeddedDataSourceConfiguration.class,
            HibernateJpaAutoConfiguration.class, TestConfiguration.class);
    this.context.getBean(TestRepository.class).doSomething();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PersistenceExceptionTranslationAutoConfigurationTests.java   
@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();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:HazelcastJpaDependencyAutoConfigurationTests.java   
public void load(Class<?> config) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    if (config != null) {
        ctx.register(config);
    }
    ctx.register(EmbeddedDataSourceConfiguration.class,
            DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class);
    ctx.register(HazelcastJpaDependencyAutoConfiguration.class);
    ctx.refresh();
    this.context = ctx;
}
项目:spring-boot-concourse    文件:MixedMongoRepositoriesAutoConfigurationTests.java   
@Override
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
    List<String> names = new ArrayList<String>();
    for (Class<?> type : new Class<?>[] { DataSourceAutoConfiguration.class,
            HibernateJpaAutoConfiguration.class,
            JpaRepositoriesAutoConfiguration.class, MongoAutoConfiguration.class,
            MongoDataAutoConfiguration.class,
            MongoRepositoriesAutoConfiguration.class }) {
        names.add(type.getName());
    }
    return names.toArray(new String[0]);
}
项目:spring-boot-concourse    文件:MixedNeo4jRepositoriesAutoConfigurationTests.java   
@Override
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
    List<String> names = new ArrayList<String>();
    for (Class<?> type : new Class<?>[] { DataSourceAutoConfiguration.class,
            HibernateJpaAutoConfiguration.class,
            JpaRepositoriesAutoConfiguration.class, Neo4jAutoConfiguration.class,
            Neo4jRepositoriesAutoConfiguration.class }) {
        names.add(type.getName());
    }
    return names.toArray(new String[names.size()]);
}
项目:spring-boot-concourse    文件:JpaRepositoriesAutoConfigurationTests.java   
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();
}
项目:spring-boot-concourse    文件:PersistenceExceptionTranslationAutoConfigurationTests.java   
@Test(expected = IllegalArgumentException.class)
public void persistOfNullThrowsIllegalArgumentExceptionWithoutExceptionTranslation() {
    this.context = new AnnotationConfigApplicationContext(
            EmbeddedDataSourceConfiguration.class,
            HibernateJpaAutoConfiguration.class, TestConfiguration.class);
    this.context.getBean(TestRepository.class).doSomething();
}
项目:spring-boot-concourse    文件:PersistenceExceptionTranslationAutoConfigurationTests.java   
@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();
}
项目:spring-boot-concourse    文件:HazelcastJpaDependencyAutoConfigurationTests.java   
public void load(Class<?> config) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    if (config != null) {
        ctx.register(config);
    }
    ctx.register(EmbeddedDataSourceConfiguration.class,
            DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class);
    ctx.register(HazelcastJpaDependencyAutoConfiguration.class);
    ctx.refresh();
    this.context = ctx;
}
项目:spring-cloud-dataflow    文件:DataFlowServerConfigurationTests.java   
@Before
public void setup() {
    context = new AnnotationConfigApplicationContext();
    context.setId("testDataFlowConfig");
    context.register(DataFlowServerConfigurationTests.TestConfiguration.class, RedisAutoConfiguration.class,
            SecurityAutoConfiguration.class, DataFlowServerAutoConfiguration.class,
            DataFlowControllerAutoConfiguration.class, DataSourceAutoConfiguration.class,
            DataFlowServerConfiguration.class, PropertyPlaceholderAutoConfiguration.class,
            WebClientAutoConfiguration.class, HibernateJpaAutoConfiguration.class, WebConfiguration.class);
    environment = new StandardEnvironment();
    propertySources = environment.getPropertySources();
}
项目:contestparser    文件:MixedMongoRepositoriesAutoConfigurationTests.java   
@Override
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
    List<String> names = new ArrayList<String>();
    for (Class<?> type : new Class<?>[] { DataSourceAutoConfiguration.class,
            HibernateJpaAutoConfiguration.class,
            JpaRepositoriesAutoConfiguration.class, MongoAutoConfiguration.class,
            MongoDataAutoConfiguration.class,
            MongoRepositoriesAutoConfiguration.class }) {
        names.add(type.getName());
    }
    return names.toArray(new String[0]);
}
项目:contestparser    文件:JpaRepositoriesAutoConfigurationTests.java   
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();
}
项目:contestparser    文件:PersistenceExceptionTranslationAutoConfigurationTests.java   
@Test(expected = IllegalArgumentException.class)
public void persistOfNullThrowsIllegalArgumentExceptionWithoutExceptionTranslation() {
    this.context = new AnnotationConfigApplicationContext(
            EmbeddedDataSourceConfiguration.class,
            HibernateJpaAutoConfiguration.class, TestConfiguration.class);
    this.context.getBean(TestRepository.class).doSomething();
}
项目:contestparser    文件:PersistenceExceptionTranslationAutoConfigurationTests.java   
@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();
}
项目:hapi-fhir    文件:FhirAutoConfigurationTest.java   
@Test
public void withJpaServer() {
    load(
            Arrays.array(
                    EmbeddedDataSourceConfiguration.class,
                    HibernateJpaAutoConfiguration.class,
                    PropertyPlaceholderAutoConfiguration.class,
                    FhirAutoConfiguration.class),
            "hapi.fhir.version:DSTU3",
            "spring.jpa.properties.hibernate.search.default.indexBase:target/lucenefiles",
         "spring.jpa.properties.hibernate.search.model_mapping:ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory");
    assertThat(this.context.getBeansOfType(DaoConfig.class)).hasSize(1);
    assertThat(this.context.getBeansOfType(Dstu3.class)).hasSize(1);
}