diff --git a/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/CordaRPCClientTest.kt b/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/CordaRPCClientTest.kt index bd51bd3a36..524baa83c3 100644 --- a/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/CordaRPCClientTest.kt +++ b/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/CordaRPCClientTest.kt @@ -35,7 +35,6 @@ import org.junit.After import org.junit.Before import org.junit.Test import rx.subjects.PublishSubject -import java.io.File.pathSeparator import java.net.URLClassLoader import java.nio.file.Paths import java.util.* @@ -231,15 +230,12 @@ class CordaRPCClientTest : NodeBasedTest(listOf("net.corda.finance")) { @Test fun `additional class loader used by WireTransaction when it deserialises its components`() { val financeLocation = Cash::class.java.location.toPath().toString() - val classpathWithoutFinance = ProcessUtilities.defaultClassPath - .split(pathSeparator) - .filter { financeLocation !in it } - .joinToString(pathSeparator) + val classPathWithoutFinance = ProcessUtilities.defaultClassPath.filter { financeLocation !in it } // Create a Cash.State object for the StandaloneCashRpcClient to get node.services.startFlow(CashIssueFlow(100.POUNDS, OpaqueBytes.of(1), identity), InvocationContext.shell()).flatMap { it.resultFuture }.getOrThrow() val outOfProcessRpc = ProcessUtilities.startJavaProcess( - classpath = classpathWithoutFinance, + classPath = classPathWithoutFinance, arguments = listOf(node.internals.configuration.rpcOptions.address.toString(), financeLocation) ) assertThat(outOfProcessRpc.waitFor()).isZero() // i.e. no exceptions were thrown diff --git a/samples/irs-demo/src/integration-test/kotlin/net/corda/irs/IRSDemoTest.kt b/samples/irs-demo/src/integration-test/kotlin/net/corda/irs/IRSDemoTest.kt index 11450c4939..8a90d7a56d 100644 --- a/samples/irs-demo/src/integration-test/kotlin/net/corda/irs/IRSDemoTest.kt +++ b/samples/irs-demo/src/integration-test/kotlin/net/corda/irs/IRSDemoTest.kt @@ -56,20 +56,18 @@ class IRSDemoTest { isDebug = true, extraCordappPackagesToScan = listOf("net.corda.irs") )) { - val (nodeA, nodeB) = listOf( + val (controller, nodeA, nodeB) = listOf( + defaultNotaryNode, startNode(providedName = DUMMY_BANK_A_NAME, rpcUsers = rpcUsers), startNode(providedName = DUMMY_BANK_B_NAME, rpcUsers = rpcUsers), startNode(providedName = CordaX500Name("Regulator", "Moscow", "RU")) ).map { it.getOrThrow() } - val controller = defaultNotaryNode.getOrThrow() log.info("All nodes started") - val controllerAddrFuture = startSpringBootWebapp(IrsDemoWebApplication::class.java, controller, "/api/irs/demodate") - val nodeAAddrFuture = startSpringBootWebapp(IrsDemoWebApplication::class.java, nodeA, "/api/irs/demodate") - val nodeBAddrFuture = startSpringBootWebapp(IrsDemoWebApplication::class.java, nodeB, "/api/irs/demodate") - val (controllerAddr, nodeAAddr, nodeBAddr) = - listOf(controllerAddrFuture, nodeAAddrFuture, nodeBAddrFuture).map { it.getOrThrow().listenAddress } + val (controllerAddr, nodeAAddr, nodeBAddr) = listOf(controller, nodeA, nodeB).map { + startSpringBootWebapp(IrsDemoWebApplication::class.java, it, "/api/irs/demodate") + }.map { it.getOrThrow().listenAddress } log.info("All webservers started") diff --git a/samples/irs-demo/src/integration-test/kotlin/net/corda/test/spring/SpringDriver.kt b/samples/irs-demo/src/integration-test/kotlin/net/corda/test/spring/SpringDriver.kt index a8645bf341..5a20843cc2 100644 --- a/samples/irs-demo/src/integration-test/kotlin/net/corda/test/spring/SpringDriver.kt +++ b/samples/irs-demo/src/integration-test/kotlin/net/corda/test/spring/SpringDriver.kt @@ -74,16 +74,14 @@ data class SpringBootDriverDSL(private val driverDSL: DriverDSLImpl) : InternalD } private fun startApplication(handle: NodeHandle, debugPort: Int?, clazz: Class<*>): Process { - val className = clazz.canonicalName - return ProcessUtilities.startJavaProcessImpl( - className = className, // cannot directly get class for this, so just use string + return ProcessUtilities.startJavaProcess( + className = clazz.canonicalName, // cannot directly get class for this, so just use string jdwpPort = debugPort, extraJvmArguments = listOf( "-Dname=node-${handle.p2pAddress}-webserver", "-Djava.io.tmpdir=${System.getProperty("java.io.tmpdir")}" // Inherit from parent process ), - classpath = ProcessUtilities.defaultClassPath, workingDirectory = handle.baseDirectory, arguments = listOf( "--base-directory", handle.baseDirectory.toString(), @@ -91,8 +89,7 @@ data class SpringBootDriverDSL(private val driverDSL: DriverDSLImpl) : InternalD "--corda.host=${handle.rpcAddress}", "--corda.user=${handle.rpcUsers.first().username}", "--corda.password=${handle.rpcUsers.first().password}" - ), - maximumHeapSize = null + ) ) } -} \ No newline at end of file +} diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/DriverDSLImpl.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/DriverDSLImpl.kt index c024f725a3..39b9b6306c 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/DriverDSLImpl.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/DriverDSLImpl.kt @@ -24,7 +24,6 @@ import net.corda.core.utilities.getOrThrow import net.corda.core.utilities.millis import net.corda.node.NodeRegistrationOption import net.corda.node.VersionInfo -import net.corda.node.internal.ConfigurationException import net.corda.node.internal.Node import net.corda.node.internal.StartedNode import net.corda.node.services.Permissions @@ -838,7 +837,7 @@ class DriverDSLImpl( it += extraCmdLineFlag }.toList() - return ProcessUtilities.startCordaProcess( + return ProcessUtilities.startJavaProcess( className = "net.corda.node.Corda", // cannot directly get class for this, so just use string arguments = arguments, jdwpPort = debugPort, @@ -851,13 +850,12 @@ class DriverDSLImpl( private fun startWebserver(handle: NodeHandleInternal, debugPort: Int?, maximumHeapSize: String): Process { val className = "net.corda.webserver.WebServer" writeConfig(handle.baseDirectory, "web-server.conf", handle.toWebServerConfig()) - return ProcessUtilities.startCordaProcess( + return ProcessUtilities.startJavaProcess( className = className, // cannot directly get class for this, so just use string arguments = listOf("--base-directory", handle.baseDirectory.toString()), jdwpPort = debugPort, extraJvmArguments = listOf("-Dname=node-${handle.p2pAddress}-webserver") + inheritFromParentProcess().map { "-D${it.first}=${it.second}" }, - workingDirectory = null, maximumHeapSize = maximumHeapSize ) } diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/ProcessUtilities.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/ProcessUtilities.kt index 309c3af8b3..50a4961588 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/ProcessUtilities.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/ProcessUtilities.kt @@ -1,40 +1,32 @@ package net.corda.testing.node.internal import net.corda.core.internal.div +import java.io.File import java.nio.file.Path object ProcessUtilities { inline fun startJavaProcess( arguments: List, - classpath: String = defaultClassPath, + classPath: List = defaultClassPath, + workingDirectory: Path? = null, jdwpPort: Int? = null, - extraJvmArguments: List = emptyList() + extraJvmArguments: List = emptyList(), + maximumHeapSize: String? = null ): Process { - return startJavaProcessImpl(C::class.java.name, arguments, classpath, jdwpPort, extraJvmArguments, null, null) + return startJavaProcess(C::class.java.name, arguments, classPath, workingDirectory, jdwpPort, extraJvmArguments, maximumHeapSize) } - fun startCordaProcess( + fun startJavaProcess( className: String, arguments: List, - jdwpPort: Int?, - extraJvmArguments: List, - workingDirectory: Path?, - maximumHeapSize: String - ): Process { - return startJavaProcessImpl(className, arguments, defaultClassPath, jdwpPort, extraJvmArguments, workingDirectory, maximumHeapSize) - } - - fun startJavaProcessImpl( - className: String, - arguments: List, - classpath: String, - jdwpPort: Int?, - extraJvmArguments: List, - workingDirectory: Path?, - maximumHeapSize: String? + classPath: List = defaultClassPath, + workingDirectory: Path? = null, + jdwpPort: Int? = null, + extraJvmArguments: List = emptyList(), + maximumHeapSize: String? = null ): Process { val command = mutableListOf().apply { - add((System.getProperty("java.home") / "bin" / "java").toString()) + add(javaPath) (jdwpPort != null) && add("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=$jdwpPort") if (maximumHeapSize != null) add("-Xmx$maximumHeapSize") add("-XX:+UseG1GC") @@ -44,7 +36,7 @@ object ProcessUtilities { } return ProcessBuilder(command).apply { inheritIO() - environment()["CLASSPATH"] = classpath + environment()["CLASSPATH"] = classPath.joinToString(File.pathSeparator) if (workingDirectory != null) { redirectError((workingDirectory / "$className.stderr.log").toFile()) redirectOutput((workingDirectory / "$className.stdout.log").toFile()) @@ -53,5 +45,7 @@ object ProcessUtilities { }.start() } - val defaultClassPath: String get() = System.getProperty("java.class.path") + private val javaPath = (System.getProperty("java.home") / "bin" / "java").toString() + + val defaultClassPath: List = System.getProperty("java.class.path").split(File.pathSeparator) } \ No newline at end of file