|
|
@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.hazelcast;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
import com.hazelcast.core.HazelcastInstance;
|
|
|
|
import com.hazelcast.core.HazelcastInstance;
|
|
|
|
import org.junit.After;
|
|
|
|
import org.junit.After;
|
|
|
@ -57,7 +58,7 @@ public class HazelcastJpaDependencyAutoConfigurationTests {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void registrationIfHazelcastInstanceHasRegularBeanName() {
|
|
|
|
public void registrationIfHazelcastInstanceHasRegularBeanName() {
|
|
|
|
load(HazelcastConfiguration.class);
|
|
|
|
load(HazelcastConfiguration.class);
|
|
|
|
assertThat(this.context.getBeansOfType(EntityManagerFactoryDependsOnPostProcessor.class),
|
|
|
|
assertThat(getPostProcessor(),
|
|
|
|
hasKey("hazelcastInstanceJpaDependencyPostProcessor"));
|
|
|
|
hasKey("hazelcastInstanceJpaDependencyPostProcessor"));
|
|
|
|
assertThat(getEntityManagerFactoryDependencies(), hasItem("hazelcastInstance"));
|
|
|
|
assertThat(getEntityManagerFactoryDependencies(), hasItem("hazelcastInstance"));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -65,16 +66,18 @@ public class HazelcastJpaDependencyAutoConfigurationTests {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void noRegistrationIfHazelcastInstanceHasCustomBeanName() {
|
|
|
|
public void noRegistrationIfHazelcastInstanceHasCustomBeanName() {
|
|
|
|
load(HazelcastCustomNameConfiguration.class);
|
|
|
|
load(HazelcastCustomNameConfiguration.class);
|
|
|
|
assertThat(getEntityManagerFactoryDependencies(), not(hasItem("hazelcastInstance")));
|
|
|
|
assertThat(getEntityManagerFactoryDependencies(),
|
|
|
|
assertThat(this.context.getBeansOfType(EntityManagerFactoryDependsOnPostProcessor.class),
|
|
|
|
not(hasItem("hazelcastInstance")));
|
|
|
|
|
|
|
|
assertThat(getPostProcessor(),
|
|
|
|
not(hasKey("hazelcastInstanceJpaDependencyPostProcessor")));
|
|
|
|
not(hasKey("hazelcastInstanceJpaDependencyPostProcessor")));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void noRegistrationWithNoHazelcastInstance() {
|
|
|
|
public void noRegistrationWithNoHazelcastInstance() {
|
|
|
|
load(null);
|
|
|
|
load(null);
|
|
|
|
assertThat(getEntityManagerFactoryDependencies(), not(hasItem("hazelcastInstance")));
|
|
|
|
assertThat(getEntityManagerFactoryDependencies(),
|
|
|
|
assertThat(this.context.getBeansOfType(EntityManagerFactoryDependsOnPostProcessor.class),
|
|
|
|
not(hasItem("hazelcastInstance")));
|
|
|
|
|
|
|
|
assertThat(getPostProcessor(),
|
|
|
|
not(hasKey("hazelcastInstanceJpaDependencyPostProcessor")));
|
|
|
|
not(hasKey("hazelcastInstanceJpaDependencyPostProcessor")));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -84,13 +87,20 @@ public class HazelcastJpaDependencyAutoConfigurationTests {
|
|
|
|
this.context.register(HazelcastConfiguration.class,
|
|
|
|
this.context.register(HazelcastConfiguration.class,
|
|
|
|
HazelcastJpaDependencyAutoConfiguration.class);
|
|
|
|
HazelcastJpaDependencyAutoConfiguration.class);
|
|
|
|
this.context.refresh();
|
|
|
|
this.context.refresh();
|
|
|
|
assertThat(this.context.getBeansOfType(EntityManagerFactoryDependsOnPostProcessor.class),
|
|
|
|
assertThat(getPostProcessor(),
|
|
|
|
not(hasKey("hazelcastInstanceJpaDependencyPostProcessor")));
|
|
|
|
not(hasKey("hazelcastInstanceJpaDependencyPostProcessor")));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Map<String, EntityManagerFactoryDependsOnPostProcessor> getPostProcessor() {
|
|
|
|
|
|
|
|
return this.context
|
|
|
|
|
|
|
|
.getBeansOfType(EntityManagerFactoryDependsOnPostProcessor.class);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private List<String> getEntityManagerFactoryDependencies() {
|
|
|
|
private List<String> getEntityManagerFactoryDependencies() {
|
|
|
|
String[] dependsOn = this.context.getBeanDefinition("entityManagerFactory").getDependsOn();
|
|
|
|
String[] dependsOn = this.context.getBeanDefinition("entityManagerFactory")
|
|
|
|
return dependsOn != null ? Arrays.asList(dependsOn) : Collections.<String>emptyList();
|
|
|
|
.getDependsOn();
|
|
|
|
|
|
|
|
return dependsOn != null ? Arrays.asList(dependsOn)
|
|
|
|
|
|
|
|
: Collections.<String>emptyList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void load(Class<?> config) {
|
|
|
|
public void load(Class<?> config) {
|
|
|
|