DATAREST-1509 - Test against all ISO-8601 TZ formats.
Verify that Jackson properly serializes to ISO-8601 format, which includes three potential timezone endings. Expand CI testing against both Jackson 2.10 and 2.11. Also test these profiles against JDK 8, 11, and 14. Related: spring-projects/spring-data-build#1075 Original pull request: #374.
This commit is contained in:
committed by
Mark Paluch
parent
7c10768501
commit
eaa70cdc77
57
Jenkinsfile
vendored
57
Jenkinsfile
vendored
@@ -85,6 +85,63 @@ pipeline {
|
||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pjava11 clean dependency:list test -Dsort -U -B -Pit'
|
||||
}
|
||||
}
|
||||
stage("test: spring52/jackson-next (jdk8)") {
|
||||
agent {
|
||||
docker {
|
||||
image 'springci/spring-data-openjdk8-with-mongodb-4.2.0:latest'
|
||||
label 'data'
|
||||
args '-v $HOME:/tmp/jenkins-home'
|
||||
}
|
||||
}
|
||||
options { timeout(time: 30, unit: 'MINUTES') }
|
||||
steps {
|
||||
sh 'rm -rf ?'
|
||||
sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log'
|
||||
sh 'mongod --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &'
|
||||
sh 'sleep 10'
|
||||
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
||||
sh 'sleep 15'
|
||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pjava11 clean dependency:list test -Dsort -U -B -Pit,spring52-next,jackson-next'
|
||||
}
|
||||
}
|
||||
stage("test: spring52/jackson-next (jdk11)") {
|
||||
agent {
|
||||
docker {
|
||||
image 'springci/spring-data-openjdk11-with-mongodb-4.2.0:latest'
|
||||
label 'data'
|
||||
args '-v $HOME:/tmp/jenkins-home'
|
||||
}
|
||||
}
|
||||
options { timeout(time: 30, unit: 'MINUTES') }
|
||||
steps {
|
||||
sh 'rm -rf ?'
|
||||
sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log'
|
||||
sh 'mongod --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &'
|
||||
sh 'sleep 10'
|
||||
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
||||
sh 'sleep 15'
|
||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pjava11 clean dependency:list test -Dsort -U -B -Pit,spring52-next,jackson-next'
|
||||
}
|
||||
}
|
||||
stage("test: spring52/jackson-next (jdk14)") {
|
||||
agent {
|
||||
docker {
|
||||
image 'springci/spring-data-openjdk14-with-mongodb-4.2.0:latest'
|
||||
label 'data'
|
||||
args '-v $HOME:/tmp/jenkins-home'
|
||||
}
|
||||
}
|
||||
options { timeout(time: 30, unit: 'MINUTES') }
|
||||
steps {
|
||||
sh 'rm -rf ?'
|
||||
sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log'
|
||||
sh 'mongod --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &'
|
||||
sh 'sleep 10'
|
||||
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
||||
sh 'sleep 15'
|
||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pjava11 clean dependency:list test -Dsort -U -B -Pit,spring52-next,jenkins-next'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,16 +16,21 @@
|
||||
package org.springframework.data.rest.webmvc.config;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.*;
|
||||
import static org.springframework.data.rest.webmvc.util.AssertionUtils.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import javax.naming.Name;
|
||||
import javax.naming.ldap.LdapName;
|
||||
|
||||
import org.assertj.core.api.Condition;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
@@ -45,6 +50,7 @@ import org.springframework.data.rest.webmvc.RepositoryLinksResource;
|
||||
import org.springframework.data.rest.webmvc.RestMediaTypes;
|
||||
import org.springframework.data.rest.webmvc.alps.AlpsJsonHttpMessageConverter;
|
||||
import org.springframework.data.rest.webmvc.json.PersistentEntityJackson2Module;
|
||||
import org.springframework.data.rest.webmvc.util.AssertionUtils;
|
||||
import org.springframework.data.web.HateoasPageableHandlerMethodArgumentResolver;
|
||||
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
|
||||
import org.springframework.format.datetime.DateFormatter;
|
||||
@@ -66,6 +72,7 @@ import com.jayway.jsonpath.JsonPath;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
* @author Greg Turnquist
|
||||
*/
|
||||
public class RepositoryRestMvConfigurationIntegrationTests {
|
||||
|
||||
@@ -117,7 +124,7 @@ public class RepositoryRestMvConfigurationIntegrationTests {
|
||||
assertThat(params.get("mySize").get(0)).isEqualTo("7000");
|
||||
}
|
||||
|
||||
@Test // DATAREST-336
|
||||
@Test // DATAREST-336 DATAREST-1509
|
||||
public void objectMapperRendersDatesInIsoByDefault() throws Exception {
|
||||
|
||||
Sample sample = new Sample();
|
||||
@@ -125,13 +132,12 @@ public class RepositoryRestMvConfigurationIntegrationTests {
|
||||
|
||||
ObjectMapper mapper = getObjectMapper();
|
||||
|
||||
DateFormatter formatter = new DateFormatter();
|
||||
formatter.setPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
|
||||
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
String result = JsonPath.read(mapper.writeValueAsString(sample), "$.date");
|
||||
|
||||
Object result = JsonPath.read(mapper.writeValueAsString(sample), "$.date");
|
||||
assertThat(result).isInstanceOf(String.class);
|
||||
assertThat(result).isEqualTo(formatter.print(sample.date, Locale.US));
|
||||
assertThat(result).is(anyOf( //
|
||||
new Condition<>(endsWith("+00"), "ISO-8601-TZ1"), //
|
||||
new Condition<>(endsWith("+0000"), "ISO-8601-TZ2"), //
|
||||
new Condition<>(endsWith("+00:00"), "ISO-8601-TZ3")));
|
||||
}
|
||||
|
||||
@Test(expected = NoSuchBeanDefinitionException.class) // DATAREST-362
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.springframework.data.rest.webmvc.util;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Various extensions of AssertJ to improve testing.
|
||||
*
|
||||
* @author Greg Turnquist
|
||||
*/
|
||||
public final class AssertionUtils {
|
||||
|
||||
|
||||
/**
|
||||
* {@link Predicate} to verify a given string ends in a certain pattern.
|
||||
*
|
||||
* @param pattern
|
||||
* @return
|
||||
*/
|
||||
public static Predicate<String> endsWith(String pattern) {
|
||||
return s -> s.endsWith(pattern);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user