HazelcastAutoConfigurationServerTests.java (spring-boot-2.7.3) | : | HazelcastAutoConfigurationServerTests.java (spring-boot-2.7.4) | ||
---|---|---|---|---|
skipping to change at line 91 | skipping to change at line 91 | |||
this.contextRunner | this.contextRunner | |||
.withSystemProperties(HazelcastServerConfiguratio n.CONFIG_SYSTEM_PROPERTY | .withSystemProperties(HazelcastServerConfiguratio n.CONFIG_SYSTEM_PROPERTY | |||
+ "=classpath:org/springframework /boot/autoconfigure/hazelcast/hazelcast-specific.yaml") | + "=classpath:org/springframework /boot/autoconfigure/hazelcast/hazelcast-specific.yaml") | |||
.run((context) -> { | .run((context) -> { | |||
Config config = context.getBean(Hazelcast Instance.class).getConfig(); | Config config = context.getBean(Hazelcast Instance.class).getConfig(); | |||
assertThat(config.getMapConfigs().keySet( )).containsOnly("foobar"); | assertThat(config.getMapConfigs().keySet( )).containsOnly("foobar"); | |||
}); | }); | |||
} | } | |||
@Test | @Test | |||
void systemPropertyWithYml() { | ||||
this.contextRunner | ||||
.withSystemProperties(HazelcastServerConfiguratio | ||||
n.CONFIG_SYSTEM_PROPERTY | ||||
+ "=classpath:org/springframework | ||||
/boot/autoconfigure/hazelcast/hazelcast-specific.yml") | ||||
.run((context) -> { | ||||
Config config = context.getBean(Hazelcast | ||||
Instance.class).getConfig(); | ||||
assertThat(config.getMapConfigs().keySet( | ||||
)).containsOnly("foobar"); | ||||
}); | ||||
} | ||||
@Test | ||||
void explicitConfigFileWithXml() { | void explicitConfigFileWithXml() { | |||
this.contextRunner | this.contextRunner | |||
.withPropertyValues("spring.hazelcast.config=org/ springframework/boot/autoconfigure/hazelcast/" | .withPropertyValues("spring.hazelcast.config=org/ springframework/boot/autoconfigure/hazelcast/" | |||
+ "hazelcast-specific.xml") | + "hazelcast-specific.xml") | |||
.run(assertSpecificHazelcastServer( | .run(assertSpecificHazelcastServer( | |||
"org/springframework/boot/autocon figure/hazelcast/hazelcast-specific.xml")); | "org/springframework/boot/autocon figure/hazelcast/hazelcast-specific.xml")); | |||
} | } | |||
@Test | @Test | |||
void explicitConfigFileWithYaml() { | void explicitConfigFileWithYaml() { | |||
this.contextRunner | this.contextRunner | |||
.withPropertyValues("spring.hazelcast.config=org/ springframework/boot/autoconfigure/hazelcast/" | .withPropertyValues("spring.hazelcast.config=org/ springframework/boot/autoconfigure/hazelcast/" | |||
+ "hazelcast-specific.yaml") | + "hazelcast-specific.yaml") | |||
.run(assertSpecificHazelcastServer( | .run(assertSpecificHazelcastServer( | |||
"org/springframework/boot/autocon figure/hazelcast/hazelcast-specific.yaml")); | "org/springframework/boot/autocon figure/hazelcast/hazelcast-specific.yaml")); | |||
} | } | |||
@Test | @Test | |||
void explicitConfigFileWithYml() { | ||||
this.contextRunner | ||||
.withPropertyValues("spring.hazelcast.config=org/ | ||||
springframework/boot/autoconfigure/hazelcast/" | ||||
+ "hazelcast-specific.yml") | ||||
.run(assertSpecificHazelcastServer( | ||||
"org/springframework/boot/autocon | ||||
figure/hazelcast/hazelcast-specific.yml")); | ||||
} | ||||
@Test | ||||
void explicitConfigUrlWithXml() { | void explicitConfigUrlWithXml() { | |||
this.contextRunner | this.contextRunner | |||
.withPropertyValues("spring.hazelcast.config=clas spath:org/springframework/" | .withPropertyValues("spring.hazelcast.config=clas spath:org/springframework/" | |||
+ "boot/autoconfigure/hazelcast/h azelcast-specific.xml") | + "boot/autoconfigure/hazelcast/h azelcast-specific.xml") | |||
.run(assertSpecificHazelcastServer( | .run(assertSpecificHazelcastServer( | |||
"org/springframework/boot/autocon figure/hazelcast/hazelcast-specific.xml")); | "org/springframework/boot/autocon figure/hazelcast/hazelcast-specific.xml")); | |||
} | } | |||
@Test | @Test | |||
void explicitConfigUrlWithYaml() { | void explicitConfigUrlWithYaml() { | |||
this.contextRunner | this.contextRunner | |||
.withPropertyValues("spring.hazelcast.config=clas spath:org/springframework/" | .withPropertyValues("spring.hazelcast.config=clas spath:org/springframework/" | |||
+ "boot/autoconfigure/hazelcast/h azelcast-specific.yaml") | + "boot/autoconfigure/hazelcast/h azelcast-specific.yaml") | |||
.run(assertSpecificHazelcastServer( | .run(assertSpecificHazelcastServer( | |||
"org/springframework/boot/autocon figure/hazelcast/hazelcast-specific.yaml")); | "org/springframework/boot/autocon figure/hazelcast/hazelcast-specific.yaml")); | |||
} | } | |||
@Test | ||||
void explicitConfigUrlWithYml() { | ||||
this.contextRunner | ||||
.withPropertyValues("spring.hazelcast.config=clas | ||||
spath:org/springframework/" | ||||
+ "boot/autoconfigure/hazelcast/h | ||||
azelcast-specific.yml") | ||||
.run(assertSpecificHazelcastServer( | ||||
"org/springframework/boot/autocon | ||||
figure/hazelcast/hazelcast-specific.yml")); | ||||
} | ||||
private ContextConsumer<AssertableApplicationContext> assertSpecificHazel castServer(String location) { | private ContextConsumer<AssertableApplicationContext> assertSpecificHazel castServer(String location) { | |||
return (context) -> { | return (context) -> { | |||
Config config = context.getBean(HazelcastInstance.class). getConfig(); | Config config = context.getBean(HazelcastInstance.class). getConfig(); | |||
assertThat(config.getConfigurationUrl()).asString().endsW ith(location); | assertThat(config.getConfigurationUrl()).asString().endsW ith(location); | |||
}; | }; | |||
} | } | |||
@Test | @Test | |||
void unknownConfigFile() { | void unknownConfigFile() { | |||
this.contextRunner.withPropertyValues("spring.hazelcast.config=fo o/bar/unknown.xml") | this.contextRunner.withPropertyValues("spring.hazelcast.config=fo o/bar/unknown.xml") | |||
skipping to change at line 209 | skipping to change at line 238 | |||
} | } | |||
@Test | @Test | |||
void autoConfiguredContextCanOverrideManagementContextUsingCustomizer() { | void autoConfiguredContextCanOverrideManagementContextUsingCustomizer() { | |||
this.contextRunner.withBean(TestHazelcastConfigCustomizer.class). run((context) -> { | this.contextRunner.withBean(TestHazelcastConfigCustomizer.class). run((context) -> { | |||
Config config = context.getBean(HazelcastInstance.class). getConfig(); | Config config = context.getBean(HazelcastInstance.class). getConfig(); | |||
assertThat(config.getManagedContext()).isNull(); | assertThat(config.getManagedContext()).isNull(); | |||
}); | }); | |||
} | } | |||
@Test | ||||
void autoConfiguredConfigSetsHazelcastLoggingToSlf4j() { | ||||
this.contextRunner.run((context) -> { | ||||
Config config = context.getBean(HazelcastInstance.class). | ||||
getConfig(); | ||||
assertThat(config.getProperty(HazelcastServerConfiguratio | ||||
n.HAZELCAST_LOGGING_TYPE)).isEqualTo("slf4j"); | ||||
}); | ||||
} | ||||
@Test | ||||
void autoConfiguredConfigCanOverrideHazelcastLogging() { | ||||
this.contextRunner.withUserConfiguration(HazelcastConfigWithJDKLo | ||||
gging.class).run((context) -> { | ||||
Config config = context.getBean(HazelcastInstance.class). | ||||
getConfig(); | ||||
assertThat(config.getProperty(HazelcastServerConfiguratio | ||||
n.HAZELCAST_LOGGING_TYPE)).isEqualTo("jdk"); | ||||
}); | ||||
} | ||||
private static Config createTestConfig(String instanceName) { | private static Config createTestConfig(String instanceName) { | |||
Config config = new Config(instanceName); | Config config = new Config(instanceName); | |||
JoinConfig join = config.getNetworkConfig().getJoin(); | JoinConfig join = config.getNetworkConfig().getJoin(); | |||
join.getAutoDetectionConfig().setEnabled(false); | join.getAutoDetectionConfig().setEnabled(false); | |||
join.getMulticastConfig().setEnabled(false); | join.getMulticastConfig().setEnabled(false); | |||
return config; | return config; | |||
} | } | |||
@Configuration(proxyBeanMethods = false) | @Configuration(proxyBeanMethods = false) | |||
static class HazelcastConfigWithName { | static class HazelcastConfigWithName { | |||
skipping to change at line 239 | skipping to change at line 284 | |||
@Bean | @Bean | |||
Config anotherHazelcastConfig() { | Config anotherHazelcastConfig() { | |||
Config config = createTestConfig("another-test-instance") ; | Config config = createTestConfig("another-test-instance") ; | |||
config.addQueueConfig(new QueueConfig("another-queue")); | config.addQueueConfig(new QueueConfig("another-queue")); | |||
return config; | return config; | |||
} | } | |||
} | } | |||
@Configuration(proxyBeanMethods = false) | ||||
static class HazelcastConfigWithJDKLogging { | ||||
@Bean | ||||
Config anotherHazelcastConfig() { | ||||
Config config = new Config(); | ||||
config.setProperty(HazelcastServerConfiguration.HAZELCAST | ||||
_LOGGING_TYPE, "jdk"); | ||||
return config; | ||||
} | ||||
} | ||||
@SpringAware | @SpringAware | |||
static class SpringAwareEntryProcessor<V> implements EntryProcessor<Strin g, V, String> { | static class SpringAwareEntryProcessor<V> implements EntryProcessor<Strin g, V, String> { | |||
@Autowired | @Autowired | |||
private Environment environment; | private Environment environment; | |||
@Override | @Override | |||
public String process(Map.Entry<String, V> entry) { | public String process(Map.Entry<String, V> entry) { | |||
return this.environment.getProperty(entry.getKey()); | return this.environment.getProperty(entry.getKey()); | |||
} | } | |||
End of changes. 5 change blocks. | ||||
0 lines changed or deleted | 72 lines changed or added |