From 5a3e05b57d0e49449e21d334669e3b765f87ccb2 Mon Sep 17 00:00:00 2001
From: Christian Kumpe <3316684+ckumpe@users.noreply.github.com>
Date: Wed, 26 Jul 2023 08:01:33 +0200
Subject: [PATCH 01/10] Update to Java 17
---
integration/spring/pom.xml | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/integration/spring/pom.xml b/integration/spring/pom.xml
index b89cb2aa..78591eff 100644
--- a/integration/spring/pom.xml
+++ b/integration/spring/pom.xml
@@ -45,7 +45,7 @@
rhyme/spring
- 11
+ 17
2.5.8
@@ -147,6 +147,14 @@
org.apache.felix
maven-bundle-plugin
+
+
+
+ org.ow2.asm
+ asm
+ 9.1
+
+
baseline
From fef2613e58983d6d6338aa31b9b4e43f1ee9d976 Mon Sep 17 00:00:00 2001
From: Christian Kumpe <3316684+ckumpe@users.noreply.github.com>
Date: Wed, 26 Jul 2023 08:03:44 +0200
Subject: [PATCH 02/10] Upgrade from Java EE to Jakarta EE
---
integration/spring/pom.xml | 5 ++---
.../io/wcm/caravan/rhyme/spring/impl/SpringRhymeImpl.java | 2 +-
.../wcm/caravan/rhyme/spring/impl/UrlFingerprintingImpl.java | 2 +-
.../spring/impl/LinkableResourceMessageConverterTest.java | 2 +-
.../wcm/caravan/rhyme/spring/impl/SpringRhymeImplTest.java | 2 +-
.../caravan/rhyme/spring/impl/UrlFingerprintingImplTest.java | 2 +-
6 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/integration/spring/pom.xml b/integration/spring/pom.xml
index 78591eff..c2a41fcb 100644
--- a/integration/spring/pom.xml
+++ b/integration/spring/pom.xml
@@ -64,10 +64,9 @@
- javax.servlet
- javax.servlet-api
+ jakarta.servlet
+ jakarta.servlet-api
provided
- 4.0.1
diff --git a/integration/spring/src/main/java/io/wcm/caravan/rhyme/spring/impl/SpringRhymeImpl.java b/integration/spring/src/main/java/io/wcm/caravan/rhyme/spring/impl/SpringRhymeImpl.java
index 378fb3ac..fd1b4eea 100644
--- a/integration/spring/src/main/java/io/wcm/caravan/rhyme/spring/impl/SpringRhymeImpl.java
+++ b/integration/spring/src/main/java/io/wcm/caravan/rhyme/spring/impl/SpringRhymeImpl.java
@@ -25,7 +25,7 @@
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/integration/spring/src/main/java/io/wcm/caravan/rhyme/spring/impl/UrlFingerprintingImpl.java b/integration/spring/src/main/java/io/wcm/caravan/rhyme/spring/impl/UrlFingerprintingImpl.java
index e6c68794..ea48814c 100644
--- a/integration/spring/src/main/java/io/wcm/caravan/rhyme/spring/impl/UrlFingerprintingImpl.java
+++ b/integration/spring/src/main/java/io/wcm/caravan/rhyme/spring/impl/UrlFingerprintingImpl.java
@@ -25,7 +25,7 @@
import java.util.Map;
import java.util.function.Supplier;
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.springframework.hateoas.server.mvc.WebMvcLinkBuilder;
diff --git a/integration/spring/src/test/java/io/wcm/caravan/rhyme/spring/impl/LinkableResourceMessageConverterTest.java b/integration/spring/src/test/java/io/wcm/caravan/rhyme/spring/impl/LinkableResourceMessageConverterTest.java
index a125dc73..27d46bee 100644
--- a/integration/spring/src/test/java/io/wcm/caravan/rhyme/spring/impl/LinkableResourceMessageConverterTest.java
+++ b/integration/spring/src/test/java/io/wcm/caravan/rhyme/spring/impl/LinkableResourceMessageConverterTest.java
@@ -25,7 +25,7 @@
import java.io.IOException;
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequest;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
diff --git a/integration/spring/src/test/java/io/wcm/caravan/rhyme/spring/impl/SpringRhymeImplTest.java b/integration/spring/src/test/java/io/wcm/caravan/rhyme/spring/impl/SpringRhymeImplTest.java
index 3dea4a7a..eb4b8cd4 100644
--- a/integration/spring/src/test/java/io/wcm/caravan/rhyme/spring/impl/SpringRhymeImplTest.java
+++ b/integration/spring/src/test/java/io/wcm/caravan/rhyme/spring/impl/SpringRhymeImplTest.java
@@ -25,7 +25,7 @@
import java.time.Duration;
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequest;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
diff --git a/integration/spring/src/test/java/io/wcm/caravan/rhyme/spring/impl/UrlFingerprintingImplTest.java b/integration/spring/src/test/java/io/wcm/caravan/rhyme/spring/impl/UrlFingerprintingImplTest.java
index d5fde98e..4a7a5028 100644
--- a/integration/spring/src/test/java/io/wcm/caravan/rhyme/spring/impl/UrlFingerprintingImplTest.java
+++ b/integration/spring/src/test/java/io/wcm/caravan/rhyme/spring/impl/UrlFingerprintingImplTest.java
@@ -30,7 +30,7 @@
import java.time.Duration;
import java.time.Instant;
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
From 341d988119752ce3086ca6142b0ff6182e47179e Mon Sep 17 00:00:00 2001
From: Christian Kumpe <3316684+ckumpe@users.noreply.github.com>
Date: Wed, 26 Jul 2023 08:04:20 +0200
Subject: [PATCH 03/10] Upgrade to Spring Boot 3
---
integration/spring/pom.xml | 2 +-
.../spring/impl/SpringExceptionStatusAndLoggingStrategy.java | 2 +-
integration/spring/src/main/resources/META-INF/spring.factories | 2 --
...springframework.boot.autoconfigure.AutoConfiguration.imports | 1 +
.../caravan/rhyme/spring/impl/UrlFingerprintingImplTest.java | 2 ++
5 files changed, 5 insertions(+), 4 deletions(-)
delete mode 100644 integration/spring/src/main/resources/META-INF/spring.factories
create mode 100644 integration/spring/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
diff --git a/integration/spring/pom.xml b/integration/spring/pom.xml
index c2a41fcb..f95d6ab6 100644
--- a/integration/spring/pom.xml
+++ b/integration/spring/pom.xml
@@ -46,7 +46,7 @@
rhyme/spring
17
- 2.5.8
+ 3.1.2
diff --git a/integration/spring/src/main/java/io/wcm/caravan/rhyme/spring/impl/SpringExceptionStatusAndLoggingStrategy.java b/integration/spring/src/main/java/io/wcm/caravan/rhyme/spring/impl/SpringExceptionStatusAndLoggingStrategy.java
index 0c0c7b59..95233fff 100644
--- a/integration/spring/src/main/java/io/wcm/caravan/rhyme/spring/impl/SpringExceptionStatusAndLoggingStrategy.java
+++ b/integration/spring/src/main/java/io/wcm/caravan/rhyme/spring/impl/SpringExceptionStatusAndLoggingStrategy.java
@@ -42,7 +42,7 @@ class SpringExceptionStatusAndLoggingStrategy implements ExceptionStatusAndLoggi
public Integer extractStatusCode(Throwable error) {
if (error instanceof ResponseStatusException) {
- return ((ResponseStatusException)error).getStatus().value();
+ return ((ResponseStatusException)error).getStatusCode().value();
}
if (error.getClass().isAnnotationPresent(ResponseStatus.class)) {
diff --git a/integration/spring/src/main/resources/META-INF/spring.factories b/integration/spring/src/main/resources/META-INF/spring.factories
deleted file mode 100644
index b31c0523..00000000
--- a/integration/spring/src/main/resources/META-INF/spring.factories
+++ /dev/null
@@ -1,2 +0,0 @@
-org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
-io.wcm.caravan.rhyme.spring.impl.SpringRhymeAutoConfiguration
\ No newline at end of file
diff --git a/integration/spring/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/integration/spring/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
new file mode 100644
index 00000000..976881bf
--- /dev/null
+++ b/integration/spring/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -0,0 +1 @@
+io.wcm.caravan.rhyme.spring.impl.SpringRhymeAutoConfiguration
diff --git a/integration/spring/src/test/java/io/wcm/caravan/rhyme/spring/impl/UrlFingerprintingImplTest.java b/integration/spring/src/test/java/io/wcm/caravan/rhyme/spring/impl/UrlFingerprintingImplTest.java
index 4a7a5028..554f0465 100644
--- a/integration/spring/src/test/java/io/wcm/caravan/rhyme/spring/impl/UrlFingerprintingImplTest.java
+++ b/integration/spring/src/test/java/io/wcm/caravan/rhyme/spring/impl/UrlFingerprintingImplTest.java
@@ -38,6 +38,7 @@
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.hateoas.server.mvc.WebMvcLinkBuilder;
import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import io.wcm.caravan.hal.resource.Link;
@@ -77,6 +78,7 @@ void should_build_links_if_no_other_methods_are_called() {
assertThatNoFingerprintingIsPresentInLink(fingerprinting);
}
+ @GetMapping("/somePath")
ResponseEntity controllerWithRequiredAnnotatedParamFoo(@RequestParam("foo") String foo) {
return ResponseEntity.ok("foo was set to " + foo);
}
From 549a3d57228870d9ae2b382ed3797961fd3e1bc1 Mon Sep 17 00:00:00 2001
From: Christian Kumpe <3316684+ckumpe@users.noreply.github.com>
Date: Wed, 26 Jul 2023 09:03:51 +0200
Subject: [PATCH 04/10] Prepare the next release
---
integration/spring/changes.xml | 6 ++++++
integration/spring/pom.xml | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/integration/spring/changes.xml b/integration/spring/changes.xml
index 7b1c7ae9..c9c88e7b 100644
--- a/integration/spring/changes.xml
+++ b/integration/spring/changes.xml
@@ -23,6 +23,12 @@
xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd">
+
+
+ Migrate to Java 17 and Spring Boot 3
+
+
+
Reduced expectations in AbstractHalResourceLoaderTest on how exactly malformed responses are handled by client implementations.
diff --git a/integration/spring/pom.xml b/integration/spring/pom.xml
index f95d6ab6..38ab97c2 100644
--- a/integration/spring/pom.xml
+++ b/integration/spring/pom.xml
@@ -30,7 +30,7 @@
io.wcm.caravan.rhyme.spring
- 1.0.1-SNAPSHOT
+ 2.0.0-SNAPSHOT
bundle
Rhyme - Spring Integration
From 12c60346bb26ed4797ea410c3e77cea1785a4b8a Mon Sep 17 00:00:00 2001
From: Christian Kumpe <3316684+ckumpe@users.noreply.github.com>
Date: Wed, 6 Sep 2023 13:24:16 +0200
Subject: [PATCH 05/10] Include Spring integration only for JDK17 and up
---
pom.xml | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index e9564d67..3dce05af 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,8 +42,7 @@
core
integration/aem
integration/osgi-jaxrs
- integration/spring
- testing
+ testing
tooling/coverage
tooling/docs-maven-plugin
tooling/parent
@@ -96,4 +95,16 @@
+
+
+ java17
+
+ [17,)
+
+
+ integration/spring
+
+
+
+
From 53bcc2b5fb1591544afca6657424e4e777b0facd Mon Sep 17 00:00:00 2001
From: Christian Kumpe <3316684+ckumpe@users.noreply.github.com>
Date: Wed, 6 Sep 2023 13:38:20 +0200
Subject: [PATCH 06/10] Fix SonarCloud issues
---
.../spring/impl/SpringExceptionStatusAndLoggingStrategy.java | 4 ++--
.../io/wcm/caravan/rhyme/spring/impl/SpringRhymeImpl.java | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/integration/spring/src/main/java/io/wcm/caravan/rhyme/spring/impl/SpringExceptionStatusAndLoggingStrategy.java b/integration/spring/src/main/java/io/wcm/caravan/rhyme/spring/impl/SpringExceptionStatusAndLoggingStrategy.java
index 95233fff..724eaf60 100644
--- a/integration/spring/src/main/java/io/wcm/caravan/rhyme/spring/impl/SpringExceptionStatusAndLoggingStrategy.java
+++ b/integration/spring/src/main/java/io/wcm/caravan/rhyme/spring/impl/SpringExceptionStatusAndLoggingStrategy.java
@@ -41,8 +41,8 @@ class SpringExceptionStatusAndLoggingStrategy implements ExceptionStatusAndLoggi
@Override
public Integer extractStatusCode(Throwable error) {
- if (error instanceof ResponseStatusException) {
- return ((ResponseStatusException)error).getStatusCode().value();
+ if (error instanceof ResponseStatusException responsestatusexception) {
+ return responsestatusexception.getStatusCode().value();
}
if (error.getClass().isAnnotationPresent(ResponseStatus.class)) {
diff --git a/integration/spring/src/main/java/io/wcm/caravan/rhyme/spring/impl/SpringRhymeImpl.java b/integration/spring/src/main/java/io/wcm/caravan/rhyme/spring/impl/SpringRhymeImpl.java
index fd1b4eea..65419286 100644
--- a/integration/spring/src/main/java/io/wcm/caravan/rhyme/spring/impl/SpringRhymeImpl.java
+++ b/integration/spring/src/main/java/io/wcm/caravan/rhyme/spring/impl/SpringRhymeImpl.java
@@ -98,7 +98,7 @@ private static RhymeBuilder createRhymeBuilder(HttpServletRequest httpRequest, H
private static String getRequestUrl(HttpServletRequest httpRequest) {
- StringBuffer requestUrl = httpRequest.getRequestURL();
+ StringBuilder requestUrl = new StringBuilder(httpRequest.getRequestURL());
if (httpRequest.getQueryString() != null) {
requestUrl.append("?");
From 25109e90853433b3666b1dbb2ff1d7d2b37d00fa Mon Sep 17 00:00:00 2001
From: Christian Kumpe <3316684+ckumpe@users.noreply.github.com>
Date: Wed, 6 Sep 2023 15:42:15 +0200
Subject: [PATCH 07/10] Update Spring related examples to Spring Boot 3
---
examples/spring-hello-world/README.md | 4 ++--
examples/spring-hello-world/pom.xml | 12 ++++++++----
examples/spring-hypermedia/README.md | 2 +-
examples/spring-hypermedia/pom.xml | 8 ++++----
.../spring/hypermedia/CompanyApiController.java | 5 ++++-
.../spring/hypermedia/CompanyApiLinkBuilder.java | 7 +++----
.../rhyme/examples/spring/hypermedia/Employee.java | 14 +++++++-------
.../spring/hypermedia/EmployeeController.java | 3 +++
.../rhyme/examples/spring/hypermedia/Manager.java | 12 ++++++------
.../spring/hypermedia/ManagerController.java | 2 ++
.../hypermedia/RepositoryModificationListener.java | 7 +++----
.../spring/hypermedia/AbstractCompanyApiIT.java | 7 ++++---
.../spring/hypermedia/ExternalClientIT.java | 2 +-
.../rhyme/spring/impl/SpringErrorHandlingIT.java | 10 ++++++----
pom.xml | 9 ++++-----
tooling/coverage/pom.xml | 4 ++--
16 files changed, 60 insertions(+), 48 deletions(-)
diff --git a/examples/spring-hello-world/README.md b/examples/spring-hello-world/README.md
index 77823205..7271653a 100644
--- a/examples/spring-hello-world/README.md
+++ b/examples/spring-hello-world/README.md
@@ -8,13 +8,13 @@ to render and consume [HAL+JSON](https://stateless.group/hal_specification.html)
# Build and Run
-Using **JDK 8, 11 or 17** and **Apache Maven 3.6.3** (or higher) you should be able to build and run the example like this:
+Using **JDK 17** and **Apache Maven 3.6.3** (or higher) you should be able to build and run the example like this:
```
git clone https://github.com/wcm-io-caravan/caravan-rhyme.git
cd caravan-rhyme
git checkout master
-mvn -f examples/spring-helloworld/ clean verify spring-boot:run
+mvn -f examples/spring-hello-world/ clean verify spring-boot:run
```
If there are any failures during the build or integration tests, then please open an issue on github!
diff --git a/examples/spring-hello-world/pom.xml b/examples/spring-hello-world/pom.xml
index ac6bd851..0244c53f 100644
--- a/examples/spring-hello-world/pom.xml
+++ b/examples/spring-hello-world/pom.xml
@@ -25,8 +25,8 @@
- 11
- 2.5.8
+ 17
+ 3.1.2
@@ -45,6 +45,10 @@
+
+ org.springframework.boot
+ spring-boot-starter-webflux
+
org.springframework.boot
spring-boot-starter-hateoas
@@ -58,7 +62,7 @@
io.wcm.caravan
io.wcm.caravan.rhyme.spring
- 1.0.0
+ 2.0.0-SNAPSHOT
@@ -156,4 +160,4 @@
-
\ No newline at end of file
+
diff --git a/examples/spring-hypermedia/README.md b/examples/spring-hypermedia/README.md
index 6ab1a102..26d96fba 100644
--- a/examples/spring-hypermedia/README.md
+++ b/examples/spring-hypermedia/README.md
@@ -22,7 +22,7 @@ Make sure not to miss loading a `company:detailedEmployee` link when you run the
# Build and Run
-Using **JDK 8, 11 or 17** and **Apache Maven 3.6.3** (or higher) you should be able to build and run the example like this:
+Using **JDK 17** and **Apache Maven 3.6.3** (or higher) you should be able to build and run the example like this:
```
git clone https://github.com/wcm-io-caravan/caravan-rhyme.git
diff --git a/examples/spring-hypermedia/pom.xml b/examples/spring-hypermedia/pom.xml
index 5e7edff9..a9ff3064 100644
--- a/examples/spring-hypermedia/pom.xml
+++ b/examples/spring-hypermedia/pom.xml
@@ -27,8 +27,8 @@
- 11
- 2.5.8
+ 17
+ 3.1.2
@@ -80,7 +80,7 @@
io.wcm.caravan
io.wcm.caravan.rhyme.spring
- 1.0.1-SNAPSHOT
+ 2.0.0-SNAPSHOT
@@ -190,4 +190,4 @@
-
\ No newline at end of file
+
diff --git a/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/CompanyApiController.java b/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/CompanyApiController.java
index 6bc01678..61d9fd7e 100644
--- a/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/CompanyApiController.java
+++ b/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/CompanyApiController.java
@@ -24,6 +24,7 @@
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -48,10 +49,13 @@ class CompanyApiController implements CompanyApi {
// inject the controllers for all resources that are linked from the entry point
@Autowired
+ @Lazy
private EmployeeController employees;
@Autowired
+ @Lazy
private ManagerController managers;
@Autowired
+ @Lazy
private DetailedEmployeeController detailedEmployees;
@Autowired
@@ -108,7 +112,6 @@ public ManagerResource getManagerById(Long id) {
}
@Override
-
public DetailedEmployeeResource getDetailedEmployeeById(Long id) {
return detailedEmployees.findById(id);
}
diff --git a/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/CompanyApiLinkBuilder.java b/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/CompanyApiLinkBuilder.java
index dc5352bd..f0cc3a95 100644
--- a/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/CompanyApiLinkBuilder.java
+++ b/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/CompanyApiLinkBuilder.java
@@ -27,8 +27,6 @@
import java.time.Duration;
-import javax.servlet.http.HttpServletRequest;
-
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -41,6 +39,7 @@
import io.wcm.caravan.rhyme.spring.api.RhymeLinkBuilder;
import io.wcm.caravan.rhyme.spring.api.SpringRhyme;
import io.wcm.caravan.rhyme.spring.api.UrlFingerprinting;
+import jakarta.servlet.http.HttpServletRequest;
/**
* Defines common logic (e.g. URL fingerprinting) for building any link to your resources in this project .
@@ -126,9 +125,9 @@ boolean hasClientPreferences() {
* by the {@link WebMvcLinkBuilder} class, but additional query parameters that are not directly
* present in the API and controller signatures can be appended by {@link UrlFingerprinting}.
* @param webMvcLinkBuilder created with {@link WebMvcLinkBuilder#linkTo(Class)} and
- * {@link WebMvcLinkBuilder#methodOn(Class, Object...)}
+ * {@link WebMvcLinkBuilder#methodOn(Class, Object...)}
* @return a {@link RhymeLinkBuilder} that you can use to decorate the link with name and title attributes, and
- * then finally build it
+ * then finally build it
* @see WebMvcLinkBuilder
*/
RhymeLinkBuilder create(WebMvcLinkBuilder webMvcLinkBuilder) {
diff --git a/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/Employee.java b/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/Employee.java
index 72147b1c..3f3e8677 100644
--- a/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/Employee.java
+++ b/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/Employee.java
@@ -15,14 +15,14 @@
*/
package io.wcm.caravan.rhyme.examples.spring.hypermedia;
-import javax.persistence.Entity;
-import javax.persistence.EntityListeners;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.OneToOne;
-
import com.fasterxml.jackson.annotation.JsonIgnore;
+import jakarta.persistence.Entity;
+import jakarta.persistence.EntityListeners;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.Id;
+import jakarta.persistence.ManyToOne;
+
/**
* @author Greg Turnquist
*/
@@ -46,7 +46,7 @@ public class Employee {
* To break the recursive, bidirectional relationship, don't serialize {@literal manager}.
*/
@JsonIgnore
- @OneToOne
+ @ManyToOne
private Manager manager;
Employee(String name, String role, Manager manager) {
diff --git a/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/EmployeeController.java b/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/EmployeeController.java
index faa74c55..5c5ea391 100644
--- a/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/EmployeeController.java
+++ b/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/EmployeeController.java
@@ -46,10 +46,13 @@ class EmployeeController {
// inject the controllers for all related resources
@Autowired
+ @org.springframework.context.annotation.Lazy
private CompanyApiController api;
@Autowired
+ @org.springframework.context.annotation.Lazy
private ManagerController managers;
@Autowired
+ @org.springframework.context.annotation.Lazy
private DetailedEmployeeController detailedEmployees;
@Autowired
diff --git a/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/Manager.java b/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/Manager.java
index 47bf3e80..624aca1d 100644
--- a/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/Manager.java
+++ b/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/Manager.java
@@ -18,14 +18,14 @@
import java.util.ArrayList;
import java.util.List;
-import javax.persistence.Entity;
-import javax.persistence.EntityListeners;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.OneToMany;
-
import com.fasterxml.jackson.annotation.JsonIgnore;
+import jakarta.persistence.Entity;
+import jakarta.persistence.EntityListeners;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.Id;
+import jakarta.persistence.OneToMany;
+
/**
* @author Greg Turnquist
*/
diff --git a/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/ManagerController.java b/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/ManagerController.java
index 5ddb784f..5ca54742 100644
--- a/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/ManagerController.java
+++ b/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/ManagerController.java
@@ -47,8 +47,10 @@ class ManagerController {
// inject the controllers for all related resources
@Autowired
+ @org.springframework.context.annotation.Lazy
private CompanyApiController api;
@Autowired
+ @org.springframework.context.annotation.Lazy
private EmployeeController employees;
@Autowired
diff --git a/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/RepositoryModificationListener.java b/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/RepositoryModificationListener.java
index 30c9f8f6..74aaae37 100644
--- a/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/RepositoryModificationListener.java
+++ b/examples/spring-hypermedia/src/main/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/RepositoryModificationListener.java
@@ -21,15 +21,14 @@
import java.time.Instant;
-import javax.persistence.PostPersist;
-import javax.persistence.PostRemove;
-import javax.persistence.PostUpdate;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import io.wcm.caravan.rhyme.spring.api.UrlFingerprinting;
+import jakarta.persistence.PostPersist;
+import jakarta.persistence.PostRemove;
+import jakarta.persistence.PostUpdate;
/**
* Keeps track of any modifications to the repositories for {@link Employee} and {@link Manager} entities, so that
diff --git a/examples/spring-hypermedia/src/test/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/AbstractCompanyApiIT.java b/examples/spring-hypermedia/src/test/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/AbstractCompanyApiIT.java
index 7b6fcfd5..fe283b21 100644
--- a/examples/spring-hypermedia/src/test/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/AbstractCompanyApiIT.java
+++ b/examples/spring-hypermedia/src/test/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/AbstractCompanyApiIT.java
@@ -30,10 +30,11 @@
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.mockito.internal.util.collections.Iterables;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
+import com.google.common.collect.Iterables;
+
import io.wcm.caravan.hal.resource.Link;
import io.wcm.caravan.rhyme.api.exceptions.HalApiClientException;
import io.wcm.caravan.rhyme.api.exceptions.HalApiServerException;
@@ -75,12 +76,12 @@ void setUp() {
protected Long getIdOfFirstEmployee() {
- return Iterables.firstOf(employeeRepository.findAll()).getId();
+ return Iterables.get(employeeRepository.findAll(), 0).getId();
}
protected Long getIdOfFirstManager() {
- return Iterables.firstOf(managerRepository.findAll()).getId();
+ return Iterables.get(managerRepository.findAll(), 0).getId();
}
@Test
diff --git a/examples/spring-hypermedia/src/test/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/ExternalClientIT.java b/examples/spring-hypermedia/src/test/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/ExternalClientIT.java
index bfa1b641..2a8db7b1 100644
--- a/examples/spring-hypermedia/src/test/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/ExternalClientIT.java
+++ b/examples/spring-hypermedia/src/test/java/io/wcm/caravan/rhyme/examples/spring/hypermedia/ExternalClientIT.java
@@ -71,7 +71,7 @@ protected CompanyApi getApiImplementationOrClientProxy() {
// since we don't have access to the repository in this test, the IDs need to be hard-coded
@Override
protected Long getIdOfFirstEmployee() {
- return 2L;
+ return 1L;
}
@Override
diff --git a/examples/spring-hypermedia/src/test/java/io/wcm/caravan/rhyme/spring/impl/SpringErrorHandlingIT.java b/examples/spring-hypermedia/src/test/java/io/wcm/caravan/rhyme/spring/impl/SpringErrorHandlingIT.java
index dc4eaa8e..dbeaaa3b 100644
--- a/examples/spring-hypermedia/src/test/java/io/wcm/caravan/rhyme/spring/impl/SpringErrorHandlingIT.java
+++ b/examples/spring-hypermedia/src/test/java/io/wcm/caravan/rhyme/spring/impl/SpringErrorHandlingIT.java
@@ -149,10 +149,12 @@ void should_extract_status_code_from_NoHandlerFoundException() {
String nonExistingUrl = baseUri + "/foo/bar";
- HalResponse errorResponse = getResponseFromCaughtClientException(
- (er) -> client.getRemoteResource(nonExistingUrl, ErrorThrowingResource.class));
+ ErrorThrowingResource errorResource = client.getRemoteResource(nonExistingUrl, ErrorThrowingResource.class);
- assertThat(errorResponse.getStatus())
- .isEqualTo(HttpStatus.NOT_FOUND.value());
+ HalApiClientException ex = assertThrows(HalApiClientException.class,
+ () -> errorResource.getStateWithError());
+
+ assertThat(ex.getErrorResponse()).isNotNull();
+ assertThat(ex.getErrorResponse().getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value());
}
}
diff --git a/pom.xml b/pom.xml
index 3dce05af..c6c6105c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -43,16 +43,12 @@
integration/aem
integration/osgi-jaxrs
testing
- tooling/coverage
- tooling/docs-maven-plugin
+ tooling/docs-maven-plugin
tooling/parent
examples/aem-hal-browser
examples/aws-movie-search
examples/osgi-jaxrs-example-launchpad
examples/osgi-jaxrs-example-service
- examples/spring-hello-world
- examples/spring-hypermedia
-
@@ -103,6 +99,9 @@
integration/spring
+ examples/spring-hello-world
+ examples/spring-hypermedia
+ tooling/coverage
diff --git a/tooling/coverage/pom.xml b/tooling/coverage/pom.xml
index 9fe2bf6c..b2c7a310 100644
--- a/tooling/coverage/pom.xml
+++ b/tooling/coverage/pom.xml
@@ -52,7 +52,7 @@
${project.groupId}
io.wcm.caravan.rhyme.spring
- 1.0.1-SNAPSHOT
+ 2.0.0-SNAPSHOT
provided
@@ -123,4 +123,4 @@
-
\ No newline at end of file
+
From 2f76b9bc3e5ea0770b02d8f659a34adf206e8a96 Mon Sep 17 00:00:00 2001
From: Christian Kumpe <3316684+ckumpe@users.noreply.github.com>
Date: Wed, 6 Sep 2023 15:58:00 +0200
Subject: [PATCH 08/10] Syntax fixes
---
tooling/coverage/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tooling/coverage/pom.xml b/tooling/coverage/pom.xml
index b2c7a310..46604d55 100644
--- a/tooling/coverage/pom.xml
+++ b/tooling/coverage/pom.xml
@@ -24,7 +24,7 @@
+ that all modules with code to be covered are included here as a *direct* dependency -->
${project.groupId}
io.wcm.caravan.rhyme.api-interfaces
From 4b2f562ebee9e5a1f445b6a0e69ea59b35ba8c4c Mon Sep 17 00:00:00 2001
From: Christian Kumpe <3316684+ckumpe@users.noreply.github.com>
Date: Wed, 6 Sep 2023 16:11:52 +0200
Subject: [PATCH 09/10] Update to latest Spring Boot 3 release
---
examples/spring-hello-world/pom.xml | 2 +-
examples/spring-hypermedia/pom.xml | 2 +-
integration/spring/pom.xml | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/examples/spring-hello-world/pom.xml b/examples/spring-hello-world/pom.xml
index 0244c53f..007a99a4 100644
--- a/examples/spring-hello-world/pom.xml
+++ b/examples/spring-hello-world/pom.xml
@@ -26,7 +26,7 @@
17
- 3.1.2
+ 3.1.3
diff --git a/examples/spring-hypermedia/pom.xml b/examples/spring-hypermedia/pom.xml
index a9ff3064..e07b7286 100644
--- a/examples/spring-hypermedia/pom.xml
+++ b/examples/spring-hypermedia/pom.xml
@@ -28,7 +28,7 @@
17
- 3.1.2
+ 3.1.3
diff --git a/integration/spring/pom.xml b/integration/spring/pom.xml
index 38ab97c2..444182b1 100644
--- a/integration/spring/pom.xml
+++ b/integration/spring/pom.xml
@@ -46,7 +46,7 @@
rhyme/spring
17
- 3.1.2
+ 3.1.3
From 752ac8007991a8e0d91ec47acb747d84e8955986 Mon Sep 17 00:00:00 2001
From: Christian Kumpe <3316684+ckumpe@users.noreply.github.com>
Date: Fri, 8 Sep 2023 13:39:41 +0200
Subject: [PATCH 10/10] Revert to expected error handling
---
.../src/main/resources/application.yml | 5 +++--
.../src/main/resources/application.yml | 5 +++--
.../rhyme/spring/impl/SpringErrorHandlingIT.java | 13 ++++++-------
3 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/examples/spring-hello-world/src/main/resources/application.yml b/examples/spring-hello-world/src/main/resources/application.yml
index 690a0a8d..f3cd5080 100644
--- a/examples/spring-hello-world/src/main/resources/application.yml
+++ b/examples/spring-hello-world/src/main/resources/application.yml
@@ -3,5 +3,6 @@ server:
spring:
mvc:
throw-exception-if-no-handler-found: true
- resources:
- add-mappings: false
\ No newline at end of file
+ web:
+ resources:
+ add-mappings: false
diff --git a/examples/spring-hypermedia/src/main/resources/application.yml b/examples/spring-hypermedia/src/main/resources/application.yml
index e1e47f7a..10da054a 100644
--- a/examples/spring-hypermedia/src/main/resources/application.yml
+++ b/examples/spring-hypermedia/src/main/resources/application.yml
@@ -3,5 +3,6 @@ server:
spring:
mvc:
throw-exception-if-no-handler-found: true
- resources:
- add-mappings: false
\ No newline at end of file
+ web:
+ resources:
+ add-mappings: false
diff --git a/examples/spring-hypermedia/src/test/java/io/wcm/caravan/rhyme/spring/impl/SpringErrorHandlingIT.java b/examples/spring-hypermedia/src/test/java/io/wcm/caravan/rhyme/spring/impl/SpringErrorHandlingIT.java
index dbeaaa3b..6fc35042 100644
--- a/examples/spring-hypermedia/src/test/java/io/wcm/caravan/rhyme/spring/impl/SpringErrorHandlingIT.java
+++ b/examples/spring-hypermedia/src/test/java/io/wcm/caravan/rhyme/spring/impl/SpringErrorHandlingIT.java
@@ -54,7 +54,8 @@
* there are a few error cases in this test where {@link WebEnvironment#MOCK} doesn't work the same way
* as if the application is serving requests on an actual network socket.
*/
-@SpringBootTest(classes = SpringRhymeHypermediaApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
+@SpringBootTest(classes = SpringRhymeHypermediaApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT,
+properties = {"spring.mvc.throwExceptionIfNoHandlerFound=true", "spring.web.resources.add-mappings=false"})
class SpringErrorHandlingIT {
private final String baseUri;
@@ -149,12 +150,10 @@ void should_extract_status_code_from_NoHandlerFoundException() {
String nonExistingUrl = baseUri + "/foo/bar";
- ErrorThrowingResource errorResource = client.getRemoteResource(nonExistingUrl, ErrorThrowingResource.class);
-
- HalApiClientException ex = assertThrows(HalApiClientException.class,
- () -> errorResource.getStateWithError());
+ HalResponse errorResponse = getResponseFromCaughtClientException(
+ (er) -> client.getRemoteResource(nonExistingUrl, ErrorThrowingResource.class));
- assertThat(ex.getErrorResponse()).isNotNull();
- assertThat(ex.getErrorResponse().getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value());
+ assertThat(errorResponse.getStatus())
+ .isEqualTo(HttpStatus.NOT_FOUND.value());
}
}