From 05ec885afd0492eefbf0dc77033db3203eb2fa97 Mon Sep 17 00:00:00 2001
From: szymonsztuka <szymon.sztuka@yahoo.com>
Date: Fri, 13 Apr 2018 15:28:07 +0100
Subject: [PATCH] Update integration test setup in database mode after OS->ENT
 merge (#732)

Added Notary schema for SQL setup to tests.
Added SQL setup/tearDown to a loop starting the same node few times in DriverTests.
---
 .../kotlin/net/corda/finance/flows/CashConfigDataFlowTest.kt  | 3 ++-
 .../kotlin/net/corda/node/NodeUnloadHandlerTests.kt           | 3 ++-
 .../kotlin/net/corda/testing/driver/DriverTests.kt            | 4 +++-
 .../kotlin/net/corda/webserver/WebserverDriverTests.kt        | 3 ++-
 4 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/finance/src/integration-test/kotlin/net/corda/finance/flows/CashConfigDataFlowTest.kt b/finance/src/integration-test/kotlin/net/corda/finance/flows/CashConfigDataFlowTest.kt
index 32a2902145..72002c20f7 100644
--- a/finance/src/integration-test/kotlin/net/corda/finance/flows/CashConfigDataFlowTest.kt
+++ b/finance/src/integration-test/kotlin/net/corda/finance/flows/CashConfigDataFlowTest.kt
@@ -17,6 +17,7 @@ import net.corda.finance.USD
 import net.corda.testing.core.ALICE_NAME
 import net.corda.testing.core.BOB_NAME
 import net.corda.testing.core.DUMMY_BANK_A_NAME
+import net.corda.testing.core.DUMMY_NOTARY_NAME
 import net.corda.testing.driver.driver
 import net.corda.testing.internal.IntegrationTest
 import net.corda.testing.internal.IntegrationTestSchemas
@@ -30,7 +31,7 @@ class CashConfigDataFlowTest : IntegrationTest() {
         @ClassRule
         @JvmField
         val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), BOB_NAME.toDatabaseSchemaName(),
-                DUMMY_BANK_A_NAME.toDatabaseSchemaName())
+                DUMMY_BANK_A_NAME.toDatabaseSchemaName(), DUMMY_NOTARY_NAME.toDatabaseSchemaName())
     }
     @Test
     fun `issuable currencies are read in from node config`() {
diff --git a/node/src/integration-test/kotlin/net/corda/node/NodeUnloadHandlerTests.kt b/node/src/integration-test/kotlin/net/corda/node/NodeUnloadHandlerTests.kt
index 7b4264b6a6..436c2e2c07 100644
--- a/node/src/integration-test/kotlin/net/corda/node/NodeUnloadHandlerTests.kt
+++ b/node/src/integration-test/kotlin/net/corda/node/NodeUnloadHandlerTests.kt
@@ -16,6 +16,7 @@ import net.corda.core.serialization.SingletonSerializeAsToken
 import net.corda.core.utilities.contextLogger
 import net.corda.core.utilities.getOrThrow
 import net.corda.testing.core.DUMMY_BANK_A_NAME
+import net.corda.testing.core.DUMMY_NOTARY_NAME
 import net.corda.testing.driver.DriverParameters
 import net.corda.testing.driver.driver
 import net.corda.testing.internal.IntegrationTest
@@ -31,7 +32,7 @@ class NodeUnloadHandlerTests : IntegrationTest() {
     companion object {
         @ClassRule
         @JvmField
-        val databaseSchemas = IntegrationTestSchemas(DUMMY_BANK_A_NAME.toDatabaseSchemaName())
+        val databaseSchemas = IntegrationTestSchemas(DUMMY_BANK_A_NAME.toDatabaseSchemaName(), DUMMY_NOTARY_NAME.toDatabaseSchemaName() )
         val latch = CountDownLatch(1)
     }
 
diff --git a/testing/node-driver/src/integration-test/kotlin/net/corda/testing/driver/DriverTests.kt b/testing/node-driver/src/integration-test/kotlin/net/corda/testing/driver/DriverTests.kt
index 643eb8a38e..fda41a3e44 100644
--- a/testing/node-driver/src/integration-test/kotlin/net/corda/testing/driver/DriverTests.kt
+++ b/testing/node-driver/src/integration-test/kotlin/net/corda/testing/driver/DriverTests.kt
@@ -62,7 +62,7 @@ class DriverTests : IntegrationTest() {
         @ClassRule
         @JvmField
         val databaseSchemas = IntegrationTestSchemas(DUMMY_BANK_A_NAME.toDatabaseSchemaName(), DUMMY_NOTARY_NAME.toDatabaseSchemaName(),
-                DUMMY_REGULATOR_NAME.toDatabaseSchemaName())
+                DUMMY_REGULATOR_NAME.toDatabaseSchemaName(), BOB_NAME.toDatabaseSchemaName(), DUMMY_BANK_B_NAME.toDatabaseSchemaName())
     }
 
     @Test
@@ -94,10 +94,12 @@ class DriverTests : IntegrationTest() {
     fun `default notary is visible when the startNode future completes`() {
         // Based on local testing, running this 3 times gives us a high confidence that we'll spot if the feature is not working
         repeat(3) {
+            setUp() // R3.Corda only: Schema setup for standalone database, does nothing for H2
             driver(DriverParameters(startNodesInProcess = true)) {
                 val bob = startNode(providedName = BOB_NAME).getOrThrow()
                 assertThat(bob.rpc.networkMapSnapshot().flatMap { it.legalIdentities }).contains(defaultNotaryIdentity)
             }
+            tearDown() // R3.Corda only: Schema cleanup for standalone database, does nothing for H2
         }
     }
 
diff --git a/webserver/src/integration-test/kotlin/net/corda/webserver/WebserverDriverTests.kt b/webserver/src/integration-test/kotlin/net/corda/webserver/WebserverDriverTests.kt
index 8926a04c9a..68f2d3ad70 100644
--- a/webserver/src/integration-test/kotlin/net/corda/webserver/WebserverDriverTests.kt
+++ b/webserver/src/integration-test/kotlin/net/corda/webserver/WebserverDriverTests.kt
@@ -13,6 +13,7 @@ package net.corda.webserver
 import net.corda.core.utilities.NetworkHostAndPort
 import net.corda.core.utilities.getOrThrow
 import net.corda.testing.core.DUMMY_BANK_A_NAME
+import net.corda.testing.core.DUMMY_NOTARY_NAME
 import net.corda.testing.internal.IntegrationTest
 import net.corda.testing.internal.IntegrationTestSchemas
 import net.corda.testing.driver.WebserverHandle
@@ -39,7 +40,7 @@ class WebserverDriverTests : IntegrationTest() {
 
         @ClassRule
         @JvmField
-        val databaseSchemas = IntegrationTestSchemas(DUMMY_BANK_A_NAME.toDatabaseSchemaName())
+        val databaseSchemas = IntegrationTestSchemas(DUMMY_BANK_A_NAME.toDatabaseSchemaName(), DUMMY_NOTARY_NAME.toDatabaseSchemaName())
     }
 
     @Test