From 7d75d95dc230bdcc65dbf633b89c5d778f2a2dda Mon Sep 17 00:00:00 2001 From: Tudor Malene Date: Tue, 28 Nov 2017 10:42:40 +0000 Subject: [PATCH] [ENT-1153]: fix merge --- .../net/corda/node/services/config/NodeConfiguration.kt | 3 ++- .../src/main/kotlin/net/corda/testing/NodeTestUtils.kt | 3 ++- .../src/main/kotlin/net/corda/testing/node/MockNode.kt | 3 ++- .../main/kotlin/net/corda/testing/node/MockServices.kt | 9 +++++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/node/src/main/kotlin/net/corda/node/services/config/NodeConfiguration.kt b/node/src/main/kotlin/net/corda/node/services/config/NodeConfiguration.kt index 3bdf57e889..3d8e96945b 100644 --- a/node/src/main/kotlin/net/corda/node/services/config/NodeConfiguration.kt +++ b/node/src/main/kotlin/net/corda/node/services/config/NodeConfiguration.kt @@ -47,7 +47,8 @@ data class DatabaseConfig( val initDatabase: Boolean = true, val serverNameTablePrefix: String = "", val transactionIsolationLevel: TransactionIsolationLevel = TransactionIsolationLevel.REPEATABLE_READ, - val schema: String? = null + val schema: String? = null, + val nodeOrganizationName: String? = null ) enum class TransactionIsolationLevel { diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/NodeTestUtils.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/NodeTestUtils.kt index 3a4f0217fd..1e24380d5b 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/NodeTestUtils.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/NodeTestUtils.kt @@ -24,6 +24,7 @@ import net.corda.node.services.config.VerifierType import net.corda.nodeapi.User import net.corda.testing.node.MockServices import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties +import net.corda.testing.node.MockServices.Companion.makeTestDatabaseProperties import java.nio.file.Path /** @@ -64,7 +65,7 @@ fun testNodeConfiguration( doReturn(emptyList()).whenever(it).rpcUsers doReturn(null).whenever(it).notary doReturn(makeTestDataSourceProperties(myLegalName.organisation)).whenever(it).dataSourceProperties - doReturn(DatabaseConfig(serverNameTablePrefix = myLegalName.organisation)).whenever(it).database + doReturn(makeTestDatabaseProperties(myLegalName.organisation)).whenever(it).database doReturn("").whenever(it).emailAddress doReturn("").whenever(it).exportJMXto doReturn(true).whenever(it).devMode diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNode.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNode.kt index b1b2adcbb1..d9b128420d 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNode.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNode.kt @@ -41,6 +41,7 @@ import net.corda.node.utilities.CordaPersistence import net.corda.testing.DUMMY_NOTARY import net.corda.testing.node.MockServices.Companion.MOCK_VERSION_INFO import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties +import net.corda.testing.node.MockServices.Companion.makeTestDatabaseProperties import net.corda.testing.setGlobalSerialization import net.corda.testing.testNodeConfiguration import org.apache.activemq.artemis.utils.ReusableLatch @@ -364,7 +365,7 @@ class MockNetwork(defaultParameters: MockNetworkParameters = MockNetworkParamete baseDirectory = baseDirectory(id).createDirectories(), myLegalName = parameters.legalName ?: CordaX500Name(organisation = "Mock Company $id", locality = "London", country = "GB")).also { doReturn(makeTestDataSourceProperties("node_$id", "net_$networkId")).whenever(it).dataSourceProperties - doReturn(DatabaseConfig()).whenever(it).database + doReturn(makeTestDatabaseProperties("node_$id")).whenever(it).database parameters.configOverrides(it) } val node = nodeFactory(MockNodeArgs(config, this, id, parameters.entropyRoot)) diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockServices.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockServices.kt index ddba48ea1c..5459048a4e 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockServices.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockServices.kt @@ -103,6 +103,15 @@ open class MockServices( return props } + /** + * Make properties appropriate for creating a Database for unit tests. + * + * @param nodeName Reflects the "instance" of the in-memory database or database username/schema. + */ + @JvmStatic + fun makeTestDatabaseProperties(nodeName: String? = null): DatabaseConfig = + DatabaseConfig(nodeOrganizationName = nodeName) + /** * Creates an instance of [InMemoryIdentityService] with [MOCK_IDENTITIES]. */