From ff304c67aab6efced667e1dc8d7a92ba88522481 Mon Sep 17 00:00:00 2001 From: Susmitha Date: Fri, 1 Oct 2021 14:38:14 -0700 Subject: [PATCH 1/3] Added smoke test for session hazel cast. --- .../build.gradle | 16 ++++++++ .../SampleSessionHazelcastApplication.java | 29 ++++++++++++++ .../src/main/resources/application.properties | 4 ++ ...ampleSessionHazelcastApplicationTests.java | 39 +++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/build.gradle create mode 100644 spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/main/java/smoketest/session/hazelcast/SampleSessionHazelcastApplication.java create mode 100644 spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/main/resources/application.properties create mode 100644 spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/test/java/smoketest/session/hazelcast/SampleSessionHazelcastApplicationTests.java diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/build.gradle new file mode 100644 index 000000000000..548705c44fb8 --- /dev/null +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/build.gradle @@ -0,0 +1,16 @@ +plugins { + id "java" + id "org.springframework.boot.conventions" +} + +description = "Spring Boot Session smoke test" + +dependencies { + implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-actuator")) + implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-security")) + implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web")) + implementation("com.hazelcast:hazelcast") + implementation("org.springframework.session:spring-session-hazelcast") + + testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) +} diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/main/java/smoketest/session/hazelcast/SampleSessionHazelcastApplication.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/main/java/smoketest/session/hazelcast/SampleSessionHazelcastApplication.java new file mode 100644 index 000000000000..8c0b9ef2feaa --- /dev/null +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/main/java/smoketest/session/hazelcast/SampleSessionHazelcastApplication.java @@ -0,0 +1,29 @@ +/* + * Copyright 2012-2019 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package smoketest.session.hazelcast; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SampleSessionHazelcastApplication { + + public static void main(String[] args) { + SpringApplication.run(SampleSessionHazelcastApplication.class); + } + +} diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/main/resources/application.properties b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/main/resources/application.properties new file mode 100644 index 000000000000..ec27160a368b --- /dev/null +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/main/resources/application.properties @@ -0,0 +1,4 @@ +spring.security.user.name=user +spring.security.user.password=password + +management.endpoints.web.exposure.include=* \ No newline at end of file diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/test/java/smoketest/session/hazelcast/SampleSessionHazelcastApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/test/java/smoketest/session/hazelcast/SampleSessionHazelcastApplicationTests.java new file mode 100644 index 000000000000..4d47418ba121 --- /dev/null +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/test/java/smoketest/session/hazelcast/SampleSessionHazelcastApplicationTests.java @@ -0,0 +1,39 @@ +package smoketest.session.hazelcast; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Map; + + +/** + * Tests for {@link SampleSessionHazelcastApplication}, + * + */ +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class SampleSessionHazelcastApplicationTests { + + @Autowired + private TestRestTemplate restTemplate; + + @Test + public void test_sessionsEndPoint() { + ResponseEntity> entity = asMapEntity( + this.restTemplate.withBasicAuth("user", "password") + .getForEntity("/actuator/sessions?username=user", Map.class)); + assertThat(entity).isNotNull(); + assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); + } + + static ResponseEntity> asMapEntity(ResponseEntity entity) { + return (ResponseEntity) entity; + } + +} From 985ede68f89cef800226401a30454f8ece96e821 Mon Sep 17 00:00:00 2001 From: Susmitha Date: Fri, 1 Oct 2021 15:51:47 -0700 Subject: [PATCH 2/3] Added hazelcast.xml and upgraded sessions bom. --- .../spring-boot-dependencies/build.gradle | 2 +- .../src/main/resources/hazelcast.xml | 21 +++++++++++++++++++ ...ampleSessionHazelcastApplicationTests.java | 11 +++------- 3 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/main/resources/hazelcast.xml diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 4c666f34d57b..599aef79fe44 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1700,7 +1700,7 @@ bom { ] } } - library("Spring Session Bom", "2021.1.0-M1") { + library("Spring Session Bom", "2021.1.0-SNAPSHOT") { group("org.springframework.session") { imports = [ "spring-session-bom" diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/main/resources/hazelcast.xml b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/main/resources/hazelcast.xml new file mode 100644 index 000000000000..4fbcdb0b596f --- /dev/null +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/main/resources/hazelcast.xml @@ -0,0 +1,21 @@ + + + 600 + + + + + true + true + + + + + + + + + diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/test/java/smoketest/session/hazelcast/SampleSessionHazelcastApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/test/java/smoketest/session/hazelcast/SampleSessionHazelcastApplicationTests.java index 4d47418ba121..d942794b6df6 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/test/java/smoketest/session/hazelcast/SampleSessionHazelcastApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/test/java/smoketest/session/hazelcast/SampleSessionHazelcastApplicationTests.java @@ -1,6 +1,5 @@ package smoketest.session.hazelcast; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -25,15 +24,11 @@ public class SampleSessionHazelcastApplicationTests { @Test public void test_sessionsEndPoint() { - ResponseEntity> entity = asMapEntity( - this.restTemplate.withBasicAuth("user", "password") - .getForEntity("/actuator/sessions?username=user", Map.class)); + ResponseEntity> entity = (ResponseEntity>) (ResponseEntity) this.restTemplate.withBasicAuth("user", "password") + .getForEntity("/actuator/sessions?username=user", Map.class); assertThat(entity).isNotNull(); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - } - - static ResponseEntity> asMapEntity(ResponseEntity entity) { - return (ResponseEntity) entity; + assertThat(entity.getBody().get("sessions")).isNotNull(); } } From f4cd9bd9aa463422f6c172b123338251738e3436 Mon Sep 17 00:00:00 2001 From: Susmitha Date: Fri, 1 Oct 2021 15:53:31 -0700 Subject: [PATCH 3/3] Added author info --- .../hazelcast/SampleSessionHazelcastApplicationTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/test/java/smoketest/session/hazelcast/SampleSessionHazelcastApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/test/java/smoketest/session/hazelcast/SampleSessionHazelcastApplicationTests.java index d942794b6df6..a607dc35d388 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/test/java/smoketest/session/hazelcast/SampleSessionHazelcastApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/test/java/smoketest/session/hazelcast/SampleSessionHazelcastApplicationTests.java @@ -14,7 +14,7 @@ /** * Tests for {@link SampleSessionHazelcastApplication}, - * + * @author Susmitha Kandula */ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class SampleSessionHazelcastApplicationTests {