Merge branch '5.3.x'

This commit is contained in:
rstoyanchev
2022-07-13 19:21:33 +01:00
8 changed files with 82 additions and 37 deletions

View File

@@ -240,6 +240,16 @@ class Jackson2ObjectMapperBuilderTests {
assertThat(serializers.findSerializer(null, SimpleType.construct(Integer.class), null)).isSameAs(serializer1);
}
@Test
void modulesWithConsumer() {
NumberSerializer serializer1 = new NumberSerializer(Integer.class);
SimpleModule module = new SimpleModule();
module.addSerializer(Integer.class, serializer1);
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().modules(list -> list.add(module) ).build();
Serializers serializers = getSerializerFactoryConfig(objectMapper).serializers().iterator().next();
assertThat(serializers.findSerializer(null, SimpleType.construct(Integer.class), null)).isSameAs(serializer1);
}
@Test
void modulesToInstallByClass() {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
@@ -258,6 +268,15 @@ class Jackson2ObjectMapperBuilderTests {
assertThat(serializers.findSerializer(null, SimpleType.construct(Integer.class), null).getClass()).isSameAs(CustomIntegerSerializer.class);
}
@Test
void modulesToInstallWithConsumer() {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
.modulesToInstall(list -> list.add(new CustomIntegerModule()))
.build();
Serializers serializers = getSerializerFactoryConfig(objectMapper).serializers().iterator().next();
assertThat(serializers.findSerializer(null, SimpleType.construct(Integer.class), null).getClass()).isSameAs(CustomIntegerSerializer.class);
}
@Test
void wellKnownModules() throws JsonProcessingException, UnsupportedEncodingException {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().build();

View File

@@ -301,6 +301,7 @@ public class PathPatternTests {
checkCapture("{var:f o}","f%20o","var","f o"); // constraint is expressed in non encoded form
checkCapture("{var:f.o}","f%20o","var","f o");
checkCapture("{var:f\\|o}","f%7co","var","f|o");
checkCapture("{var:.*}","x\ny","var","x\ny");
}
@Test
@@ -320,6 +321,8 @@ public class PathPatternTests {
checkCapture("/{var1}_ _{var2}","/f%20o_%20_f%7co","var1","f o","var2","f|o");
checkCapture("/{var1}_ _{var2:f\\|o}","/f%20o_%20_f%7co","var1","f o","var2","f|o");
checkCapture("/{var1:f o}_ _{var2:f\\|o}","/f%20o_%20_f%7co","var1","f o","var2","f|o");
checkCapture("/{var1:f o}_ _{var2:f\\|o}","/f%20o_%20_f%7co","var1","f o","var2","f|o");
checkCapture("/{var1}_{var2}","/f\noo_foo","var1","f\noo","var2","foo");
}
@Test