Skip to content

Commit

Permalink
Upgrade to Spring Framework 6 and Jakarta EE 9
Browse files Browse the repository at this point in the history
Closes gh-750
Closes gh-748
  • Loading branch information
wilkinsona committed Nov 17, 2021
1 parent 68ff043 commit 4223f70
Show file tree
Hide file tree
Showing 37 changed files with 147 additions and 217 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ nohttp {
}

ext {
springVersion = "5.0.15.RELEASE"
springFrameworkVersion = "6.0.0-SNAPSHOT"
javadocLinks = [
"https://docs.oracle.com/javase/8/docs/api/",
"https://docs.spring.io/spring-framework/docs/$springVersion/javadoc-api/",
"https://docs.spring.io/spring-framework/docs/$springFrameworkVersion/javadoc-api/",
"https://docs.jboss.org/hibernate/stable/beanvalidation/api/",
"https://docs.jboss.org/hibernate/stable/validator/api/"
] as String[]
Expand Down
4 changes: 2 additions & 2 deletions docs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ dependencies {
asciidoctorExt("io.spring.asciidoctor:spring-asciidoctor-extensions-block-switch:0.5.0")

internal(platform(project(":spring-restdocs-platform")))
internal(enforcedPlatform("org.springframework:spring-framework-bom:5.3.8"))
internal(enforcedPlatform("org.springframework:spring-framework-bom:$springFrameworkVersion"))

testImplementation(project(":spring-restdocs-mockmvc"))
testImplementation(project(":spring-restdocs-restassured"))
testImplementation(project(":spring-restdocs-webtestclient"))
testImplementation("io.rest-assured:rest-assured")
testImplementation("javax.validation:validation-api")
testImplementation("jakarta.validation:jakarta.validation-api")
testImplementation("junit:junit")
testImplementation("org.testng:testng:6.9.10")
testImplementation("org.junit.jupiter:junit-jupiter-api")
Expand Down
4 changes: 2 additions & 2 deletions docs/src/docs/asciidoc/documenting-your-api.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ example of such a resource bundle].

Each key in the resource bundle is the fully-qualified name of a constraint plus a
`.description`. For example, the key for the standard `@NotNull` constraint is
`javax.validation.constraints.NotNull.description`.
`jakarta.validation.constraints.NotNull.description`.

You can use a property placeholder referring to a constraint's attributes in its
description. For example, the default description of the `@Min` constraint,
Expand Down Expand Up @@ -1318,7 +1318,7 @@ You can configure which snippets are produced by default. See the
=== Using Parameterized Output Directories

When using MockMvc, REST Assured, or `WebTestClient` you can parameterize the output directory used by
`document`. Parameterizing output with `WebTestClient` requires Spring Framework 5.3.5 or later.
`document`.

The following parameters are supported:

Expand Down
2 changes: 1 addition & 1 deletion docs/src/docs/asciidoc/getting-started.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ If you want to jump straight in, a number of sample applications are available:
Spring REST Docs has the following minimum requirements:

* Java 17
* Spring Framework 5 (5.0.2 or later)
* Spring Framework 6

Additionally, the `spring-restdocs-restassured` module requires REST Assured 4 (4.4 or later).

Expand Down
4 changes: 2 additions & 2 deletions docs/src/test/java/com/example/Constraints.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import java.util.List;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

import org.springframework.restdocs.constraints.ConstraintDescriptions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import java.util.HashMap;
import java.util.Map;

import javax.servlet.RequestDispatcher;
import jakarta.servlet.RequestDispatcher;

import org.junit.Before;
import org.junit.Rule;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import java.util.HashMap;
import java.util.Map;

import javax.servlet.RequestDispatcher;
import jakarta.servlet.RequestDispatcher;

import org.junit.Before;
import org.junit.Rule;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public Map<String, Object> getErrorAttributes(WebRequest webRequest,
ErrorAttributeOptions options) {
Map<String, Object> errorAttributes = super.getErrorAttributes(webRequest, options);
errorAttributes.remove("exception");
Object message = webRequest.getAttribute("javax.servlet.error.message", RequestAttributes.SCOPE_REQUEST);
Object message = webRequest.getAttribute("jakarta.servlet.error.message", RequestAttributes.SCOPE_REQUEST);
if (message != null) {
errorAttributes.put("message", message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.util.Collections;
import java.util.List;

import javax.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotBlank;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import javax.validation.Constraint;
import javax.validation.Payload;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Null;
import jakarta.validation.Constraint;
import jakarta.validation.Payload;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Null;

import org.hibernate.validator.constraints.CompositionType;
import org.hibernate.validator.constraints.ConstraintComposition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.example.notes;

import javax.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotBlank;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import java.util.HashMap;
import java.util.Map;

import javax.servlet.RequestDispatcher;
import jakarta.servlet.RequestDispatcher;

import org.junit.Before;
import org.junit.Rule;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

import java.util.Set;

import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import jakarta.validation.ConstraintViolation;
import jakarta.validation.Validation;
import jakarta.validation.Validator;

import org.junit.Test;

Expand Down
13 changes: 3 additions & 10 deletions spring-restdocs-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ dependencies {

optional(platform(project(":spring-restdocs-platform")))
optional("commons-codec:commons-codec")
optional("javax.validation:validation-api")
optional("jakarta.validation:jakarta.validation-api")
optional("junit:junit")
optional("org.hibernate.validator:hibernate-validator")
optional("org.junit.jupiter:junit-jupiter-api")

testFixturesApi(platform(project(":spring-restdocs-platform")))
testFixturesApi("junit:junit")
testFixturesApi("org.assertj:assertj-core")
Expand All @@ -68,7 +68,7 @@ dependencies {
testImplementation("org.hamcrest:hamcrest-library")
testImplementation("org.springframework:spring-test")

testRuntimeOnly("org.glassfish:javax.el:3.0.0")
testRuntimeOnly("org.glassfish:jakarta.el:4.0.2")
}

jar {
Expand All @@ -85,10 +85,3 @@ components.java.withVariantsFromConfiguration(configurations.testFixturesApiElem
components.java.withVariantsFromConfiguration(configurations.testFixturesRuntimeElements) {
skip()
}

compatibilityTest {
dependency("Spring Framework") { springFramework ->
springFramework.groupId = "org.springframework"
springFramework.versions = ["5.1.+", "5.2.+", "5.3.+"]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,28 @@
import java.util.MissingResourceException;
import java.util.ResourceBundle;

import javax.validation.constraints.AssertFalse;
import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.DecimalMax;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Digits;
import javax.validation.constraints.Email;
import javax.validation.constraints.Future;
import javax.validation.constraints.FutureOrPresent;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.Negative;
import javax.validation.constraints.NegativeOrZero;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import javax.validation.constraints.Past;
import javax.validation.constraints.PastOrPresent;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Positive;
import javax.validation.constraints.PositiveOrZero;
import javax.validation.constraints.Size;

import jakarta.validation.constraints.AssertFalse;
import jakarta.validation.constraints.AssertTrue;
import jakarta.validation.constraints.DecimalMax;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.Digits;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.Future;
import jakarta.validation.constraints.FutureOrPresent;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.Negative;
import jakarta.validation.constraints.NegativeOrZero;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Null;
import jakarta.validation.constraints.Past;
import jakarta.validation.constraints.PastOrPresent;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Positive;
import jakarta.validation.constraints.PositiveOrZero;
import jakarta.validation.constraints.Size;
import org.hibernate.validator.constraints.CodePointLength;
import org.hibernate.validator.constraints.CreditCardNumber;
import org.hibernate.validator.constraints.Currency;
Expand All @@ -52,7 +51,6 @@
import org.hibernate.validator.constraints.Mod10Check;
import org.hibernate.validator.constraints.Mod11Check;
import org.hibernate.validator.constraints.Range;
import org.hibernate.validator.constraints.SafeHtml;
import org.hibernate.validator.constraints.URL;

import org.springframework.util.PropertyPlaceholderHelper;
Expand All @@ -63,8 +61,8 @@
* A {@link ConstraintDescriptionResolver} that resolves constraint descriptions from a
* {@link ResourceBundle}. The resource bundle's keys are the name of the constraint with
* {@code .description} appended. For example, the key for the constraint named
* {@code javax.validation.constraints.NotNull} is
* {@code javax.validation.constraints.NotNull.description}.
* {@code jakarta.validation.constraints.NotNull} is
* {@code jakarta.validation.constraints.NotNull.description}.
* <p>
* Default descriptions are provided for Bean Validation 2.0's constraints:
*
Expand Down Expand Up @@ -109,7 +107,6 @@
* <li>{@link org.hibernate.validator.constraints.NotBlank}
* <li>{@link org.hibernate.validator.constraints.NotEmpty}
* <li>{@link Range}
* <li>{@link SafeHtml}
* <li>{@link URL}
* </ul>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@
import java.util.ArrayList;
import java.util.List;

import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import javax.validation.constraints.NotNull;
import javax.validation.metadata.BeanDescriptor;
import javax.validation.metadata.ConstraintDescriptor;
import javax.validation.metadata.PropertyDescriptor;
import jakarta.validation.Validation;
import jakarta.validation.Validator;
import jakarta.validation.ValidatorFactory;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.metadata.BeanDescriptor;
import jakarta.validation.metadata.ConstraintDescriptor;
import jakarta.validation.metadata.PropertyDescriptor;

/**
* A {@link ConstraintResolver} that uses a Bean Validation {@link Validator} to resolve
* constraints. The name of the constraint is the fully-qualified class name of the
* constraint annotation. For example, a {@link NotNull} constraint will be named
* {@code javax.validation.constraints.NotNull}.
* {@code jakarta.validation.constraints.NotNull}.
*
* @author Andy Wilkinson
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
javax.validation.constraints.AssertFalse.description=Must be false
javax.validation.constraints.AssertTrue.description=Must be true
javax.validation.constraints.DecimalMax.description=Must be at most ${value}
javax.validation.constraints.DecimalMin.description=Must be at least ${value}
javax.validation.constraints.Digits.description=Must have at most ${integer} integral digits and ${fraction} fractional digits
javax.validation.constraints.Email.description=Must be a well-formed email address
javax.validation.constraints.Future.description=Must be in the future
javax.validation.constraints.FutureOrPresent.description=Must be in the future or the present
javax.validation.constraints.Max.description=Must be at most ${value}
javax.validation.constraints.Min.description=Must be at least ${value}
javax.validation.constraints.Negative.description=Must be negative
javax.validation.constraints.NegativeOrZero.description=Must be negative or zero
javax.validation.constraints.NotBlank.description=Must not be blank
javax.validation.constraints.NotEmpty.description=Must not be empty
javax.validation.constraints.NotNull.description=Must not be null
javax.validation.constraints.Null.description=Must be null
javax.validation.constraints.Past.description=Must be in the past
javax.validation.constraints.PastOrPresent.description=Must be in the past or the present
javax.validation.constraints.Pattern.description=Must match the regular expression `${regexp}`
javax.validation.constraints.Positive.description=Must be positive
javax.validation.constraints.PositiveOrZero.description=Must be positive or zero
javax.validation.constraints.Size.description=Size must be between ${min} and ${max} inclusive
jakarta.validation.constraints.AssertFalse.description=Must be false
jakarta.validation.constraints.AssertTrue.description=Must be true
jakarta.validation.constraints.DecimalMax.description=Must be at most ${value}
jakarta.validation.constraints.DecimalMin.description=Must be at least ${value}
jakarta.validation.constraints.Digits.description=Must have at most ${integer} integral digits and ${fraction} fractional digits
jakarta.validation.constraints.Email.description=Must be a well-formed email address
jakarta.validation.constraints.Future.description=Must be in the future
jakarta.validation.constraints.FutureOrPresent.description=Must be in the future or the present
jakarta.validation.constraints.Max.description=Must be at most ${value}
jakarta.validation.constraints.Min.description=Must be at least ${value}
jakarta.validation.constraints.Negative.description=Must be negative
jakarta.validation.constraints.NegativeOrZero.description=Must be negative or zero
jakarta.validation.constraints.NotBlank.description=Must not be blank
jakarta.validation.constraints.NotEmpty.description=Must not be empty
jakarta.validation.constraints.NotNull.description=Must not be null
jakarta.validation.constraints.Null.description=Must be null
jakarta.validation.constraints.Past.description=Must be in the past
jakarta.validation.constraints.PastOrPresent.description=Must be in the past or the present
jakarta.validation.constraints.Pattern.description=Must match the regular expression `${regexp}`
jakarta.validation.constraints.Positive.description=Must be positive
jakarta.validation.constraints.PositiveOrZero.description=Must be positive or zero
jakarta.validation.constraints.Size.description=Size must be between ${min} and ${max} inclusive
org.hibernate.validator.constraints.CodePointLength.description=Code point length must be between ${min} and ${max} inclusive
org.hibernate.validator.constraints.CreditCardNumber.description=Must be a well-formed credit card number
org.hibernate.validator.constraints.Currency.description=Must be in an accepted currency unit (${value})
Expand All @@ -32,5 +32,4 @@ org.hibernate.validator.constraints.Mod11Check.description=Must pass the Mod11 c
org.hibernate.validator.constraints.NotBlank.description=Must not be blank
org.hibernate.validator.constraints.NotEmpty.description=Must not be empty
org.hibernate.validator.constraints.Range.description=Must be at least ${min} and at most ${max}
org.hibernate.validator.constraints.SafeHtml.description=Must be safe HTML
org.hibernate.validator.constraints.URL.description=Must be a well-formed URL
Loading

0 comments on commit 4223f70

Please sign in to comment.