Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a780e87

Browse files
committed
Upgrade to Hazelcast 5.0.2
See spring-projectsgh-29265
1 parent 508d0af commit a780e87

File tree

14 files changed

+247
-9
lines changed

14 files changed

+247
-9
lines changed

‎spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/hazelcast.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<hazelcast
2-
xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-4.0.xsd"
2+
xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-5.0.xsd"
33
xmlns="http://www.hazelcast.com/schema/config"
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
55
<map name="defaultCache" />

‎spring-boot-project/spring-boot-actuator/src/test/resources/hazelcast.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<hazelcast xmlns="http://www.hazelcast.com/schema/config"
22
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:schemaLocation="http://www.hazelcast.com/schema/config
4-
http://www.hazelcast.com/schema/config/hazelcast-config-4.0.xsd">
4+
http://www.hazelcast.com/schema/config/hazelcast-config-5.0.xsd">
55
<instance-name>actuator-hazelcast</instance-name>
66
<map name="defaultCache" />
77
<network>

‎spring-boot-project/spring-boot-autoconfigure/src/test/resources/hazelcast.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<hazelcast
2-
xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-4.0.xsd"
2+
xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-5.0.xsd"
33
xmlns="http://www.hazelcast.com/schema/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
44
<instance-name>default-instance</instance-name>
55
<map name="defaultCache" />

‎spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/hazelcast/hazelcast-specific.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-4.0.xsd"
1+
<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-5.0.xsd"
22
xmlns="http://www.hazelcast.com/schema/config"
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
44

‎spring-boot-project/spring-boot-dependencies/build.gradle‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ bom {
413413
]
414414
}
415415
}
416-
library("Hazelcast", "4.2.4") {
416+
library("Hazelcast", "5.0.2") {
417417
group("com.hazelcast") {
418418
modules = [
419419
"hazelcast",

‎spring-boot-project/spring-boot-docs/src/docs/asciidoc/io/hazelcast.adoc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Spring Boot first attempts to create a client by checking the following configur
1010
* A `hazelcast-client.xml` in the working directory or at the root of the classpath.
1111
* A `hazelcast-client.yaml` in the working directory or at the root of the classpath.
1212

13-
NOTE: Spring Boot supports both Hazelcast 4 and Hazelcast 3.
14-
If you downgrade to Hazelcast 3, `hazelcast-client` should be added to the classpath to configure a client.
13+
WARNING: Hazelcast 3 support is deprecated.
14+
If you still need to downgrade to Hazelcast 3, `hazelcast-client` should be added to the classpath to configure a client.
1515

1616
If a client can not be created, Spring Boot attempts to configure an embedded server.
1717
If you define a `com.hazelcast.config.Config` bean, Spring Boot uses that.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright 2012-2020 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package smoketest.hazelcast3;
18+
19+
import com.hazelcast.spring.cache.HazelcastCacheManager;
20+
import org.junit.jupiter.api.Test;
21+
22+
import org.springframework.beans.factory.annotation.Autowired;
23+
import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient;
24+
import org.springframework.boot.test.context.SpringBootTest;
25+
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
26+
import org.springframework.cache.CacheManager;
27+
import org.springframework.test.web.reactive.server.WebTestClient;
28+
29+
import static org.assertj.core.api.Assertions.assertThat;
30+
31+
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
32+
@AutoConfigureWebTestClient
33+
class SampleHazelcast3ApplicationTests {
34+
35+
@Autowired
36+
private WebTestClient webClient;
37+
38+
@Autowired
39+
private CacheManager cacheManager;
40+
41+
@Autowired
42+
private CountryRepository countryRepository;
43+
44+
@Test
45+
void cacheManagerIsUsingHazelcast() {
46+
assertThat(this.cacheManager).isInstanceOf(HazelcastCacheManager.class);
47+
}
48+
49+
@Test
50+
void healthEndpointHasHazelcastContributor() {
51+
this.webClient.get().uri("/actuator/health/hazelcast").exchange().expectStatus().isOk().expectBody()
52+
.jsonPath("status").isEqualTo("UP").jsonPath("details.name").isNotEmpty().jsonPath("details.uuid")
53+
.isNotEmpty();
54+
}
55+
56+
@Test
57+
void metricsEndpointHasCacheMetrics() {
58+
this.webClient.get().uri("/actuator/metrics/cache.entries").exchange().expectStatus().isOk();
59+
}
60+
61+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
plugins {
2+
id "java"
3+
id "org.springframework.boot.conventions"
4+
}
5+
6+
description = "Spring Boot Hazelcast 4 smoke test"
7+
8+
configurations.all {
9+
resolutionStrategy {
10+
force "com.hazelcast:hazelcast:4.0.5"
11+
force "com.hazelcast:hazelcast-spring:4.0.5"
12+
}
13+
}
14+
15+
dependencies {
16+
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-actuator"))
17+
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-cache"))
18+
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web"))
19+
implementation("com.hazelcast:hazelcast")
20+
implementation("com.hazelcast:hazelcast-spring")
21+
22+
testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test"))
23+
testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-webflux"))
24+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2012-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package smoketest.hazelcast4;
18+
19+
import java.io.Serializable;
20+
21+
@SuppressWarnings("serial")
22+
public class Country implements Serializable {
23+
24+
private final String code;
25+
26+
public Country(String code) {
27+
this.code = code;
28+
}
29+
30+
public String getCode() {
31+
return this.code;
32+
}
33+
34+
@Override
35+
public boolean equals(Object o) {
36+
if (this == o) {
37+
return true;
38+
}
39+
if (o == null || getClass() != o.getClass()) {
40+
return false;
41+
}
42+
43+
Country country = (Country) o;
44+
45+
return this.code.equals(country.code);
46+
}
47+
48+
@Override
49+
public int hashCode() {
50+
return this.code.hashCode();
51+
}
52+
53+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2012-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package smoketest.hazelcast4;
18+
19+
import org.springframework.cache.annotation.CacheConfig;
20+
import org.springframework.cache.annotation.Cacheable;
21+
import org.springframework.stereotype.Component;
22+
23+
@Component
24+
@CacheConfig(cacheNames = "countries")
25+
public class CountryRepository {
26+
27+
@Cacheable
28+
public Country findByCode(String code) {
29+
System.out.println("---> Loading country with code '" + code + "'");
30+
return new Country(code);
31+
}
32+
33+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /