diff --git a/client/jfx/src/integration-test/kotlin/net/corda/client/jfx/NodeMonitorModelTest.kt b/client/jfx/src/integration-test/kotlin/net/corda/client/jfx/NodeMonitorModelTest.kt index 2b75244715..e703b5fa7c 100644 --- a/client/jfx/src/integration-test/kotlin/net/corda/client/jfx/NodeMonitorModelTest.kt +++ b/client/jfx/src/integration-test/kotlin/net/corda/client/jfx/NodeMonitorModelTest.kt @@ -31,11 +31,10 @@ import net.corda.node.services.Permissions.Companion.startFlow import net.corda.nodeapi.User import net.corda.testing.* import net.corda.testing.driver.driver -import net.corda.testing.node.DriverBasedTest import org.junit.Test import rx.Observable -class NodeMonitorModelTest : DriverBasedTest() { +class NodeMonitorModelTest { lateinit var aliceNode: NodeInfo lateinit var bobNode: NodeInfo lateinit var notaryParty: Party @@ -50,8 +49,7 @@ class NodeMonitorModelTest : DriverBasedTest() { lateinit var vaultUpdates: Observable> lateinit var networkMapUpdates: Observable lateinit var newNode: (CordaX500Name) -> NodeInfo - - override fun setup() = driver(extraCordappPackagesToScan = listOf("net.corda.finance")) { + private fun setup(runTest: () -> Unit) = driver(extraCordappPackagesToScan = listOf("net.corda.finance")) { val cashUser = User("user1", "test", permissions = setOf( startFlow(), startFlow(), @@ -91,7 +89,7 @@ class NodeMonitorModelTest : DriverBasedTest() { } @Test - fun `network map update`() { + fun `network map update`() = setup { val charlieNode = newNode(CHARLIE.name) val nonServiceIdentities = aliceNode.legalIdentitiesAndCerts + bobNode.legalIdentitiesAndCerts + charlieNode.legalIdentitiesAndCerts networkMapUpdates.filter { it.node.legalIdentitiesAndCerts.any { it in nonServiceIdentities } } @@ -112,7 +110,7 @@ class NodeMonitorModelTest : DriverBasedTest() { } @Test - fun `cash issue works end to end`() { + fun `cash issue works end to end`() = setup { rpc.startFlow(::CashIssueFlow, Amount(100, USD), OpaqueBytes(ByteArray(1, { 1 })), @@ -136,7 +134,7 @@ class NodeMonitorModelTest : DriverBasedTest() { } @Test - fun `cash issue and move`() { + fun `cash issue and move`() = setup { val (_, issueIdentity) = rpc.startFlow(::CashIssueFlow, 100.DOLLARS, OpaqueBytes.of(1), notaryParty).returnValue.getOrThrow() rpc.startFlow(::CashPaymentFlow, 100.DOLLARS, bobNode.chooseIdentity()).returnValue.getOrThrow() diff --git a/node/src/integration-test/kotlin/net/corda/node/services/DistributedServiceTests.kt b/node/src/integration-test/kotlin/net/corda/node/services/DistributedServiceTests.kt index 6952390506..3f5fd63e45 100644 --- a/node/src/integration-test/kotlin/net/corda/node/services/DistributedServiceTests.kt +++ b/node/src/integration-test/kotlin/net/corda/node/services/DistributedServiceTests.kt @@ -18,20 +18,18 @@ import net.corda.nodeapi.User import net.corda.testing.* import net.corda.testing.driver.NodeHandle import net.corda.testing.driver.driver -import net.corda.testing.node.DriverBasedTest import org.junit.Test import rx.Observable import java.util.* import kotlin.test.assertEquals -class DistributedServiceTests : DriverBasedTest() { +class DistributedServiceTests { lateinit var alice: NodeHandle lateinit var notaries: List lateinit var aliceProxy: CordaRPCOps lateinit var raftNotaryIdentity: Party lateinit var notaryStateMachines: Observable> - - override fun setup() = driver(extraCordappPackagesToScan = listOf("net.corda.finance.contracts")) { + private fun setup(runTest: () -> Unit) = driver(extraCordappPackagesToScan = listOf("net.corda.finance.contracts")) { // Start Alice and 3 notaries in a RAFT cluster val clusterSize = 3 val testUser = User("test", "test", permissions = setOf( @@ -72,7 +70,7 @@ class DistributedServiceTests : DriverBasedTest() { // TODO Use a dummy distributed service rather than a Raft Notary Service as this test is only about Artemis' ability // to handle distributed services @Test - fun `requests are distributed evenly amongst the nodes`() { + fun `requests are distributed evenly amongst the nodes`() = setup { // Issue 100 pounds, then pay ourselves 50x2 pounds issueCash(100.POUNDS) @@ -100,7 +98,7 @@ class DistributedServiceTests : DriverBasedTest() { // TODO This should be in RaftNotaryServiceTests @Test - fun `cluster survives if a notary is killed`() { + fun `cluster survives if a notary is killed`() = setup { // Issue 100 pounds, then pay ourselves 10x5 pounds issueCash(100.POUNDS) diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/DriverBasedTest.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/DriverBasedTest.kt deleted file mode 100644 index d9b4807845..0000000000 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/DriverBasedTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -package net.corda.testing.node - -import com.google.common.util.concurrent.SettableFuture -import net.corda.core.utilities.getOrThrow -import net.corda.testing.driver.DriverDSLExposedInterface -import org.junit.After -import org.junit.Before -import java.util.concurrent.CountDownLatch -import kotlin.concurrent.thread - -abstract class DriverBasedTest { - private val stopDriver = CountDownLatch(1) - private var driverThread: Thread? = null - private lateinit var driverStarted: SettableFuture - - protected sealed class RunTestToken { - internal object Token : RunTestToken() - } - - protected abstract fun setup(): RunTestToken - - protected fun DriverDSLExposedInterface.runTest(): RunTestToken { - driverStarted.set(Unit) - stopDriver.await() - return RunTestToken.Token - } - - @Before - fun start() { - driverStarted = SettableFuture.create() - driverThread = thread { - try { - setup() - } catch (t: Throwable) { - driverStarted.setException(t) - } - } - driverStarted.getOrThrow() - } - - @After - fun stop() { - stopDriver.countDown() - driverThread?.join() - } -} \ No newline at end of file