Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<maven.assembly.plugin.version>3.0.0</maven.assembly.plugin.version>

<lombok.version>1.18.40</lombok.version>
<spring.boot.version>3.5.4</spring.boot.version>
<spring.boot.version>4.0.0</spring.boot.version>
</properties>

<modules>
Expand Down
5 changes: 5 additions & 0 deletions spring/resilient-sessions/docker/conf-lon/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ hazelcast:
- type: HASH
attributes:
- "principalName"
products:
wan-replication-ref:
replicate-to-nyc:
merge-policy-class-name: PutIfAbsentMergePolicy
backup-count: 1
5 changes: 5 additions & 0 deletions spring/resilient-sessions/docker/conf-newyork/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ hazelcast:
- type: HASH
attributes:
- "principalName"
products:
wan-replication-ref:
eplicate-to-lon:
merge-policy-class-name: PutIfAbsentMergePolicy
backup-count: 1
10 changes: 10 additions & 0 deletions spring/spring-boot-caching-hazelcast-cache-manager/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,21 @@
<artifactId>hazelcast-spring</artifactId>
<version>${hazelcast.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-hazelcast</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down
15 changes: 10 additions & 5 deletions spring/spring-boot-caching-jcache/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,20 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-spring-boot</artifactId>
</dependency>

<!-- tag::hazelcast[] -->
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast</artifactId>
<version>5.5.0</version>
<version>5.6.0</version>
</dependency>
<!-- end::hazelcast[] -->

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-hazelcast</artifactId>
</dependency>

<dependency>
<groupId>javax.cache</groupId>
<artifactId>cache-api</artifactId>
Expand All @@ -91,6 +92,10 @@
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -18,9 +18,6 @@ class ApplicationClientServerTest {
@LocalServerPort
private int port;

@Autowired
private TestRestTemplate restTemplate;

@Autowired
private HazelcastInstance hazelcastInstance;

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down
12 changes: 9 additions & 3 deletions spring/spring-boot-embedded/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,28 @@
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-spring-boot</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-hazelcast</artifactId>
</dependency>

<!-- tag::hazelcast-dep[] -->
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-spring</artifactId>
<version>5.5.0</version>
<version>5.6.0</version>
</dependency>
<!-- end::hazelcast-dep[] -->

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add comment why we excluded this?

<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@SpringBootApplication(excludeName = "com.hazelcast.spring.HazelcastObjectExtractionConfiguration")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe worth to add an comment - why there is this exclude?

public class HazelcastApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -20,19 +22,26 @@
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = HazelcastApplication.class)
class CommandControllerIT {

@Autowired
private WebTestClient webTestClient;
private RestTestClient restTestClient;

@Autowired
private HazelcastInstance hazelcastInstance;

@Autowired
private Map<String, String> 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()
Expand All @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

/**
Expand Down
5 changes: 5 additions & 0 deletions spring/spring-hibernate-2ndlevel-cache/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-hazelcast</artifactId>
</dependency>

<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-hibernate53</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down