Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
9eae2993
Commit
9eae2993
authored
Nov 18, 2014
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test that http.mappers props are applied by JacksonAutoConfiguration
Closes gh-1919
parent
f51b304c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
JacksonAutoConfigurationTests.java
.../autoconfigure/jackson/JacksonAutoConfigurationTests.java
+26
-0
No files found.
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jackson/JacksonAutoConfigurationTests.java
View file @
9eae2993
...
...
@@ -25,6 +25,7 @@ import org.junit.Before;
import
org.junit.Test
;
import
org.mockito.Mockito
;
import
org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration
;
import
org.springframework.boot.test.EnvironmentTestUtils
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -35,6 +36,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import
com.fasterxml.jackson.databind.JsonSerializer
;
import
com.fasterxml.jackson.databind.Module
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.SerializationFeature
;
import
com.fasterxml.jackson.databind.SerializerProvider
;
import
com.fasterxml.jackson.databind.module.SimpleModule
;
import
com.fasterxml.jackson.datatype.joda.JodaModule
;
...
...
@@ -45,6 +47,7 @@ import static org.hamcrest.Matchers.instanceOf;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Matchers
.
argThat
;
import
static
org
.
mockito
.
Mockito
.
verify
;
...
...
@@ -101,6 +104,29 @@ public class JacksonAutoConfigurationTests {
assertEquals
(
"{\"foo\":\"bar\"}"
,
mapper
.
writeValueAsString
(
new
Foo
()));
}
@Test
public
void
httpMappersJsonPrettyPrintIsApplied
()
{
this
.
context
.
register
(
JacksonAutoConfiguration
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"http.mappers.json-pretty-print:true"
);
this
.
context
.
refresh
();
ObjectMapper
objectMapper
=
this
.
context
.
getBean
(
ObjectMapper
.
class
);
assertTrue
(
objectMapper
.
getSerializationConfig
().
isEnabled
(
SerializationFeature
.
INDENT_OUTPUT
));
}
@Test
public
void
httpMappersJsonSortKeysIsApplied
()
{
this
.
context
.
register
(
JacksonAutoConfiguration
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"http.mappers.json-sort-keys:true"
);
this
.
context
.
refresh
();
ObjectMapper
objectMapper
=
this
.
context
.
getBean
(
ObjectMapper
.
class
);
assertTrue
(
objectMapper
.
getSerializationConfig
().
isEnabled
(
SerializationFeature
.
ORDER_MAP_ENTRIES_BY_KEYS
));
}
@Configuration
protected
static
class
ModulesConfig
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment