diff --git a/build.gradle b/build.gradle index f32903fc39..fb5d920704 100644 --- a/build.gradle +++ b/build.gradle @@ -127,6 +127,13 @@ allprojects { tasks.withType(Test) { // Prevent the project from creating temporary files outside of the build directory. systemProperties['java.io.tmpdir'] = buildDir + + // Ensures that "net.corda.testing.amqp.enable" is passed correctly from Gradle command line + // down to JVM executing unit test. It looks like we are running unit tests in the forked mode + // and all the "-D" parameters passed to Gradle not making it to unit test level + // TODO: Remove once we fully switched to AMQP + final AMQP_ENABLE_PROP_NAME = "net.corda.testing.amqp.enable" + systemProperty(AMQP_ENABLE_PROP_NAME, System.getProperty(AMQP_ENABLE_PROP_NAME)) } group 'net.corda' diff --git a/test-utils/src/main/kotlin/net/corda/testing/SerializationTestHelpers.kt b/test-utils/src/main/kotlin/net/corda/testing/SerializationTestHelpers.kt index 859d8e24af..9712bc866d 100644 --- a/test-utils/src/main/kotlin/net/corda/testing/SerializationTestHelpers.kt +++ b/test-utils/src/main/kotlin/net/corda/testing/SerializationTestHelpers.kt @@ -66,7 +66,14 @@ fun initialiseTestSerialization() { registerScheme(AMQPClientSerializationScheme()) registerScheme(AMQPServerSerializationScheme()) } - (SerializationDefaults.P2P_CONTEXT as TestSerializationContext).delegate = KRYO_P2P_CONTEXT + + val AMQP_ENABLE_PROP_NAME = "net.corda.testing.amqp.enable" + // TODO: Remove these "if" conditions once we fully switched to AMQP + (SerializationDefaults.P2P_CONTEXT as TestSerializationContext).delegate = if (java.lang.Boolean.getBoolean(AMQP_ENABLE_PROP_NAME)) { + AMQP_P2P_CONTEXT + } else { + KRYO_P2P_CONTEXT + } (SerializationDefaults.RPC_SERVER_CONTEXT as TestSerializationContext).delegate = KRYO_RPC_SERVER_CONTEXT (SerializationDefaults.RPC_CLIENT_CONTEXT as TestSerializationContext).delegate = KRYO_RPC_CLIENT_CONTEXT (SerializationDefaults.STORAGE_CONTEXT as TestSerializationContext).delegate = KRYO_STORAGE_CONTEXT