From 98651702338c9bdf208efc9d3f8a14d3d6a6695a Mon Sep 17 00:00:00 2001 From: Katelyn Baker Date: Fri, 13 Jul 2018 15:47:09 +0100 Subject: [PATCH] CORDA-1808 - Refactor serialization test infrastructure backport --- .../internal/serialization/amqp/SerializationOutput.kt | 2 +- .../nodeapi/internal/serialization/amqp/SerializerFactory.kt | 4 ---- .../internal/serialization/amqp/CorDappSerializerTests.kt | 1 + .../serialization/amqp/DeserializeAndReturnEnvelopeTests.kt | 5 ++++- .../internal/serialization/amqp/DeserializeMapTests.kt | 2 ++ .../amqp/DeserializeNeedingCarpentryOfEnumsTest.kt | 3 +++ .../amqp/DeserializeNeedingCarpentrySimpleTypesTest.kt | 2 ++ .../serialization/amqp/DeserializeNeedingCarpentryTests.kt | 3 +++ .../serialization/amqp/DeserializeSimpleTypesTests.kt | 2 ++ .../internal/serialization/amqp/EnumEvolvabilityTests.kt | 2 ++ .../nodeapi/internal/serialization/amqp/EnumEvolveTests.kt | 2 ++ .../corda/nodeapi/internal/serialization/amqp/EnumTests.kt | 5 ++++- .../internal/serialization/amqp/ErrorMessagesTests.kt | 3 +++ .../nodeapi/internal/serialization/amqp/EvolvabilityTests.kt | 3 +++ .../nodeapi/internal/serialization/amqp/GenericsTests.kt | 4 ++++ .../internal/serialization/amqp/PrivatePropertyTests.kt | 1 + .../nodeapi/internal/serialization/amqp/RoundTripTests.kt | 1 + .../internal/serialization/amqp/SerializationOutputTests.kt | 2 ++ .../serialization/amqp/SerializationPropertyOrdering.kt | 2 ++ .../serialization/amqp/SerializeAndReturnSchemaTest.kt | 2 ++ 20 files changed, 44 insertions(+), 7 deletions(-) diff --git a/node-api/src/main/kotlin/net/corda/nodeapi/internal/serialization/amqp/SerializationOutput.kt b/node-api/src/main/kotlin/net/corda/nodeapi/internal/serialization/amqp/SerializationOutput.kt index 94b17f6efd..232084db48 100644 --- a/node-api/src/main/kotlin/net/corda/nodeapi/internal/serialization/amqp/SerializationOutput.kt +++ b/node-api/src/main/kotlin/net/corda/nodeapi/internal/serialization/amqp/SerializationOutput.kt @@ -31,7 +31,7 @@ open class SerializationOutput(internal val serializerFactory: SerializerFactory * of AMQP serialization constructed the serialized form. */ @Throws(NotSerializableException::class) - fun serialize(obj: T): SerializedBytes { + open fun serialize(obj: T): SerializedBytes { try { return _serialize(obj) } finally { diff --git a/node-api/src/main/kotlin/net/corda/nodeapi/internal/serialization/amqp/SerializerFactory.kt b/node-api/src/main/kotlin/net/corda/nodeapi/internal/serialization/amqp/SerializerFactory.kt index a32e2dd677..12e1f43449 100644 --- a/node-api/src/main/kotlin/net/corda/nodeapi/internal/serialization/amqp/SerializerFactory.kt +++ b/node-api/src/main/kotlin/net/corda/nodeapi/internal/serialization/amqp/SerializerFactory.kt @@ -49,10 +49,6 @@ open class SerializerFactory( private val customSerializers = CopyOnWriteArrayList() private val transformsCache = ConcurrentHashMap>>() - init { - fingerPrinter.setOwner(this) - } - open val classCarpenter = ClassCarpenter(cl, whitelist) val classloader: ClassLoader diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/CorDappSerializerTests.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/CorDappSerializerTests.kt index d809f7beda..59129dcd1a 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/CorDappSerializerTests.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/CorDappSerializerTests.kt @@ -6,6 +6,7 @@ import net.corda.core.serialization.SerializationCustomSerializer import org.assertj.core.api.Assertions import java.io.NotSerializableException import kotlin.test.assertEquals +import net.corda.nodeapi.internal.serialization.amqp.testutils.testDefaultFactory class CorDappSerializerTests { data class NeedsProxy (val a: String) diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/DeserializeAndReturnEnvelopeTests.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/DeserializeAndReturnEnvelopeTests.kt index d793c9f0d2..9915f8b4d2 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/DeserializeAndReturnEnvelopeTests.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/DeserializeAndReturnEnvelopeTests.kt @@ -1,6 +1,9 @@ package net.corda.nodeapi.internal.serialization.amqp import net.corda.core.serialization.CordaSerializable +import net.corda.nodeapi.internal.serialization.amqp.testutils.testDefaultFactoryNoEvolution +import net.corda.nodeapi.internal.serialization.amqp.testutils.testDefaultFactoryWithWhitelist +import net.corda.nodeapi.internal.serialization.amqp.testutils.testName import org.junit.Test import kotlin.test.assertEquals import kotlin.test.assertNotEquals @@ -9,7 +12,7 @@ import kotlin.test.assertTrue class DeserializeAndReturnEnvelopeTests { // the 'this' reference means we can't just move this to the common test utils @Suppress("NOTHING_TO_INLINE") - inline private fun classTestName(clazz: String) = "${this.javaClass.name}\$${testName()}\$$clazz" + private inline fun classTestName(clazz: String) = "${this.javaClass.name}\$${testName()}\$$clazz" val factory = testDefaultFactoryNoEvolution() diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/DeserializeMapTests.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/DeserializeMapTests.kt index 2e910bf19c..26688e32dd 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/DeserializeMapTests.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/DeserializeMapTests.kt @@ -1,5 +1,7 @@ package net.corda.nodeapi.internal.serialization.amqp +import net.corda.nodeapi.internal.serialization.amqp.testutils.TestSerializationOutput +import net.corda.nodeapi.internal.serialization.amqp.testutils.testDefaultFactoryNoEvolution import org.assertj.core.api.Assertions import org.junit.Test import java.util.* diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/DeserializeNeedingCarpentryOfEnumsTest.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/DeserializeNeedingCarpentryOfEnumsTest.kt index caa3e06c4f..6e06d69f95 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/DeserializeNeedingCarpentryOfEnumsTest.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/DeserializeNeedingCarpentryOfEnumsTest.kt @@ -1,6 +1,9 @@ package net.corda.nodeapi.internal.serialization.amqp import net.corda.nodeapi.internal.serialization.AllWhitelist +import net.corda.nodeapi.internal.serialization.amqp.testutils.TestSerializationOutput +import net.corda.nodeapi.internal.serialization.amqp.testutils.testDefaultFactoryNoEvolution +import net.corda.nodeapi.internal.serialization.amqp.testutils.testDefaultFactoryWithWhitelist import org.junit.Test import kotlin.test.* import net.corda.nodeapi.internal.serialization.carpenter.* diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/DeserializeNeedingCarpentrySimpleTypesTest.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/DeserializeNeedingCarpentrySimpleTypesTest.kt index 002adc5e24..f40e8aecbe 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/DeserializeNeedingCarpentrySimpleTypesTest.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/DeserializeNeedingCarpentrySimpleTypesTest.kt @@ -1,6 +1,8 @@ package net.corda.nodeapi.internal.serialization.amqp import net.corda.nodeapi.internal.serialization.AllWhitelist +import net.corda.nodeapi.internal.serialization.amqp.testutils.TestSerializationOutput +import net.corda.nodeapi.internal.serialization.amqp.testutils.testDefaultFactoryNoEvolution import org.junit.Test import kotlin.test.* import net.corda.nodeapi.internal.serialization.carpenter.* diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/DeserializeNeedingCarpentryTests.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/DeserializeNeedingCarpentryTests.kt index f54112b2dc..37d4a22380 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/DeserializeNeedingCarpentryTests.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/DeserializeNeedingCarpentryTests.kt @@ -5,6 +5,9 @@ import org.junit.Test import kotlin.test.* import net.corda.nodeapi.internal.serialization.carpenter.* import net.corda.nodeapi.internal.serialization.AllWhitelist +import net.corda.nodeapi.internal.serialization.amqp.testutils.TestSerializationOutput +import net.corda.nodeapi.internal.serialization.amqp.testutils.testDefaultFactoryNoEvolution +import net.corda.nodeapi.internal.serialization.amqp.testutils.testDefaultFactoryWithWhitelist @CordaSerializable interface I { diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/DeserializeSimpleTypesTests.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/DeserializeSimpleTypesTests.kt index 05e8cd2827..4ce0cb6848 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/DeserializeSimpleTypesTests.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/DeserializeSimpleTypesTests.kt @@ -1,5 +1,7 @@ package net.corda.nodeapi.internal.serialization.amqp +import net.corda.nodeapi.internal.serialization.amqp.testutils.TestSerializationOutput +import net.corda.nodeapi.internal.serialization.amqp.testutils.testDefaultFactoryNoEvolution import org.junit.Test import kotlin.test.assertEquals diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/EnumEvolvabilityTests.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/EnumEvolvabilityTests.kt index 0eac230736..bfafb1d0c2 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/EnumEvolvabilityTests.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/EnumEvolvabilityTests.kt @@ -2,6 +2,8 @@ package net.corda.nodeapi.internal.serialization.amqp import net.corda.core.serialization.* import net.corda.nodeapi.internal.serialization.NotSerializableDetailedException +import net.corda.nodeapi.internal.serialization.amqp.testutils.TestSerializationOutput +import net.corda.nodeapi.internal.serialization.amqp.testutils.testDefaultFactory import net.corda.testing.common.internal.ProjectStructure.projectRootDir import org.assertj.core.api.Assertions import org.assertj.core.api.Assertions.assertThat diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/EnumEvolveTests.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/EnumEvolveTests.kt index bdcde9bf64..07b392e257 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/EnumEvolveTests.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/EnumEvolveTests.kt @@ -3,6 +3,8 @@ package net.corda.nodeapi.internal.serialization.amqp import net.corda.core.serialization.CordaSerializationTransformEnumDefault import net.corda.core.serialization.CordaSerializationTransformEnumDefaults import net.corda.core.serialization.SerializedBytes +import net.corda.nodeapi.internal.serialization.amqp.testutils.testDefaultFactory +import net.corda.nodeapi.internal.serialization.amqp.testutils.testName import net.corda.testing.common.internal.ProjectStructure.projectRootDir import org.assertj.core.api.Assertions import org.junit.Test diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/EnumTests.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/EnumTests.kt index cc46273f08..e136ede77b 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/EnumTests.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/EnumTests.kt @@ -3,6 +3,9 @@ package net.corda.nodeapi.internal.serialization.amqp import net.corda.core.serialization.ClassWhitelist import net.corda.core.serialization.CordaSerializable import net.corda.core.serialization.SerializedBytes +import net.corda.nodeapi.internal.serialization.amqp.testutils.TestSerializationOutput +import net.corda.nodeapi.internal.serialization.amqp.testutils.testDefaultFactoryNoEvolution +import net.corda.nodeapi.internal.serialization.amqp.testutils.testName import org.assertj.core.api.Assertions import org.junit.Test import java.io.File @@ -63,7 +66,7 @@ class EnumTests { } @Suppress("NOTHING_TO_INLINE") - inline private fun classTestName(clazz: String) = "${this.javaClass.name}\$${testName()}\$$clazz" + private inline fun classTestName(clazz: String) = "${this.javaClass.name}\$${testName()}\$$clazz" private val sf1 = testDefaultFactoryNoEvolution() diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/ErrorMessagesTests.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/ErrorMessagesTests.kt index 6aab88660a..83d58cf510 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/ErrorMessagesTests.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/ErrorMessagesTests.kt @@ -1,5 +1,8 @@ package net.corda.nodeapi.internal.serialization.amqp +import net.corda.nodeapi.internal.serialization.amqp.testutils.TestSerializationOutput +import net.corda.nodeapi.internal.serialization.amqp.testutils.testDefaultFactory +import net.corda.nodeapi.internal.serialization.amqp.testutils.testName import org.assertj.core.api.Assertions import org.junit.Ignore import org.junit.Test diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/EvolvabilityTests.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/EvolvabilityTests.kt index d4b6573c1a..e0ab20ef6c 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/EvolvabilityTests.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/EvolvabilityTests.kt @@ -19,6 +19,9 @@ import java.net.URI import java.time.Instant import kotlin.test.assertEquals import net.corda.nodeapi.internal.serialization.amqp.custom.InstantSerializer +import net.corda.nodeapi.internal.serialization.amqp.testutils.TestSerializationOutput +import net.corda.nodeapi.internal.serialization.amqp.testutils.testDefaultFactory +import net.corda.nodeapi.internal.serialization.amqp.testutils.testName // To regenerate any of the binary test files do the following // diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/GenericsTests.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/GenericsTests.kt index 6490f48522..b33e687087 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/GenericsTests.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/GenericsTests.kt @@ -9,6 +9,10 @@ import net.corda.core.identity.AbstractParty import net.corda.core.identity.CordaX500Name import net.corda.core.identity.Party import net.corda.core.transactions.WireTransaction +import net.corda.nodeapi.internal.serialization.amqp.testutils.TestSerializationOutput +import net.corda.nodeapi.internal.serialization.amqp.testutils.testDefaultFactory +import net.corda.nodeapi.internal.serialization.amqp.testutils.testDefaultFactoryNoEvolution +import net.corda.nodeapi.internal.serialization.amqp.testutils.testName import net.corda.testing.core.TestIdentity import org.hibernate.Transaction import java.io.File diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/PrivatePropertyTests.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/PrivatePropertyTests.kt index 795ac1a12e..8f0fbbdaaf 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/PrivatePropertyTests.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/PrivatePropertyTests.kt @@ -3,6 +3,7 @@ package net.corda.nodeapi.internal.serialization.amqp import junit.framework.TestCase.assertTrue import junit.framework.TestCase.assertEquals import net.corda.core.serialization.ConstructorForDeserialization +import net.corda.nodeapi.internal.serialization.amqp.testutils.testDefaultFactoryNoEvolution import org.junit.Test import org.apache.qpid.proton.amqp.Symbol import org.assertj.core.api.Assertions diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/RoundTripTests.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/RoundTripTests.kt index f42823a862..f0a6d8c29c 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/RoundTripTests.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/RoundTripTests.kt @@ -1,6 +1,7 @@ package net.corda.nodeapi.internal.serialization.amqp import net.corda.core.serialization.ConstructorForDeserialization +import net.corda.nodeapi.internal.serialization.amqp.testutils.testDefaultFactoryNoEvolution import org.assertj.core.api.Assertions import org.junit.Test diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/SerializationOutputTests.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/SerializationOutputTests.kt index a7440f9d30..9fc8c13e29 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/SerializationOutputTests.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/SerializationOutputTests.kt @@ -21,6 +21,8 @@ import net.corda.nodeapi.internal.serialization.AllWhitelist import net.corda.nodeapi.internal.serialization.EmptyWhitelist import net.corda.nodeapi.internal.serialization.GeneratedAttachment import net.corda.nodeapi.internal.serialization.amqp.SerializerFactory.Companion.isPrimitive +import net.corda.nodeapi.internal.serialization.amqp.testutils.testDefaultFactory +import net.corda.nodeapi.internal.serialization.amqp.testutils.testDefaultFactoryNoEvolution import net.corda.testing.contracts.DummyContract import net.corda.testing.core.BOB_NAME import net.corda.testing.core.SerializationEnvironmentRule diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/SerializationPropertyOrdering.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/SerializationPropertyOrdering.kt index 2fd435aa24..46cc29a437 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/SerializationPropertyOrdering.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/SerializationPropertyOrdering.kt @@ -1,6 +1,8 @@ package net.corda.nodeapi.internal.serialization.amqp import net.corda.core.serialization.ConstructorForDeserialization +import net.corda.nodeapi.internal.serialization.amqp.testutils.TestSerializationOutput +import net.corda.nodeapi.internal.serialization.amqp.testutils.testDefaultFactoryNoEvolution import org.junit.Test import java.util.concurrent.ConcurrentHashMap import kotlin.test.assertEquals diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/SerializeAndReturnSchemaTest.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/SerializeAndReturnSchemaTest.kt index 51248a4d4e..06eb9b6fe8 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/SerializeAndReturnSchemaTest.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/amqp/SerializeAndReturnSchemaTest.kt @@ -1,5 +1,7 @@ package net.corda.nodeapi.internal.serialization.amqp +import net.corda.nodeapi.internal.serialization.amqp.testutils.testDefaultFactoryNoEvolution +import net.corda.nodeapi.internal.serialization.amqp.testutils.testName import org.junit.Test import kotlin.test.assertEquals import kotlin.test.assertNotNull