Skip to content

Commit c6ee34c

Browse files
committed
Add JDK serializability test for KotlinModule
1 parent c135316 commit c6ee34c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/test/kotlin/com/fasterxml/jackson/module/kotlin/KotlinModuleTest.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import org.junit.Assert.assertEquals
1111
import org.junit.Assert.assertFalse
1212
import org.junit.Assert.assertTrue
1313
import org.junit.Test
14+
import kotlin.test.assertNotNull
1415

1516
class KotlinModuleTest {
1617
/**
@@ -103,4 +104,27 @@ class KotlinModuleTest {
103104

104105
assertTrue(module.strictNullChecks)
105106
}
107+
108+
@Test
109+
fun jdkSerializabilityTest() {
110+
val module = KotlinModule.Builder().apply {
111+
withReflectionCacheSize(123)
112+
enable(NullToEmptyCollection)
113+
enable(NullToEmptyMap)
114+
enable(NullIsSameAsDefault)
115+
enable(SingletonSupport)
116+
enable(StrictNullChecks)
117+
}.build()
118+
119+
val serialized = jdkSerialize(module)
120+
val deserialized = jdkDeserialize<KotlinModule>(serialized)
121+
122+
assertNotNull(deserialized)
123+
assertEquals(123, deserialized.reflectionCacheSize)
124+
assertTrue(deserialized.nullToEmptyCollection)
125+
assertTrue(deserialized.nullToEmptyMap)
126+
assertTrue(deserialized.nullIsSameAsDefault)
127+
assertEquals(CANONICALIZE, deserialized.singletonSupport)
128+
assertTrue(deserialized.strictNullChecks)
129+
}
106130
}

0 commit comments

Comments
 (0)