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
14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.2</version>
<version>3.5.7</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.sergiofreire.xray.tutorials</groupId>
Expand All @@ -19,12 +19,12 @@
<!-- the following lines were needed because for vscode -->
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<junit-jupiter.version>5.10.2</junit-jupiter.version>
<xray-junit-extensions.version>0.7.3</xray-junit-extensions.version>
<xray-maven-plugin.version>0.8.0</xray-maven-plugin.version>
<maven-failsafe-plugin.version>3.2.5</maven-failsafe-plugin.version>
<maven-surefire-plugin.version>3.2.5</maven-surefire-plugin.version>
<jacoco.version>0.8.13</jacoco.version>
<junit-jupiter.version>5.14.1</junit-jupiter.version>
<xray-junit-extensions.version>0.9.0</xray-junit-extensions.version>
<xray-maven-plugin.version>0.9.0</xray-maven-plugin.version>
<maven-failsafe-plugin.version>3.5.4</maven-failsafe-plugin.version>
<maven-surefire-plugin.version>3.5.4</maven-surefire-plugin.version>
<jacoco.version>0.8.14</jacoco.version>
<unit.coverage.file>${project.build.directory}/jacoco-output/jacoco-unit-tests.exec</unit.coverage.file>
<it.coverage.file>${project.build.directory}/jacoco-output/jacoco-it-tests.exec</it.coverage.file>
<merged.coverage.file>${project.build.directory}/jacoco-output/merged.exec</merged.coverage.file>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.sergiofreire.xray.tutorials.springboot.boundary;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Controller
public class IndexController {

@GetMapping("/")
public String index() {
return "Welcome to this amazing website!";
return "index";
}

}
62 changes: 55 additions & 7 deletions src/main/resources/templates/greeting.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,58 @@
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<title>Getting Started: Serving Web Content</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="A simple Thymeleaf web page example saying hello to a user." />
<meta name="robots" content="index, follow" />

<title>Hello Page</title>

<!-- Preconnect for faster font loading -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />

<!-- Accessible, performant font -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap" rel="stylesheet">

<!-- Minimal inline CSS (fast load, high contrast) -->
<style>
body {
font-family: 'Inter', system-ui, sans-serif;
margin: 0;
padding: 2rem;
background-color: #ffffff;
color: #111827;
font-size: 1.125rem;
line-height: 1.6;
}
main {
max-width: 600px;
margin: auto;
text-align: center;
}
h1 {
font-size: 2rem;
color: #1d4ed8;
margin-bottom: 1rem;
}
p {
margin: 0;
}
</style>
</head>

<body>
<p th:text="|Hello, ${name}!|" />
<main>
<h1>Hello!</h1>
<p th:text="|Hello, ${name}!|">Hello, Guest!</p>
</main>

<!-- Lightweight script placeholder (deferred for performance) -->
<script defer>
// Example: Lighthouse likes scripts to be deferred
console.info("Page loaded successfully.");
</script>
</body>
</html>
</html>
57 changes: 57 additions & 0 deletions src/main/resources/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="A simple Thymeleaf web page example saying hello to a user." />
<meta name="robots" content="index, follow" />

<title>Hello Page</title>

<!-- Preconnect for faster font loading -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />

<!-- Accessible, performant font -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap" rel="stylesheet">

<!-- Minimal inline CSS (fast load, high contrast) -->
<style>
body {
font-family: 'Inter', system-ui, sans-serif;
margin: 0;
padding: 2rem;
background-color: #ffffff;
color: #111827;
font-size: 1.125rem;
line-height: 1.6;
}
main {
max-width: 600px;
margin: auto;
text-align: center;
}
h1 {
font-size: 2rem;
color: #1d4ed8;
margin-bottom: 1rem;
}
p {
margin: 0;
}
</style>
</head>

<body>
<main>
<h1>Welcome to this amazing website!</h1>
</main>

<!-- Lightweight script placeholder (deferred for performance) -->
<script defer>
// Example: Lighthouse likes scripts to be deferred
console.info("Page loaded successfully.");
</script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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;

Expand All @@ -18,6 +19,9 @@ class IndexControllerIT {
void getWelcomeMessage() throws Exception {
ResponseEntity<String> response = template.getForEntity("/", String.class);

assertThat(response.getBody()).isEqualTo("Welcome to this amazing website!");
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(response.getHeaders().getContentType()).toString().equals("text/html;charset=UTF-8");
// che
assertThat(response.getBody()).contains("Welcome to this amazing website!");
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.sergiofreire.xray.tutorials.springboot;

import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.containsString;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -30,6 +30,6 @@ class IndexControllerMockedIT {
void getWelcomeMessage() throws Exception {
mvc.perform(MockMvcRequestBuilders.get("/").accept(MediaType.TEXT_PLAIN))
.andExpect(status().isOk())
.andExpect(content().string(equalTo("Welcome to this amazing website!")));
.andExpect(content().string(containsString("Welcome to this amazing website!")));
}
}
Loading