From 4995b7a1bd6821d5969cc97d5d3209c5e61c31da Mon Sep 17 00:00:00 2001 From: Viktor Kolomeyko <31008341+vkolomeyko@users.noreply.github.com> Date: Thu, 24 Aug 2017 12:56:12 +0100 Subject: [PATCH] Introduced a property to be able to enable AMQP mode from command line for Gradle run (#1316) This can be useful if we decide to create a custom TeamCity configuration that will enable us to independently run *all* tests in AMQP mode to know where we stand. --- build.gradle | 7 +++++++ .../kotlin/net/corda/testing/SerializationTestHelpers.kt | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) 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