Skip to content

Commit 70dd655

Browse files
Susmithambhave
Susmitha
authored andcommitted
Add smoke test with Spring Session and Hazelcast
See gh-28173
1 parent 2963770 commit 70dd655

File tree

6 files changed

+105
-1
lines changed

6 files changed

+105
-1
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1700,7 +1700,7 @@ bom {
17001700
]
17011701
}
17021702
}
1703-
library("Spring Session Bom", "2021.1.0-M1") {
1703+
library("Spring Session Bom", "2021.1.0-SNAPSHOT") {
17041704
group("org.springframework.session") {
17051705
imports = [
17061706
"spring-session-bom"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
plugins {
2+
id "java"
3+
id "org.springframework.boot.conventions"
4+
}
5+
6+
description = "Spring Boot Session smoke test"
7+
8+
dependencies {
9+
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-actuator"))
10+
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-security"))
11+
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web"))
12+
implementation("com.hazelcast:hazelcast")
13+
implementation("org.springframework.session:spring-session-hazelcast")
14+
15+
testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test"))
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2012-2019 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.session.hazelcast;
18+
19+
import org.springframework.boot.SpringApplication;
20+
import org.springframework.boot.autoconfigure.SpringBootApplication;
21+
22+
@SpringBootApplication
23+
public class SampleSessionHazelcastApplication {
24+
25+
public static void main(String[] args) {
26+
SpringApplication.run(SampleSessionHazelcastApplication.class);
27+
}
28+
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
spring.security.user.name=user
2+
spring.security.user.password=password
3+
4+
management.endpoints.web.exposure.include=*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<hazelcast xmlns="http://www.hazelcast.com/schema/config"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://www.hazelcast.com/schema/config
4+
http://www.hazelcast.com/schema/config/hazelcast-config-3.12.xsd">
5+
<map name="countries">
6+
<time-to-live-seconds>600</time-to-live-seconds>
7+
</map>
8+
<cache name="countries">
9+
<eviction size="200"/>
10+
11+
<statistics-enabled>true</statistics-enabled>
12+
<management-enabled>true</management-enabled>
13+
</cache>
14+
15+
<network>
16+
<join>
17+
<tcp-ip enabled="false"/>
18+
<multicast enabled="false"/>
19+
</join>
20+
</network>
21+
</hazelcast>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package smoketest.session.hazelcast;
2+
3+
import org.junit.jupiter.api.Test;
4+
import org.springframework.beans.factory.annotation.Autowired;
5+
import org.springframework.boot.test.context.SpringBootTest;
6+
import org.springframework.boot.test.web.client.TestRestTemplate;
7+
import org.springframework.http.HttpStatus;
8+
import org.springframework.http.ResponseEntity;
9+
10+
import static org.assertj.core.api.Assertions.assertThat;
11+
12+
import java.util.Map;
13+
14+
15+
/**
16+
* Tests for {@link SampleSessionHazelcastApplication},
17+
* @author Susmitha Kandula
18+
*/
19+
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
20+
public class SampleSessionHazelcastApplicationTests {
21+
22+
@Autowired
23+
private TestRestTemplate restTemplate;
24+
25+
@Test
26+
public void test_sessionsEndPoint() {
27+
ResponseEntity<Map<String, Object>> entity = (ResponseEntity<Map<String, Object>>) (ResponseEntity) this.restTemplate.withBasicAuth("user", "password")
28+
.getForEntity("/actuator/sessions?username=user", Map.class);
29+
assertThat(entity).isNotNull();
30+
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
31+
assertThat(entity.getBody().get("sessions")).isNotNull();
32+
}
33+
34+
}

0 commit comments

Comments
 (0)