Moved Driver.kt to net.corda.testing.driver in the test-utils module

This commit is contained in:
Shams Asari
2017-06-14 14:26:06 +01:00
parent 97053be4f7
commit b52d3706eb
46 changed files with 207 additions and 172 deletions

1
.idea/compiler.xml generated
View File

@ -79,6 +79,7 @@
<module name="simm-valuation-demo_test" target="1.8" /> <module name="simm-valuation-demo_test" target="1.8" />
<module name="smoke-test-utils_main" target="1.8" /> <module name="smoke-test-utils_main" target="1.8" />
<module name="smoke-test-utils_test" target="1.8" /> <module name="smoke-test-utils_test" target="1.8" />
<module name="test-utils_integrationTest" target="1.8" />
<module name="test-utils_main" target="1.8" /> <module name="test-utils_main" target="1.8" />
<module name="test-utils_test" target="1.8" /> <module name="test-utils_test" target="1.8" />
<module name="tools_main" target="1.8" /> <module name="tools_main" target="1.8" />

View File

@ -28,11 +28,11 @@ import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.flows.CashExitFlow import net.corda.flows.CashExitFlow
import net.corda.flows.CashIssueFlow import net.corda.flows.CashIssueFlow
import net.corda.flows.CashPaymentFlow import net.corda.flows.CashPaymentFlow
import net.corda.node.driver.driver
import net.corda.node.services.network.NetworkMapService import net.corda.node.services.network.NetworkMapService
import net.corda.node.services.startFlowPermission import net.corda.node.services.startFlowPermission
import net.corda.node.services.transactions.SimpleNotaryService import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.nodeapi.User import net.corda.nodeapi.User
import net.corda.testing.driver.driver
import net.corda.testing.expect import net.corda.testing.expect
import net.corda.testing.expectEvents import net.corda.testing.expectEvents
import net.corda.testing.node.DriverBasedTest import net.corda.testing.node.DriverBasedTest
@ -123,14 +123,14 @@ class NodeMonitorModelTest : DriverBasedTest() {
vaultUpdates.expectEvents(isStrict = false) { vaultUpdates.expectEvents(isStrict = false) {
sequence( sequence(
// SNAPSHOT // SNAPSHOT
expect { output: Vault.Update -> expect { (consumed, produced) ->
require(output.consumed.isEmpty()) { output.consumed.size } require(consumed.isEmpty()) { consumed.size }
require(output.produced.isEmpty()) { output.produced.size } require(produced.isEmpty()) { produced.size }
}, },
// ISSUE // ISSUE
expect { output: Vault.Update -> expect { (consumed, produced) ->
require(output.consumed.isEmpty()) { output.consumed.size } require(consumed.isEmpty()) { consumed.size }
require(output.produced.size == 1) { output.produced.size } require(produced.size == 1) { produced.size }
} }
) )
} }
@ -207,19 +207,19 @@ class NodeMonitorModelTest : DriverBasedTest() {
vaultUpdates.expectEvents { vaultUpdates.expectEvents {
sequence( sequence(
// SNAPSHOT // SNAPSHOT
expect { output: Vault.Update -> expect { (consumed, produced) ->
require(output.consumed.isEmpty()) { output.consumed.size } require(consumed.isEmpty()) { consumed.size }
require(output.produced.isEmpty()) { output.produced.size } require(produced.isEmpty()) { produced.size }
}, },
// ISSUE // ISSUE
expect { update -> expect { (consumed, produced) ->
require(update.consumed.isEmpty()) { update.consumed.size } require(consumed.isEmpty()) { consumed.size }
require(update.produced.size == 1) { update.produced.size } require(produced.size == 1) { produced.size }
}, },
// MOVE // MOVE
expect { update -> expect { (consumed, produced) ->
require(update.consumed.size == 1) { update.consumed.size } require(consumed.size == 1) { consumed.size }
require(update.produced.isEmpty()) { update.produced.size } require(produced.isEmpty()) { produced.size }
} }
) )
} }
@ -227,14 +227,14 @@ class NodeMonitorModelTest : DriverBasedTest() {
stateMachineTransactionMapping.expectEvents { stateMachineTransactionMapping.expectEvents {
sequence( sequence(
// ISSUE // ISSUE
expect { mapping -> expect { (stateMachineRunId, transactionId) ->
require(mapping.stateMachineRunId == issueSmId) require(stateMachineRunId == issueSmId)
require(mapping.transactionId == issueTx!!.id) require(transactionId == issueTx!!.id)
}, },
// MOVE // MOVE
expect { mapping -> expect { (stateMachineRunId, transactionId) ->
require(mapping.stateMachineRunId == moveSmId) require(stateMachineRunId == moveSmId)
require(mapping.transactionId == moveTx!!.id) require(transactionId == moveTx!!.id)
} }
) )
} }

View File

@ -12,7 +12,7 @@ import net.corda.client.rpc.internal.RPCClient
import net.corda.client.rpc.internal.RPCClientConfiguration import net.corda.client.rpc.internal.RPCClientConfiguration
import net.corda.core.* import net.corda.core.*
import net.corda.core.messaging.RPCOps import net.corda.core.messaging.RPCOps
import net.corda.node.driver.poll import net.corda.testing.driver.poll
import net.corda.node.services.messaging.RPCServerConfiguration import net.corda.node.services.messaging.RPCServerConfiguration
import net.corda.nodeapi.RPCApi import net.corda.nodeapi.RPCApi
import net.corda.nodeapi.RPCKryo import net.corda.nodeapi.RPCKryo

View File

@ -11,9 +11,9 @@ import net.corda.core.minutes
import net.corda.core.seconds import net.corda.core.seconds
import net.corda.core.utilities.Rate import net.corda.core.utilities.Rate
import net.corda.core.utilities.div import net.corda.core.utilities.div
import net.corda.node.driver.ShutdownManager
import net.corda.node.services.messaging.RPCServerConfiguration import net.corda.node.services.messaging.RPCServerConfiguration
import net.corda.testing.RPCDriverExposedDSLInterface import net.corda.testing.RPCDriverExposedDSLInterface
import net.corda.testing.driver.ShutdownManager
import net.corda.testing.measure import net.corda.testing.measure
import net.corda.testing.rpcDriver import net.corda.testing.rpcDriver
import org.junit.Ignore import org.junit.Ignore
@ -83,12 +83,13 @@ class RPCPerformanceTests : AbstractRPCTest() {
val averageIndividualMs: Double, val averageIndividualMs: Double,
val Mbps: Double val Mbps: Double
) )
@Test @Test
fun `measure Megabytes per second for simple RPCs`() { fun `measure Megabytes per second for simple RPCs`() {
warmup() warmup()
val inputOutputSizes = listOf(1024, 4096, 100 * 1024) val inputOutputSizes = listOf(1024, 4096, 100 * 1024)
val overallTraffic = 512 * 1024 * 1024L val overallTraffic = 512 * 1024 * 1024L
measure(inputOutputSizes, (1..5)) { inputOutputSize, N -> measure(inputOutputSizes, (1..5)) { inputOutputSize, _ ->
rpcDriver { rpcDriver {
val proxy = testProxy( val proxy = testProxy(
RPCClientConfiguration.default.copy( RPCClientConfiguration.default.copy(

View File

@ -10,6 +10,8 @@ UNRELEASED
* A new RPC has been added to support fuzzy matching of X.500 names, for instance, to translate from user input to * A new RPC has been added to support fuzzy matching of X.500 names, for instance, to translate from user input to
an unambiguous identity by searching the network map. an unambiguous identity by searching the network map.
* The node driver has moved to net.corda.testing.driver in the test-utils module
Milestone 12 Milestone 12
------------ ------------

View File

@ -35,8 +35,7 @@ compileTestJava.dependsOn tasks.getByPath(':node:capsule:buildCordaJAR')
dependencies { dependencies {
compile project(':core') compile project(':core')
compile project(':client:jfx') compile project(':client:jfx')
compile project(':node') compile project(':test-utils')
testCompile project(':test-utils')
testCompile project(':verifier') testCompile project(':verifier')
compile "org.graphstream:gs-core:1.3" compile "org.graphstream:gs-core:1.3"

View File

@ -14,7 +14,7 @@ import net.corda.core.utilities.BOB
import net.corda.core.utilities.DUMMY_NOTARY import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.flows.CashIssueFlow import net.corda.flows.CashIssueFlow
import net.corda.flows.CashPaymentFlow import net.corda.flows.CashPaymentFlow
import net.corda.node.driver.driver import net.corda.testing.driver.driver
import net.corda.node.services.startFlowPermission import net.corda.node.services.startFlowPermission
import net.corda.node.services.transactions.ValidatingNotaryService import net.corda.node.services.transactions.ValidatingNotaryService
import net.corda.nodeapi.User import net.corda.nodeapi.User

View File

@ -17,10 +17,10 @@ import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.flows.CashExitFlow import net.corda.flows.CashExitFlow
import net.corda.flows.CashIssueFlow import net.corda.flows.CashIssueFlow
import net.corda.flows.CashPaymentFlow import net.corda.flows.CashPaymentFlow
import net.corda.node.driver.driver
import net.corda.node.services.startFlowPermission import net.corda.node.services.startFlowPermission
import net.corda.node.services.transactions.ValidatingNotaryService import net.corda.node.services.transactions.ValidatingNotaryService
import net.corda.nodeapi.User import net.corda.nodeapi.User
import net.corda.testing.driver.driver
import org.graphstream.graph.Edge import org.graphstream.graph.Edge
import org.graphstream.graph.Node import org.graphstream.graph.Node
import org.graphstream.graph.implementations.MultiGraph import org.graphstream.graph.implementations.MultiGraph

View File

@ -183,6 +183,7 @@ dependencies {
// Integration test helpers // Integration test helpers
integrationTestCompile "junit:junit:$junit_version" integrationTestCompile "junit:junit:$junit_version"
integrationTestCompile "org.assertj:assertj-core:${assertj_version}"
// Smoke tests do NOT have any Node code on the classpath! // Smoke tests do NOT have any Node code on the classpath!
smokeTestCompile project(':smoke-test-utils') smokeTestCompile project(':smoke-test-utils')

View File

@ -7,7 +7,7 @@ import net.corda.core.flows.StartableByRPC
import net.corda.core.getOrThrow import net.corda.core.getOrThrow
import net.corda.core.messaging.startFlow import net.corda.core.messaging.startFlow
import net.corda.core.utilities.ALICE import net.corda.core.utilities.ALICE
import net.corda.node.driver.driver import net.corda.testing.driver.driver
import net.corda.node.services.startFlowPermission import net.corda.node.services.startFlowPermission
import net.corda.nodeapi.User import net.corda.nodeapi.User
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat

View File

@ -0,0 +1,54 @@
package net.corda.node
import co.paralleluniverse.fibers.Suspendable
import com.google.common.util.concurrent.Futures
import net.corda.core.flows.FlowLogic
import net.corda.core.flows.InitiatedBy
import net.corda.core.flows.InitiatingFlow
import net.corda.core.flows.StartableByRPC
import net.corda.core.getOrThrow
import net.corda.core.identity.Party
import net.corda.core.messaging.startFlow
import net.corda.core.utilities.ALICE
import net.corda.core.utilities.BOB
import net.corda.core.utilities.unwrap
import net.corda.node.services.startFlowPermission
import net.corda.nodeapi.User
import net.corda.testing.driver.driver
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
class CordappScanningDriverTest {
@Test
fun `sub-classed initiated flow pointing to the same initiating flow as its super-class`() {
val user = User("u", "p", setOf(startFlowPermission<ReceiveFlow>()))
// The driver will automatically pick up the annotated flows below
driver {
val (alice, bob) = Futures.allAsList(
startNode(ALICE.name, rpcUsers = listOf(user)),
startNode(BOB.name)).getOrThrow()
val initiatedFlowClass = alice.rpcClientToNode()
.start(user.username, user.password)
.proxy
.startFlow(::ReceiveFlow, bob.nodeInfo.legalIdentity)
.returnValue
assertThat(initiatedFlowClass.getOrThrow()).isEqualTo(SendSubClassFlow::class.java.name)
}
}
@StartableByRPC
@InitiatingFlow
class ReceiveFlow(val otherParty: Party) :FlowLogic<String>() {
@Suspendable
override fun call(): String = receive<String>(otherParty).unwrap { it }
}
@InitiatedBy(ReceiveFlow::class)
open class SendClassFlow(val otherParty: Party) : FlowLogic<Unit>() {
@Suspendable
override fun call() = send(otherParty, javaClass.name)
}
@InitiatedBy(ReceiveFlow::class)
class SendSubClassFlow(otherParty: Party) : SendClassFlow(otherParty)
}

View File

@ -1,8 +1,8 @@
package net.corda.node package net.corda.node
import com.google.common.base.Stopwatch import com.google.common.base.Stopwatch
import net.corda.node.driver.NetworkMapStartStrategy import net.corda.testing.driver.NetworkMapStartStrategy
import net.corda.node.driver.driver import net.corda.testing.driver.driver
import org.junit.Ignore import org.junit.Ignore
import org.junit.Test import org.junit.Test
import java.util.* import java.util.*

View File

@ -14,8 +14,8 @@ import net.corda.core.utilities.ALICE
import net.corda.core.utilities.DUMMY_NOTARY import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.flows.CashIssueFlow import net.corda.flows.CashIssueFlow
import net.corda.flows.CashPaymentFlow import net.corda.flows.CashPaymentFlow
import net.corda.node.driver.NodeHandle import net.corda.testing.driver.NodeHandle
import net.corda.node.driver.driver import net.corda.testing.driver.driver
import net.corda.node.services.transactions.RaftValidatingNotaryService import net.corda.node.services.transactions.RaftValidatingNotaryService
import net.corda.nodeapi.User import net.corda.nodeapi.User
import net.corda.testing.expect import net.corda.testing.expect

View File

@ -0,0 +1,52 @@
package net.corda.node
import net.corda.core.copyToDirectory
import net.corda.core.createDirectories
import net.corda.core.div
import net.corda.core.utilities.ALICE
import net.corda.nodeapi.User
import net.corda.smoketesting.NodeConfig
import net.corda.smoketesting.NodeProcess
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
import java.nio.file.Paths
import java.util.concurrent.atomic.AtomicInteger
class CordappScanningNodeProcessTest {
private companion object {
val user = User("user1", "test", permissions = setOf("ALL"))
val port = AtomicInteger(15100)
}
private val factory = NodeProcess.Factory()
private val aliceConfig = NodeConfig(
party = ALICE,
p2pPort = port.andIncrement,
rpcPort = port.andIncrement,
webPort = port.andIncrement,
extraServices = emptyList(),
users = listOf(user)
)
@Test
fun `CorDapp jar in plugins directory is scanned`() {
// If the CorDapp jar does't exist then run the smokeTestClasses gradle task
val cordappJar = Paths.get(javaClass.getResource("/trader-demo.jar").toURI())
val pluginsDir = (factory.baseDirectory(aliceConfig) / "plugins").createDirectories()
cordappJar.copyToDirectory(pluginsDir)
factory.create(aliceConfig).use {
it.connect().use {
// If the CorDapp wasn't scanned then SellerFlow won't have been picked up as an RPC flow
assertThat(it.proxy.registeredFlows()).contains("net.corda.traderdemo.flow.SellerFlow")
}
}
}
@Test
fun `empty plugins directory`() {
(factory.baseDirectory(aliceConfig) / "plugins").createDirectories()
factory.create(aliceConfig).close()
}
}

View File

@ -1,99 +0,0 @@
package net.corda.node
import co.paralleluniverse.fibers.Suspendable
import com.google.common.util.concurrent.Futures
import net.corda.core.copyToDirectory
import net.corda.core.createDirectories
import net.corda.core.div
import net.corda.core.flows.FlowLogic
import net.corda.core.flows.InitiatedBy
import net.corda.core.flows.InitiatingFlow
import net.corda.core.flows.StartableByRPC
import net.corda.core.getOrThrow
import net.corda.core.identity.Party
import net.corda.core.messaging.startFlow
import net.corda.core.utilities.ALICE
import net.corda.core.utilities.BOB
import net.corda.core.utilities.unwrap
import net.corda.node.driver.driver
import net.corda.node.services.startFlowPermission
import net.corda.nodeapi.User
import net.corda.smoketesting.NodeConfig
import net.corda.smoketesting.NodeProcess
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
import java.nio.file.Paths
import java.util.concurrent.atomic.AtomicInteger
class CordappScanningTest {
private companion object {
val user = User("user1", "test", permissions = setOf("ALL"))
val port = AtomicInteger(15100)
}
private val factory = NodeProcess.Factory()
private val aliceConfig = NodeConfig(
party = ALICE,
p2pPort = port.andIncrement,
rpcPort = port.andIncrement,
webPort = port.andIncrement,
extraServices = emptyList(),
users = listOf(user)
)
@Test
fun `CorDapp jar in plugins directory is scanned`() {
// If the CorDapp jar does't exist then run the smokeTestClasses gradle task
val cordappJar = Paths.get(javaClass.getResource("/trader-demo.jar").toURI())
val pluginsDir = (factory.baseDirectory(aliceConfig) / "plugins").createDirectories()
cordappJar.copyToDirectory(pluginsDir)
factory.create(aliceConfig).use {
it.connect().use {
// If the CorDapp wasn't scanned then SellerFlow won't have been picked up as an RPC flow
assertThat(it.proxy.registeredFlows()).contains("net.corda.traderdemo.flow.SellerFlow")
}
}
}
@Test
fun `empty plugins directory`() {
(factory.baseDirectory(aliceConfig) / "plugins").createDirectories()
factory.create(aliceConfig).close()
}
@Test
fun `sub-classed initiated flow pointing to the same initiating flow as its super-class`() {
val user = User("u", "p", setOf(startFlowPermission<ReceiveFlow>()))
// We don't use the factory for this test because we want the node to pick up the annotated flows below. The driver
// will do just that.
driver {
val (alice, bob) = Futures.allAsList(
startNode(ALICE.name, rpcUsers = listOf(user)),
startNode(BOB.name)).getOrThrow()
val initiatedFlowClass = alice.rpcClientToNode()
.start(user.username, user.password)
.proxy
.startFlow(::ReceiveFlow, bob.nodeInfo.legalIdentity)
.returnValue
assertThat(initiatedFlowClass.getOrThrow()).isEqualTo(SendSubClassFlow::class.java.name)
}
}
@StartableByRPC
@InitiatingFlow
class ReceiveFlow(val otherParty: Party) : FlowLogic<String>() {
@Suspendable
override fun call(): String = receive<String>(otherParty).unwrap { it }
}
@InitiatedBy(ReceiveFlow::class)
open class SendClassFlow(val otherParty: Party) : FlowLogic<Unit>() {
@Suspendable
override fun call() = send(otherParty, javaClass.name)
}
@InitiatedBy(ReceiveFlow::class)
class SendSubClassFlow(otherParty: Party) : SendClassFlow(otherParty)
}

View File

@ -6,7 +6,7 @@ import net.corda.core.node.services.ServiceInfo
import net.corda.core.utilities.DUMMY_BANK_A import net.corda.core.utilities.DUMMY_BANK_A
import net.corda.core.utilities.DUMMY_BANK_B import net.corda.core.utilities.DUMMY_BANK_B
import net.corda.core.utilities.DUMMY_NOTARY import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.node.driver.driver import net.corda.testing.driver.driver
import net.corda.node.services.startFlowPermission import net.corda.node.services.startFlowPermission
import net.corda.node.services.transactions.SimpleNotaryService import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.nodeapi.User import net.corda.nodeapi.User

View File

@ -8,19 +8,19 @@ import net.corda.core.contracts.Contract
import net.corda.core.contracts.ContractState import net.corda.core.contracts.ContractState
import net.corda.core.contracts.TransactionForContract import net.corda.core.contracts.TransactionForContract
import net.corda.core.contracts.TransactionType import net.corda.core.contracts.TransactionType
import net.corda.core.identity.Party
import net.corda.core.crypto.SecureHash import net.corda.core.crypto.SecureHash
import net.corda.core.flows.FlowLogic import net.corda.core.flows.FlowLogic
import net.corda.core.flows.StartableByRPC import net.corda.core.flows.StartableByRPC
import net.corda.core.getOrThrow import net.corda.core.getOrThrow
import net.corda.core.identity.AbstractParty import net.corda.core.identity.AbstractParty
import net.corda.core.identity.Party
import net.corda.core.messaging.CordaRPCOps import net.corda.core.messaging.CordaRPCOps
import net.corda.core.messaging.startTrackedFlow import net.corda.core.messaging.startTrackedFlow
import net.corda.core.sizedInputStreamAndHash import net.corda.core.sizedInputStreamAndHash
import net.corda.core.transactions.SignedTransaction import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.* import net.corda.core.utilities.*
import net.corda.flows.FinalityFlow import net.corda.flows.FinalityFlow
import net.corda.node.driver.poll import net.corda.testing.driver.poll
import java.io.InputStream import java.io.InputStream
import java.net.HttpURLConnection import java.net.HttpURLConnection
import java.net.URL import java.net.URL

View File

@ -5,9 +5,9 @@ import net.corda.core.node.services.ServiceInfo
import net.corda.core.utilities.DUMMY_BANK_A import net.corda.core.utilities.DUMMY_BANK_A
import net.corda.core.utilities.DUMMY_BANK_B import net.corda.core.utilities.DUMMY_BANK_B
import net.corda.core.utilities.DUMMY_NOTARY import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.node.driver.driver
import net.corda.node.services.transactions.SimpleNotaryService import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.nodeapi.User import net.corda.nodeapi.User
import net.corda.testing.driver.driver
/** /**
* This file is exclusively for being able to run your nodes through an IDE (as opposed to running deployNodes) * This file is exclusively for being able to run your nodes through an IDE (as opposed to running deployNodes)

View File

@ -5,7 +5,7 @@ import net.corda.bank.api.BankOfCordaClientApi
import net.corda.bank.api.BankOfCordaWebApi.IssueRequestParams import net.corda.bank.api.BankOfCordaWebApi.IssueRequestParams
import net.corda.core.getOrThrow import net.corda.core.getOrThrow
import net.corda.core.node.services.ServiceInfo import net.corda.core.node.services.ServiceInfo
import net.corda.node.driver.driver import net.corda.testing.driver.driver
import net.corda.node.services.transactions.SimpleNotaryService import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.testing.BOC import net.corda.testing.BOC
import org.junit.Test import org.junit.Test

View File

@ -6,7 +6,7 @@ import net.corda.core.getOrThrow
import net.corda.core.messaging.startFlow import net.corda.core.messaging.startFlow
import net.corda.core.node.services.ServiceInfo import net.corda.core.node.services.ServiceInfo
import net.corda.flows.IssuerFlow.IssuanceRequester import net.corda.flows.IssuerFlow.IssuanceRequester
import net.corda.node.driver.driver import net.corda.testing.driver.driver
import net.corda.node.services.startFlowPermission import net.corda.node.services.startFlowPermission
import net.corda.node.services.transactions.SimpleNotaryService import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.nodeapi.User import net.corda.nodeapi.User

View File

@ -12,7 +12,7 @@ import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.flows.CashExitFlow import net.corda.flows.CashExitFlow
import net.corda.flows.CashPaymentFlow import net.corda.flows.CashPaymentFlow
import net.corda.flows.IssuerFlow import net.corda.flows.IssuerFlow
import net.corda.node.driver.driver import net.corda.testing.driver.driver
import net.corda.node.services.startFlowPermission import net.corda.node.services.startFlowPermission
import net.corda.node.services.transactions.SimpleNotaryService import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.nodeapi.User import net.corda.nodeapi.User

View File

@ -13,7 +13,7 @@ import net.corda.irs.contract.InterestRateSwap
import net.corda.irs.utilities.postJson import net.corda.irs.utilities.postJson
import net.corda.irs.utilities.putJson import net.corda.irs.utilities.putJson
import net.corda.irs.utilities.uploadFile import net.corda.irs.utilities.uploadFile
import net.corda.node.driver.driver import net.corda.testing.driver.driver
import net.corda.node.services.config.FullNodeConfiguration import net.corda.node.services.config.FullNodeConfiguration
import net.corda.node.services.transactions.SimpleNotaryService import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.nodeapi.User import net.corda.nodeapi.User

View File

@ -7,8 +7,8 @@ import net.corda.core.utilities.DUMMY_BANK_A
import net.corda.core.utilities.DUMMY_BANK_B import net.corda.core.utilities.DUMMY_BANK_B
import net.corda.core.utilities.DUMMY_NOTARY import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.irs.api.NodeInterestRates import net.corda.irs.api.NodeInterestRates
import net.corda.node.driver.driver
import net.corda.node.services.transactions.SimpleNotaryService import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.testing.driver.driver
/** /**
* This file is exclusively for being able to run your nodes through an IDE (as opposed to running deployNodes) * This file is exclusively for being able to run your nodes through an IDE (as opposed to running deployNodes)

View File

@ -1,10 +1,10 @@
package net.corda.demorun package net.corda.demorun
import net.corda.node.driver.NetworkMapStartStrategy
import net.corda.node.driver.PortAllocation
import net.corda.node.driver.driver
import net.corda.cordform.CordformDefinition import net.corda.cordform.CordformDefinition
import net.corda.cordform.CordformNode import net.corda.cordform.CordformNode
import net.corda.testing.driver.NetworkMapStartStrategy
import net.corda.testing.driver.PortAllocation
import net.corda.testing.driver.driver
fun CordformDefinition.clean() { fun CordformDefinition.clean() {
System.err.println("Deleting: $driverDirectory") System.err.println("Deleting: $driverDirectory")

View File

@ -34,10 +34,9 @@ dependencies {
compile project(path: ":node:capsule", configuration: 'runtimeArtifacts') compile project(path: ":node:capsule", configuration: 'runtimeArtifacts')
compile project(path: ":webserver:webcapsule", configuration: 'runtimeArtifacts') compile project(path: ":webserver:webcapsule", configuration: 'runtimeArtifacts')
compile project(':core') compile project(':core')
compile project(':node')
compile project(':webserver') compile project(':webserver')
compile project(':finance') compile project(':finance')
testCompile project(':test-utils') compile project(':test-utils')
// Javax is required for webapis // Javax is required for webapis
compile "org.glassfish.jersey.core:jersey-server:${jersey_version}" compile "org.glassfish.jersey.core:jersey-server:${jersey_version}"

View File

@ -7,7 +7,7 @@ import net.corda.core.node.services.ServiceInfo
import net.corda.core.utilities.DUMMY_BANK_A import net.corda.core.utilities.DUMMY_BANK_A
import net.corda.core.utilities.DUMMY_BANK_B import net.corda.core.utilities.DUMMY_BANK_B
import net.corda.core.utilities.DUMMY_NOTARY import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.node.driver.driver import net.corda.testing.driver.driver
import net.corda.node.services.transactions.SimpleNotaryService import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.testing.IntegrationTestCategory import net.corda.testing.IntegrationTestCategory
import net.corda.testing.http.HttpApi import net.corda.testing.http.HttpApi

View File

@ -7,7 +7,7 @@ import net.corda.core.node.services.ServiceInfo
import net.corda.core.utilities.DUMMY_BANK_A import net.corda.core.utilities.DUMMY_BANK_A
import net.corda.core.utilities.DUMMY_BANK_B import net.corda.core.utilities.DUMMY_BANK_B
import net.corda.core.utilities.DUMMY_BANK_C import net.corda.core.utilities.DUMMY_BANK_C
import net.corda.node.driver.driver import net.corda.testing.driver.driver
import net.corda.node.services.transactions.SimpleNotaryService import net.corda.node.services.transactions.SimpleNotaryService
/** /**

View File

@ -10,7 +10,7 @@ import net.corda.core.utilities.DUMMY_BANK_A
import net.corda.core.utilities.DUMMY_BANK_B import net.corda.core.utilities.DUMMY_BANK_B
import net.corda.core.utilities.DUMMY_NOTARY import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.flows.IssuerFlow import net.corda.flows.IssuerFlow
import net.corda.node.driver.poll import net.corda.testing.driver.poll
import net.corda.node.services.startFlowPermission import net.corda.node.services.startFlowPermission
import net.corda.node.services.transactions.SimpleNotaryService import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.nodeapi.User import net.corda.nodeapi.User

View File

@ -6,11 +6,11 @@ import net.corda.core.utilities.DUMMY_BANK_A
import net.corda.core.utilities.DUMMY_BANK_B import net.corda.core.utilities.DUMMY_BANK_B
import net.corda.core.utilities.DUMMY_NOTARY import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.flows.IssuerFlow import net.corda.flows.IssuerFlow
import net.corda.node.driver.driver
import net.corda.node.services.startFlowPermission import net.corda.node.services.startFlowPermission
import net.corda.node.services.transactions.SimpleNotaryService import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.nodeapi.User import net.corda.nodeapi.User
import net.corda.testing.BOC import net.corda.testing.BOC
import net.corda.testing.driver.driver
/** /**
* This file is exclusively for being able to run your nodes through an IDE (as opposed to running deployNodes) * This file is exclusively for being able to run your nodes through an IDE (as opposed to running deployNodes)

View File

@ -8,6 +8,22 @@ description 'Testing utilities for Corda'
configurations { configurations {
// we don't want isolated.jar in classPath, since we want to test jar being dynamically loaded as an attachment // we don't want isolated.jar in classPath, since we want to test jar being dynamically loaded as an attachment
runtime.exclude module: 'isolated' runtime.exclude module: 'isolated'
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
}
sourceSets {
integrationTest {
kotlin {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integration-test/kotlin')
}
resources {
srcDir file('src/integration-test/resources')
}
}
} }
dependencies { dependencies {
@ -32,6 +48,15 @@ dependencies {
// OkHTTP: Simple HTTP library. // OkHTTP: Simple HTTP library.
compile "com.squareup.okhttp3:okhttp:$okhttp_version" compile "com.squareup.okhttp3:okhttp:$okhttp_version"
// Integration test helpers
integrationTestCompile "org.assertj:assertj-core:${assertj_version}"
integrationTestCompile "junit:junit:$junit_version"
}
task integrationTest(type: Test) {
testClassesDir = sourceSets.integrationTest.output.classesDir
classpath = sourceSets.integrationTest.runtimeClasspath
} }
jar { jar {

View File

@ -1,4 +1,4 @@
package net.corda.node.driver package net.corda.testing.driver
import com.google.common.util.concurrent.ListenableFuture import com.google.common.util.concurrent.ListenableFuture
import net.corda.core.div import net.corda.core.div

View File

@ -13,7 +13,6 @@ import net.corda.core.map
import net.corda.core.messaging.RPCOps import net.corda.core.messaging.RPCOps
import net.corda.core.random63BitValue import net.corda.core.random63BitValue
import net.corda.core.utilities.ProcessUtilities import net.corda.core.utilities.ProcessUtilities
import net.corda.node.driver.*
import net.corda.node.services.RPCUserService import net.corda.node.services.RPCUserService
import net.corda.node.services.messaging.ArtemisMessagingServer import net.corda.node.services.messaging.ArtemisMessagingServer
import net.corda.node.services.messaging.RPCServer import net.corda.node.services.messaging.RPCServer
@ -22,6 +21,7 @@ import net.corda.nodeapi.ArtemisTcpTransport
import net.corda.nodeapi.ConnectionDirection import net.corda.nodeapi.ConnectionDirection
import net.corda.nodeapi.RPCApi import net.corda.nodeapi.RPCApi
import net.corda.nodeapi.User import net.corda.nodeapi.User
import net.corda.testing.driver.*
import org.apache.activemq.artemis.api.core.SimpleString import org.apache.activemq.artemis.api.core.SimpleString
import org.apache.activemq.artemis.api.core.TransportConfiguration import org.apache.activemq.artemis.api.core.TransportConfiguration
import org.apache.activemq.artemis.api.core.client.ActiveMQClient import org.apache.activemq.artemis.api.core.client.ActiveMQClient

View File

@ -1,6 +1,6 @@
@file:JvmName("Driver") @file:JvmName("Driver")
package net.corda.node.driver package net.corda.testing.driver
import com.google.common.net.HostAndPort import com.google.common.net.HostAndPort
import com.google.common.util.concurrent.* import com.google.common.util.concurrent.*
@ -14,7 +14,6 @@ import net.corda.core.crypto.X509Utilities
import net.corda.core.crypto.appendToCommonName import net.corda.core.crypto.appendToCommonName
import net.corda.core.crypto.commonName import net.corda.core.crypto.commonName
import net.corda.core.identity.Party import net.corda.core.identity.Party
import net.corda.core.identity.PartyAndCertificate
import net.corda.core.messaging.CordaRPCOps import net.corda.core.messaging.CordaRPCOps
import net.corda.core.node.NodeInfo import net.corda.core.node.NodeInfo
import net.corda.core.node.services.ServiceInfo import net.corda.core.node.services.ServiceInfo

View File

@ -1,4 +1,4 @@
package net.corda.node.driver package net.corda.testing.driver
import com.google.common.net.HostAndPort import com.google.common.net.HostAndPort
import net.corda.core.utilities.DUMMY_MAP import net.corda.core.utilities.DUMMY_MAP

View File

@ -2,7 +2,7 @@ package net.corda.testing.node
import com.google.common.util.concurrent.SettableFuture import com.google.common.util.concurrent.SettableFuture
import net.corda.core.getOrThrow import net.corda.core.getOrThrow
import net.corda.node.driver.DriverDSLExposedInterface import net.corda.testing.driver.DriverDSLExposedInterface
import org.junit.After import org.junit.After
import org.junit.Before import org.junit.Before
import java.util.concurrent.CountDownLatch import java.util.concurrent.CountDownLatch

View File

@ -11,7 +11,6 @@ import net.corda.core.node.services.ServiceType
import net.corda.core.utilities.DUMMY_CA import net.corda.core.utilities.DUMMY_CA
import net.corda.core.utilities.DUMMY_MAP import net.corda.core.utilities.DUMMY_MAP
import net.corda.core.utilities.WHITESPACE import net.corda.core.utilities.WHITESPACE
import net.corda.node.driver.addressMustNotBeBoundFuture
import net.corda.node.internal.Node import net.corda.node.internal.Node
import net.corda.node.services.config.ConfigHelper import net.corda.node.services.config.ConfigHelper
import net.corda.node.services.config.FullNodeConfiguration import net.corda.node.services.config.FullNodeConfiguration
@ -22,6 +21,7 @@ import net.corda.node.utilities.ServiceIdentityGenerator
import net.corda.nodeapi.User import net.corda.nodeapi.User
import net.corda.nodeapi.config.parseAs import net.corda.nodeapi.config.parseAs
import net.corda.testing.MOCK_VERSION_INFO import net.corda.testing.MOCK_VERSION_INFO
import net.corda.testing.driver.addressMustNotBeBoundFuture
import net.corda.testing.getFreeLocalPorts import net.corda.testing.getFreeLocalPorts
import org.apache.logging.log4j.Level import org.apache.logging.log4j.Level
import org.bouncycastle.asn1.x500.X500Name import org.bouncycastle.asn1.x500.X500Name

View File

@ -30,7 +30,7 @@ dependencies {
compile project(':core') compile project(':core')
compile project(':client:jfx') compile project(':client:jfx')
compile project(':client:mock') compile project(':client:mock')
compile project(':node') compile project(':test-utils')
compile project(':finance') compile project(':finance')
// Capsule is a library for building independently executable fat JARs. // Capsule is a library for building independently executable fat JARs.

View File

@ -39,8 +39,8 @@ import net.corda.flows.CashFlowCommand
import net.corda.flows.CashIssueFlow import net.corda.flows.CashIssueFlow
import net.corda.flows.CashPaymentFlow import net.corda.flows.CashPaymentFlow
import net.corda.flows.IssuerFlow.IssuanceRequester import net.corda.flows.IssuerFlow.IssuanceRequester
import net.corda.node.driver.PortAllocation import net.corda.testing.driver.PortAllocation
import net.corda.node.driver.driver import net.corda.testing.driver.driver
import net.corda.node.services.startFlowPermission import net.corda.node.services.startFlowPermission
import net.corda.node.services.transactions.SimpleNotaryService import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.nodeapi.User import net.corda.nodeapi.User

View File

@ -6,7 +6,7 @@ mainClassName = 'net.corda.loadtest.MainKt'
dependencies { dependencies {
compile project(':client:mock') compile project(':client:mock')
compile project(':client:rpc') compile project(':client:rpc')
compile project(':node') compile project(':test-utils')
// https://mvnrepository.com/artifact/com.jcraft/jsch // https://mvnrepository.com/artifact/com.jcraft/jsch
compile group: 'com.jcraft', name: 'jsch', version: '0.1.54' compile group: 'com.jcraft', name: 'jsch', version: '0.1.54'

View File

@ -8,7 +8,7 @@ import com.jcraft.jsch.agentproxy.usocket.JNAUSocketFactory
import net.corda.client.rpc.CordaRPCClient import net.corda.client.rpc.CordaRPCClient
import net.corda.client.rpc.CordaRPCConnection import net.corda.client.rpc.CordaRPCConnection
import net.corda.core.messaging.CordaRPCOps import net.corda.core.messaging.CordaRPCOps
import net.corda.node.driver.PortAllocation import net.corda.testing.driver.PortAllocation
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
import java.io.Closeable import java.io.Closeable

View File

@ -3,7 +3,7 @@ package net.corda.loadtest
import net.corda.client.mock.Generator import net.corda.client.mock.Generator
import net.corda.client.rpc.notUsed import net.corda.client.rpc.notUsed
import net.corda.core.crypto.toBase58String import net.corda.core.crypto.toBase58String
import net.corda.node.driver.PortAllocation import net.corda.testing.driver.PortAllocation
import net.corda.node.services.network.NetworkMapService import net.corda.node.services.network.NetworkMapService
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import java.util.* import java.util.*

View File

@ -15,7 +15,6 @@ import net.corda.core.random63BitValue
import net.corda.core.transactions.LedgerTransaction import net.corda.core.transactions.LedgerTransaction
import net.corda.core.utilities.ProcessUtilities import net.corda.core.utilities.ProcessUtilities
import net.corda.core.utilities.loggerFor import net.corda.core.utilities.loggerFor
import net.corda.node.driver.*
import net.corda.node.services.config.configureDevKeyAndTrustStores import net.corda.node.services.config.configureDevKeyAndTrustStores
import net.corda.nodeapi.ArtemisMessagingComponent.Companion.NODE_USER import net.corda.nodeapi.ArtemisMessagingComponent.Companion.NODE_USER
import net.corda.nodeapi.ArtemisTcpTransport import net.corda.nodeapi.ArtemisTcpTransport
@ -23,6 +22,7 @@ import net.corda.nodeapi.ConnectionDirection
import net.corda.nodeapi.VerifierApi import net.corda.nodeapi.VerifierApi
import net.corda.nodeapi.config.NodeSSLConfiguration import net.corda.nodeapi.config.NodeSSLConfiguration
import net.corda.nodeapi.config.SSLConfiguration import net.corda.nodeapi.config.SSLConfiguration
import net.corda.testing.driver.*
import org.apache.activemq.artemis.api.core.SimpleString import org.apache.activemq.artemis.api.core.SimpleString
import org.apache.activemq.artemis.api.core.client.ActiveMQClient import org.apache.activemq.artemis.api.core.client.ActiveMQClient
import org.apache.activemq.artemis.api.core.client.ClientProducer import org.apache.activemq.artemis.api.core.client.ClientProducer

View File

@ -13,7 +13,7 @@ import net.corda.core.utilities.ALICE
import net.corda.core.utilities.DUMMY_NOTARY import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.flows.CashIssueFlow import net.corda.flows.CashIssueFlow
import net.corda.flows.CashPaymentFlow import net.corda.flows.CashPaymentFlow
import net.corda.node.driver.NetworkMapStartStrategy import net.corda.testing.driver.NetworkMapStartStrategy
import net.corda.node.services.config.VerifierType import net.corda.node.services.config.VerifierType
import net.corda.node.services.transactions.ValidatingNotaryService import net.corda.node.services.transactions.ValidatingNotaryService
import org.junit.Test import org.junit.Test

View File

@ -33,7 +33,6 @@ dependencies {
compile project(':finance') compile project(':finance')
compile project(':client:rpc') compile project(':client:rpc')
compile project(':client:jackson') compile project(':client:jackson')
testCompile project(':node')
// Web stuff: for HTTP[S] servlets // Web stuff: for HTTP[S] servlets
compile "org.eclipse.jetty:jetty-servlet:$jetty_version" compile "org.eclipse.jetty:jetty-servlet:$jetty_version"
@ -58,6 +57,7 @@ dependencies {
// For rendering the index page. // For rendering the index page.
compile "org.jetbrains.kotlinx:kotlinx-html-jvm:0.6.3" compile "org.jetbrains.kotlinx:kotlinx-html-jvm:0.6.3"
testCompile project(':test-utils')
testCompile "junit:junit:$junit_version" testCompile "junit:junit:$junit_version"
} }

View File

@ -3,16 +3,17 @@ package net.corda.webserver
import com.google.common.net.HostAndPort import com.google.common.net.HostAndPort
import net.corda.core.getOrThrow import net.corda.core.getOrThrow
import net.corda.core.utilities.DUMMY_BANK_A import net.corda.core.utilities.DUMMY_BANK_A
import net.corda.node.driver.WebserverHandle import net.corda.testing.driver.WebserverHandle
import net.corda.node.driver.addressMustBeBound import net.corda.testing.driver.addressMustBeBound
import net.corda.node.driver.addressMustNotBeBound import net.corda.testing.driver.addressMustNotBeBound
import net.corda.node.driver.driver import net.corda.testing.driver.driver
import org.junit.Test import org.junit.Test
import java.util.concurrent.Executors import java.util.concurrent.Executors
import java.util.concurrent.ScheduledExecutorService
class DriverTests { class DriverTests {
companion object { companion object {
val executorService = Executors.newScheduledThreadPool(2) val executorService: ScheduledExecutorService = Executors.newScheduledThreadPool(2)
fun webserverMustBeUp(webserverHandle: WebserverHandle) { fun webserverMustBeUp(webserverHandle: WebserverHandle) {
addressMustBeBound(executorService, webserverHandle.listenAddress, webserverHandle.process) addressMustBeBound(executorService, webserverHandle.listenAddress, webserverHandle.process)