org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration Java Examples
The following examples show how to use
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration.
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: 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 #2
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 #3
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 #4
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 #5
Source File: JpaWebAutoConfigurationTest.java From joinfaces with Apache License 2.0 | 4 votes |
@BeforeEach public void setUp() { this.webApplicationContextRunner = new WebApplicationContextRunner() .withConfiguration(AutoConfigurations.of(JpaWebAutoConfiguration.class, HibernateJpaAutoConfiguration.class)); }
Example #6
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(); }); }