Skip to content

Commit

Permalink
Add JDK serializability test for KotlinModule
Browse files Browse the repository at this point in the history
  • Loading branch information
k163377 committed Feb 25, 2023
1 parent c135316 commit c6ee34c
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
import kotlin.test.assertNotNull

class KotlinModuleTest {
/**
Expand Down Expand Up @@ -103,4 +104,27 @@ class KotlinModuleTest {

assertTrue(module.strictNullChecks)
}

@Test
fun jdkSerializabilityTest() {
val module = KotlinModule.Builder().apply {
withReflectionCacheSize(123)
enable(NullToEmptyCollection)
enable(NullToEmptyMap)
enable(NullIsSameAsDefault)
enable(SingletonSupport)
enable(StrictNullChecks)
}.build()

val serialized = jdkSerialize(module)
val deserialized = jdkDeserialize<KotlinModule>(serialized)

assertNotNull(deserialized)
assertEquals(123, deserialized.reflectionCacheSize)
assertTrue(deserialized.nullToEmptyCollection)
assertTrue(deserialized.nullToEmptyMap)
assertTrue(deserialized.nullIsSameAsDefault)
assertEquals(CANONICALIZE, deserialized.singletonSupport)
assertTrue(deserialized.strictNullChecks)
}
}

0 comments on commit c6ee34c

Please sign in to comment.