diff --git a/temporal-kotlin/build.gradle b/temporal-kotlin/build.gradle index d542da8d1..71ca39ad6 100644 --- a/temporal-kotlin/build.gradle +++ b/temporal-kotlin/build.gradle @@ -1,4 +1,5 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import org.gradle.api.plugins.jvm.JvmTestSuite plugins { id 'org.jlleitschuh.gradle.ktlint' version '11.3.1' @@ -43,3 +44,27 @@ task registerNamespace(type: JavaExec) { test.dependsOn 'registerNamespace' +def jacksonVersions = ['2.9.0', "$jacksonVersion".toString()] + +testing { + suites { + jacksonVersions.forEach { jacksonVersion -> + "jackson${jacksonVersion}Test"(JvmTestSuite) { + useJUnit(junitVersion) + dependencies { + implementation project() + implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonVersion!!" + implementation "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:$jacksonVersion!!" + implementation("com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonVersion!!") { + exclude group: 'org.jetbrains.kotlin', module: 'kotlin-reflect' + } + + implementation project(':temporal-testing') + implementation "junit:junit:${junitVersion}" + } + } + } + } +} + +test.dependsOn("jackson2.9.0Test", "jackson2.14.2Test") diff --git a/temporal-kotlin/src/jackson2.14.2Test/kotlin/io/temporal/common/converter/KotlinObjectMapperFactoryTest.kt b/temporal-kotlin/src/jackson2.14.2Test/kotlin/io/temporal/common/converter/KotlinObjectMapperFactoryTest.kt new file mode 100644 index 000000000..16da2f488 --- /dev/null +++ b/temporal-kotlin/src/jackson2.14.2Test/kotlin/io/temporal/common/converter/KotlinObjectMapperFactoryTest.kt @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved. + * + * Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Modifications copyright (C) 2017 Uber Technologies, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this material except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.temporal.common.converter + +import com.fasterxml.jackson.module.kotlin.PackageVersion +import org.junit.Assert.assertEquals +import org.junit.Test + +class KotlinObjectMapperFactoryTest { + @Test + fun `test jackson 2 14 2`() { + assertEquals(PackageVersion.VERSION.toString(), "2.14.2") + KotlinObjectMapperFactory.new() + } +} diff --git a/temporal-kotlin/src/jackson2.9.0Test/kotlin/io/temporal/common/converter/KotlinObjectMapperFactoryTest.kt b/temporal-kotlin/src/jackson2.9.0Test/kotlin/io/temporal/common/converter/KotlinObjectMapperFactoryTest.kt new file mode 100644 index 000000000..f70d765dd --- /dev/null +++ b/temporal-kotlin/src/jackson2.9.0Test/kotlin/io/temporal/common/converter/KotlinObjectMapperFactoryTest.kt @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved. + * + * Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Modifications copyright (C) 2017 Uber Technologies, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this material except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.temporal.common.converter + +import com.fasterxml.jackson.module.kotlin.PackageVersion +import org.junit.Assert.assertEquals +import org.junit.Test + +class KotlinObjectMapperFactoryTest { + @Test + fun `test jackson 2 9 0`() { + assertEquals(PackageVersion.VERSION.toString(), "2.9.0") + KotlinObjectMapperFactory.new() + } +} diff --git a/temporal-kotlin/src/main/kotlin/io/temporal/common/converter/KotlinObjectMapperFactory.kt b/temporal-kotlin/src/main/kotlin/io/temporal/common/converter/KotlinObjectMapperFactory.kt index 82a220b1a..42503f58a 100644 --- a/temporal-kotlin/src/main/kotlin/io/temporal/common/converter/KotlinObjectMapperFactory.kt +++ b/temporal-kotlin/src/main/kotlin/io/temporal/common/converter/KotlinObjectMapperFactory.kt @@ -21,7 +21,7 @@ package io.temporal.common.converter import com.fasterxml.jackson.databind.ObjectMapper -import com.fasterxml.jackson.module.kotlin.KotlinModule +import com.fasterxml.jackson.module.kotlin.registerKotlinModule class KotlinObjectMapperFactory { companion object { @@ -29,11 +29,7 @@ class KotlinObjectMapperFactory { fun new(): ObjectMapper { val mapper = JacksonJsonPayloadConverter.newDefaultObjectMapper() - // use deprecated constructor instead of builder to maintain compatibility with old jackson versions - @Suppress("deprecation") - val km = KotlinModule() - mapper.registerModule(km) - return mapper + return mapper.registerKotlinModule() } } }