File tree Expand file tree Collapse file tree 6 files changed +23
-5
lines changed
src/test/kotlin/com/fasterxml/jackson/module/kotlin Expand file tree Collapse file tree 6 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ WrongWrong (@k163377)
26
26
* #629 : Changed to not cache valueParameters
27
27
* #631 : Fix minor bugs in SimpleModule.addSerializer/addDeserializer
28
28
* #634 : Fix ReflectionCache to be serializable
29
+ * #640 : Fixed problem with test failure in windows.
29
30
30
31
# 2 .14.0
31
32
Original file line number Diff line number Diff line change
1
+ package com.fasterxml.jackson.module.kotlin
2
+
3
+ import com.fasterxml.jackson.core.util.DefaultIndenter
4
+ import com.fasterxml.jackson.core.util.DefaultPrettyPrinter
5
+ import com.fasterxml.jackson.databind.ObjectMapper
6
+ import com.fasterxml.jackson.databind.ObjectWriter
7
+
8
+ // This `printer` is used to match the output from Jackson to the newline char of the source code.
9
+ // If this is removed, comparisons will fail in a Windows-like platform.
10
+ val LF_PRINTER : DefaultPrettyPrinter =
11
+ DefaultPrettyPrinter ().withObjectIndenter(DefaultIndenter ().withLinefeed(" \n " ))
12
+
13
+ fun ObjectMapper.testPrettyWriter (): ObjectWriter = this .writer(LF_PRINTER )
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.module.SimpleModule
7
7
import com.fasterxml.jackson.databind.ser.std.StdSerializer
8
8
import com.fasterxml.jackson.module.kotlin.jacksonMapperBuilder
9
9
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
10
+ import com.fasterxml.jackson.module.kotlin.testPrettyWriter
10
11
import org.junit.Test
11
12
import kotlin.test.assertEquals
12
13
import kotlin.test.assertNotEquals
@@ -39,7 +40,7 @@ class GitHub524 {
39
40
fun test () {
40
41
val sm = SimpleModule ()
41
42
.addSerializer(Serializer ())
42
- val writer = jacksonMapperBuilder().addModule(sm).build().writerWithDefaultPrettyPrinter ()
43
+ val writer = jacksonMapperBuilder().addModule(sm).build().testPrettyWriter ()
43
44
44
45
// 18446744073709551615 is ULong.MAX_VALUE.
45
46
assertEquals(
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package com.fasterxml.jackson.module.kotlin.test.github
2
2
3
3
import com.fasterxml.jackson.annotation.JsonValue
4
4
import com.fasterxml.jackson.module.kotlin.jacksonMapperBuilder
5
+ import com.fasterxml.jackson.module.kotlin.testPrettyWriter
5
6
import kotlin.test.assertEquals
6
7
import org.junit.Test
7
8
@@ -37,7 +38,7 @@ class GitHub530 {
37
38
@JvmInline
38
39
value class JsonValueGetterImplementation (val value : Int ) : JsonValueGetter
39
40
40
- private val writer = jacksonMapperBuilder().build().writerWithDefaultPrettyPrinter ()
41
+ private val writer = jacksonMapperBuilder().build().testPrettyWriter ()
41
42
42
43
@Test
43
44
fun valueParamGetterAnnotated () {
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import com.fasterxml.jackson.databind.ser.std.StdSerializer
11
11
import com.fasterxml.jackson.module.kotlin.KotlinModule
12
12
import com.fasterxml.jackson.module.kotlin.jacksonMapperBuilder
13
13
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
14
+ import com.fasterxml.jackson.module.kotlin.testPrettyWriter
14
15
import org.junit.Ignore
15
16
import org.junit.Test
16
17
import kotlin.test.assertEquals
@@ -75,7 +76,7 @@ class Github464 {
75
76
@Suppress(" UNCHECKED_CAST" )
76
77
val writer: ObjectWriter = jacksonObjectMapper()
77
78
.apply { serializerProvider.setNullKeySerializer(NullValueClassKeySerializer as JsonSerializer <Any ?>) }
78
- .writerWithDefaultPrettyPrinter ()
79
+ .testPrettyWriter ()
79
80
80
81
assertEquals(
81
82
"""
@@ -117,7 +118,7 @@ class Github464 {
117
118
.apply {
118
119
serializerProvider.setNullKeySerializer(NullValueClassKeySerializer as JsonSerializer <Any ?>)
119
120
serializerProvider.setNullValueSerializer(NullValueSerializer )
120
- }.writerWithDefaultPrettyPrinter ()
121
+ }.testPrettyWriter ()
121
122
122
123
assertEquals(
123
124
"""
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonInclude
4
4
import com.fasterxml.jackson.annotation.JsonProperty
5
5
import com.fasterxml.jackson.databind.MapperFeature.SORT_PROPERTIES_ALPHABETICALLY
6
6
import com.fasterxml.jackson.module.kotlin.jacksonMapperBuilder
7
+ import com.fasterxml.jackson.module.kotlin.testPrettyWriter
7
8
import org.junit.Ignore
8
9
import org.junit.Test
9
10
import kotlin.test.assertEquals
@@ -16,7 +17,7 @@ class TestGitHub337 {
16
17
.configure(SORT_PROPERTIES_ALPHABETICALLY , true )
17
18
.build()
18
19
.setSerializationInclusion(JsonInclude .Include .ALWAYS )
19
- private val writer = mapper.writerWithDefaultPrettyPrinter ()
20
+ private val writer = mapper.testPrettyWriter ()
20
21
21
22
@Test
22
23
@Ignore
You can’t perform that action at this time.
0 commit comments