Skip to content

Commit

Permalink
Restore support for Hazelcast 3
Browse files Browse the repository at this point in the history
  • Loading branch information
snicoll committed Jan 4, 2022
1 parent 69dbc34 commit 578855f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Expand Up @@ -114,7 +114,11 @@ static class SpringManagedContextHazelcastConfigCustomizerConfiguration {
@Bean
@Order(0)
HazelcastConfigCustomizer springManagedContextHazelcastConfigCustomizer(ApplicationContext applicationContext) {
return (config) -> config.setManagedContext(new SpringManagedContext(applicationContext));
return (config) -> {
SpringManagedContext managementContext = new SpringManagedContext();
managementContext.setApplicationContext(applicationContext);
config.setManagedContext(managementContext);
};
}

}
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,6 +20,7 @@
import com.hazelcast.config.Config;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.spring.context.SpringManagedContext;
import org.assertj.core.api.Condition;
import org.junit.jupiter.api.Test;

Expand All @@ -39,7 +40,8 @@
* @author Stephane Nicoll
*/
@ClassPathExclusions("hazelcast*.jar")
@ClassPathOverrides({ "com.hazelcast:hazelcast:3.12.8", "com.hazelcast:hazelcast-client:3.12.8" })
@ClassPathOverrides({ "com.hazelcast:hazelcast:3.12.8", "com.hazelcast:hazelcast-client:3.12.8",
"com.hazelcast:hazelcast-spring:3.12.8" })
class Hazelcast3AutoConfigurationTests {

private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
Expand Down Expand Up @@ -70,6 +72,14 @@ void explicitConfigFileWithXml() {
}
}

@Test
void autoConfiguredConfigUsesSpringManagedContext() {
this.contextRunner.run((context) -> {
Config config = context.getBean(HazelcastInstance.class).getConfig();
assertThat(config.getManagedContext()).isInstanceOf(SpringManagedContext.class);
});
}

private ContextConsumer<AssertableApplicationContext> assertSpecificHazelcastClient(String label) {
return (context) -> assertThat(context).getBean(HazelcastInstance.class).isInstanceOf(HazelcastInstance.class)
.has(labelEqualTo(label));
Expand Down

0 comments on commit 578855f

Please sign in to comment.