Skip to content

Add smoke test with Spring Session and Hazelcast #28173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
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 spring-boot-project/spring-boot-dependencies/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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"))
}
Original file line number Diff line number Diff line change
@@ -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);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
spring.security.user.name=user
spring.security.user.password=password

management.endpoints.web.exposure.include=*
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<hazelcast xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.hazelcast.com/schema/config
http://www.hazelcast.com/schema/config/hazelcast-config-3.12.xsd">
<map name="countries">
<time-to-live-seconds>600</time-to-live-seconds>
</map>
<cache name="countries">
<eviction size="200"/>

<statistics-enabled>true</statistics-enabled>
<management-enabled>true</management-enabled>
</cache>

<network>
<join>
<tcp-ip enabled="false"/>
<multicast enabled="false"/>
</join>
</network>
</hazelcast>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package smoketest.session.hazelcast;

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},
* @author Susmitha Kandula
*/
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class SampleSessionHazelcastApplicationTests {

@Autowired
private TestRestTemplate restTemplate;

@Test
public void test_sessionsEndPoint() {
ResponseEntity<Map<String, Object>> entity = (ResponseEntity<Map<String, Object>>) (ResponseEntity) this.restTemplate.withBasicAuth("user", "password")
.getForEntity("/actuator/sessions?username=user", Map.class);
assertThat(entity).isNotNull();
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody().get("sessions")).isNotNull();
}

}