Port test to use ehcache3
Hibernate 5.3 has deprecated the ehcache2 region factory so this commit upgrades the integration test to use JCache instead.
This commit is contained in:
parent
0881b7c390
commit
26353a8f35
|
@ -327,7 +327,7 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
<artifactId>hibernate-ehcache</artifactId>
|
<artifactId>hibernate-jcache</artifactId>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
package org.springframework.boot.autoconfigure.orm.jpa;
|
package org.springframework.boot.autoconfigure.orm.jpa;
|
||||||
|
|
||||||
import org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory;
|
import org.ehcache.jsr107.EhcacheCachingProvider;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
@ -32,13 +32,13 @@ import org.springframework.context.annotation.Configuration;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for Hibernate 2nd level cache with ehcache2.
|
* Tests for Hibernate 2nd level cache with jcache.
|
||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
*/
|
*/
|
||||||
@RunWith(ModifiedClassPathRunner.class)
|
@RunWith(ModifiedClassPathRunner.class)
|
||||||
@ClassPathExclusions("ehcache-3*.jar")
|
@ClassPathExclusions("ehcache-2*.jar")
|
||||||
public class Hibernate2ndLevelCacheEhCacheIntegrationTests {
|
public class Hibernate2ndLevelCacheIntegrationTests {
|
||||||
|
|
||||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||||
.withConfiguration(AutoConfigurations.of(CacheAutoConfiguration.class,
|
.withConfiguration(AutoConfigurations.of(CacheAutoConfiguration.class,
|
||||||
|
@ -48,11 +48,15 @@ public class Hibernate2ndLevelCacheEhCacheIntegrationTests {
|
||||||
.withUserConfiguration(TestConfiguration.class);
|
.withUserConfiguration(TestConfiguration.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void hibernate2ndLevelCacheWithEhCache2() {
|
public void hibernate2ndLevelCacheWithJCacheAndEhCache3() {
|
||||||
this.contextRunner
|
String cachingProviderFqn = EhcacheCachingProvider.class.getName();
|
||||||
.withPropertyValues("spring.cache.type=ehcache",
|
String configLocation = "ehcache3.xml";
|
||||||
"spring.jpa.properties.hibernate.cache.region.factory_class="
|
this.contextRunner.withPropertyValues("spring.cache.type=jcache",
|
||||||
+ SingletonEhCacheRegionFactory.class.getName())
|
"spring.cache.jcache.provider=" + cachingProviderFqn,
|
||||||
|
"spring.cache.jcache.config=" + configLocation,
|
||||||
|
"spring.jpa.properties.hibernate.cache.region.factory_class=jcache",
|
||||||
|
"spring.jpa.properties.hibernate.cache.provider=" + cachingProviderFqn,
|
||||||
|
"spring.jpa.properties.hibernate.javax.cache.uri=" + configLocation)
|
||||||
.run((context) -> assertThat(context).hasNotFailed());
|
.run((context) -> assertThat(context).hasNotFailed());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue