diff --git a/pom.xml b/pom.xml index 19edf37fc..2a407deb3 100644 --- a/pom.xml +++ b/pom.xml @@ -45,7 +45,7 @@ 3.0.0 1.18.40 - 3.5.4 + 4.0.0 diff --git a/spring/resilient-sessions/docker/conf-lon/config.yml b/spring/resilient-sessions/docker/conf-lon/config.yml index ac0ced81d..7393f3811 100644 --- a/spring/resilient-sessions/docker/conf-lon/config.yml +++ b/spring/resilient-sessions/docker/conf-lon/config.yml @@ -30,3 +30,8 @@ hazelcast: - type: HASH attributes: - "principalName" + products: + wan-replication-ref: + replicate-to-nyc: + merge-policy-class-name: PutIfAbsentMergePolicy + backup-count: 1 diff --git a/spring/resilient-sessions/docker/conf-newyork/config.yml b/spring/resilient-sessions/docker/conf-newyork/config.yml index c9ec761f8..a896dc835 100644 --- a/spring/resilient-sessions/docker/conf-newyork/config.yml +++ b/spring/resilient-sessions/docker/conf-newyork/config.yml @@ -30,3 +30,8 @@ hazelcast: - type: HASH attributes: - "principalName" + products: + wan-replication-ref: + eplicate-to-lon: + merge-policy-class-name: PutIfAbsentMergePolicy + backup-count: 1 diff --git a/spring/spring-boot-caching-hazelcast-cache-manager/pom.xml b/spring/spring-boot-caching-hazelcast-cache-manager/pom.xml index f39b83b68..26763abd2 100644 --- a/spring/spring-boot-caching-hazelcast-cache-manager/pom.xml +++ b/spring/spring-boot-caching-hazelcast-cache-manager/pom.xml @@ -66,11 +66,21 @@ hazelcast-spring ${hazelcast.version} + + org.springframework.boot + spring-boot-hazelcast + org.springframework.boot spring-boot-starter-test test + + + org.springframework.boot + spring-boot-starter-logging + + diff --git a/spring/spring-boot-caching-hazelcast-cache-manager/src/test/java/com/hazelcast/springboot/caching/ApplicationTest.java b/spring/spring-boot-caching-hazelcast-cache-manager/src/test/java/com/hazelcast/springboot/caching/ApplicationTest.java index 7304977b5..f78578d5b 100644 --- a/spring/spring-boot-caching-hazelcast-cache-manager/src/test/java/com/hazelcast/springboot/caching/ApplicationTest.java +++ b/spring/spring-boot-caching-hazelcast-cache-manager/src/test/java/com/hazelcast/springboot/caching/ApplicationTest.java @@ -5,8 +5,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.test.web.servlet.client.RestTestClient; import static org.assertj.core.api.Assertions.assertThat; @@ -16,21 +16,22 @@ class ApplicationTest { @LocalServerPort private int port; - @Autowired - private TestRestTemplate restTemplate; - @Autowired private HazelcastInstance hazelcastInstance; @Test void useCachedValue() { // given + RestTestClient restTestClient = RestTestClient.bindToServer().baseUrl("http://localhost:" + port).build(); String isbn = "12345"; String cachedValue = "cached-value"; hazelcastInstance.getMap("books").put(isbn, cachedValue); // when - String response = restTemplate.getForObject(String.format("http://localhost:%s/books/%s", port, isbn), String.class); + String response = restTestClient.get().uri(String.format("http://localhost:%s/books/%s", port, isbn)) + .exchange() + .returnResult(String.class) + .getResponseBody(); // then assertThat(response).isEqualTo(cachedValue); diff --git a/spring/spring-boot-caching-jcache/pom.xml b/spring/spring-boot-caching-jcache/pom.xml index 01da2ecc8..cd96e5b87 100644 --- a/spring/spring-boot-caching-jcache/pom.xml +++ b/spring/spring-boot-caching-jcache/pom.xml @@ -63,19 +63,20 @@ org.springframework.boot spring-boot-starter-log4j2 - - org.apache.logging.log4j - log4j-spring-boot - com.hazelcast hazelcast - 5.5.0 + 5.6.0 + + org.springframework.boot + spring-boot-hazelcast + + javax.cache cache-api @@ -91,6 +92,10 @@ org.junit.vintage junit-vintage-engine + + org.springframework.boot + spring-boot-starter-logging + diff --git a/spring/spring-boot-caching-jcache/src/test/java/com/hazelcast/springboot/caching/ApplicationClientServerTest.java b/spring/spring-boot-caching-jcache/src/test/java/com/hazelcast/springboot/caching/ApplicationClientServerTest.java index 14076998e..ccb97851b 100644 --- a/spring/spring-boot-caching-jcache/src/test/java/com/hazelcast/springboot/caching/ApplicationClientServerTest.java +++ b/spring/spring-boot-caching-jcache/src/test/java/com/hazelcast/springboot/caching/ApplicationClientServerTest.java @@ -7,8 +7,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.test.web.servlet.client.RestTestClient; import static org.assertj.core.api.Assertions.assertThat; @@ -18,9 +18,6 @@ class ApplicationClientServerTest { @LocalServerPort private int port; - @Autowired - private TestRestTemplate restTemplate; - @Autowired private HazelcastInstance hazelcastInstance; @@ -31,13 +28,17 @@ static void setUp() { @Test void useCachedValue() { + RestTestClient restTestClient = RestTestClient.bindToServer().baseUrl("http://localhost:" + port).build(); // given String isbn = "12345"; String cachedValue = "cached-value"; hazelcastInstance.getCacheManager().getCache("books").put(isbn, cachedValue); // when - String response = restTemplate.getForObject(String.format("http://localhost:%s/books/%s", port, isbn), String.class); + String response = restTestClient.get().uri(String.format("http://localhost:%s/books/%s", port, isbn)) + .exchange() + .returnResult(String.class) + .getResponseBody(); // then assertThat(response).isEqualTo(cachedValue); diff --git a/spring/spring-boot-caching-jcache/src/test/java/com/hazelcast/springboot/caching/ApplicationEmbeddedTest.java b/spring/spring-boot-caching-jcache/src/test/java/com/hazelcast/springboot/caching/ApplicationEmbeddedTest.java index 67d8c6ddc..cf479f646 100644 --- a/spring/spring-boot-caching-jcache/src/test/java/com/hazelcast/springboot/caching/ApplicationEmbeddedTest.java +++ b/spring/spring-boot-caching-jcache/src/test/java/com/hazelcast/springboot/caching/ApplicationEmbeddedTest.java @@ -5,7 +5,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.test.web.servlet.client.RestTestClient; import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.test.context.ActiveProfiles; @@ -18,21 +18,23 @@ class ApplicationEmbeddedTest { @LocalServerPort private int port; - @Autowired - private TestRestTemplate restTemplate; - @Autowired private HazelcastInstance hazelcastInstance; @Test void useCachedValue() { + RestTestClient restTestClient = RestTestClient.bindToServer().baseUrl("http://localhost:" + port).build(); + // given String isbn = "12345"; String cachedValue = "cached-value"; hazelcastInstance.getCacheManager().getCache("books").put(isbn, cachedValue); // when - String response = restTemplate.getForObject(String.format("http://localhost:%s/books/%s", port, isbn), String.class); + String response = restTestClient.get().uri(String.format("http://localhost:%s/books/%s", port, isbn)) + .exchange() + .returnResult(String.class) + .getResponseBody(); // then assertThat(response).isEqualTo(cachedValue); diff --git a/spring/spring-boot-embedded/pom.xml b/spring/spring-boot-embedded/pom.xml index 638f29797..55a547f45 100755 --- a/spring/spring-boot-embedded/pom.xml +++ b/spring/spring-boot-embedded/pom.xml @@ -54,15 +54,15 @@ spring-boot-starter-log4j2 - org.apache.logging.log4j - log4j-spring-boot + org.springframework.boot + spring-boot-hazelcast com.hazelcast hazelcast-spring - 5.5.0 + 5.6.0 @@ -70,6 +70,12 @@ org.springframework.boot spring-boot-starter-test test + + + org.springframework.boot + spring-boot-starter-logging + + org.springframework.boot diff --git a/spring/spring-boot-embedded/src/main/java/guides/hazelcast/springboot/HazelcastApplication.java b/spring/spring-boot-embedded/src/main/java/guides/hazelcast/springboot/HazelcastApplication.java index bc26d2f9b..497b8a366 100755 --- a/spring/spring-boot-embedded/src/main/java/guides/hazelcast/springboot/HazelcastApplication.java +++ b/spring/spring-boot-embedded/src/main/java/guides/hazelcast/springboot/HazelcastApplication.java @@ -7,7 +7,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; -@SpringBootApplication +@SpringBootApplication(excludeName = "com.hazelcast.spring.HazelcastObjectExtractionConfiguration") public class HazelcastApplication { public static void main(String[] args) { diff --git a/spring/spring-boot-embedded/src/test/java/guides/hazelcast/springboot/CommandControllerIT.java b/spring/spring-boot-embedded/src/test/java/guides/hazelcast/springboot/CommandControllerIT.java index 6cefe9056..3f97cfa4a 100755 --- a/spring/spring-boot-embedded/src/test/java/guides/hazelcast/springboot/CommandControllerIT.java +++ b/spring/spring-boot-embedded/src/test/java/guides/hazelcast/springboot/CommandControllerIT.java @@ -3,10 +3,12 @@ import com.hazelcast.config.Config; import com.hazelcast.core.Hazelcast; import com.hazelcast.core.HazelcastInstance; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.web.reactive.server.WebTestClient; +import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.test.web.servlet.client.RestTestClient; import java.time.Duration; import java.util.Map; @@ -20,8 +22,7 @@ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = HazelcastApplication.class) class CommandControllerIT { - @Autowired - private WebTestClient webTestClient; + private RestTestClient restTestClient; @Autowired private HazelcastInstance hazelcastInstance; @@ -29,10 +30,18 @@ class CommandControllerIT { @Autowired private Map keyValueMap; + @LocalServerPort + private int port; + + @BeforeEach + public void setUp() { + restTestClient = RestTestClient.bindToServer().baseUrl("http://localhost:" + port).build(); + } + @Test void testPutRequest() { //when - WebTestClient.ResponseSpec responseSpec = makePutRequest("key1", "value1"); + RestTestClient.ResponseSpec responseSpec = makePutRequest("key1", "value1"); //then responseSpec.expectStatus() @@ -51,7 +60,7 @@ void testGetRequest() { makePutRequest("key1", "value1"); //when - WebTestClient.ResponseSpec responseSpec = webTestClient + RestTestClient.ResponseSpec responseSpec = restTestClient .get() .uri("/get?key={key}", "key1") .header(ACCEPT, APPLICATION_JSON_VALUE) @@ -66,8 +75,8 @@ void testGetRequest() { .jsonPath("$.value").isEqualTo("value1"); } - private WebTestClient.ResponseSpec makePutRequest(Object... parameters) { - return webTestClient + private RestTestClient.ResponseSpec makePutRequest(Object... parameters) { + return restTestClient .post() .uri("/put?key={key}&value={value}", parameters) .header(ACCEPT, APPLICATION_JSON_VALUE) diff --git a/spring/spring-data-jpa-hazelcast-migration/after/after-main/src/main/java/com/hazelcast/samples/spring/data/migration/AfterTranslator.java b/spring/spring-data-jpa-hazelcast-migration/after/after-main/src/main/java/com/hazelcast/samples/spring/data/migration/AfterTranslator.java index 4a09b938a..9b284f57b 100644 --- a/spring/spring-data-jpa-hazelcast-migration/after/after-main/src/main/java/com/hazelcast/samples/spring/data/migration/AfterTranslator.java +++ b/spring/spring-data-jpa-hazelcast-migration/after/after-main/src/main/java/com/hazelcast/samples/spring/data/migration/AfterTranslator.java @@ -1,8 +1,8 @@ package com.hazelcast.samples.spring.data.migration; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; +import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; +import org.springframework.boot.hibernate.autoconfigure.HibernateJpaAutoConfiguration; import org.springframework.shell.Bootstrap; /** diff --git a/spring/spring-hibernate-2ndlevel-cache/pom.xml b/spring/spring-hibernate-2ndlevel-cache/pom.xml index d6324a95c..8319380cd 100644 --- a/spring/spring-hibernate-2ndlevel-cache/pom.xml +++ b/spring/spring-hibernate-2ndlevel-cache/pom.xml @@ -48,6 +48,11 @@ test + + org.springframework.boot + spring-boot-hazelcast + + com.hazelcast hazelcast-hibernate53 diff --git a/spring/spring-hibernate-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/springhibernate2lc/SpringHibernate2lcApplication.java b/spring/spring-hibernate-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/springhibernate2lc/SpringHibernate2lcApplication.java index 579bdbe4d..73de3d7fa 100644 --- a/spring/spring-hibernate-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/springhibernate2lc/SpringHibernate2lcApplication.java +++ b/spring/spring-hibernate-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/springhibernate2lc/SpringHibernate2lcApplication.java @@ -2,7 +2,7 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration; +import org.springframework.boot.hazelcast.autoconfigure.HazelcastAutoConfiguration; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.Import; import org.springframework.scheduling.annotation.EnableScheduling;