diff --git a/doorman/src/test/kotlin/com/r3/corda/doorman/DoormanParametersTest.kt b/doorman/src/test/kotlin/com/r3/corda/doorman/DoormanParametersTest.kt index 132759747f..70fe824aab 100644 --- a/doorman/src/test/kotlin/com/r3/corda/doorman/DoormanParametersTest.kt +++ b/doorman/src/test/kotlin/com/r3/corda/doorman/DoormanParametersTest.kt @@ -1,24 +1,32 @@ package com.r3.corda.doorman +import com.typesafe.config.ConfigException import org.junit.Test import java.io.File import kotlin.test.assertEquals +import kotlin.test.assertFailsWith class DoormanParametersTest { - private val testDummyPath = ".${File.separator}testDummyPath.jks" @Test fun `parse arg correctly`() { - val ref = javaClass.getResource("/reference.conf") + val ref = javaClass.getResource("/node.conf") val params = DoormanParameters(arrayOf("--keygen", "--keystorePath", testDummyPath, "--configFile", ref.path)) assertEquals(DoormanParameters.Mode.CA_KEYGEN, params.mode) assertEquals(testDummyPath, params.keystorePath.toString()) - assertEquals(0, params.port) + assertEquals(8080, params.port) val params2 = DoormanParameters(arrayOf("--keystorePath", testDummyPath, "--port", "1000")) assertEquals(DoormanParameters.Mode.DOORMAN, params2.mode) assertEquals(testDummyPath, params2.keystorePath.toString()) assertEquals(1000, params2.port) } + + @Test + fun `should fail when config missing`() { + // dataSourceProperties is missing from node_fail.conf and it should fail when accessed, and shouldn't use default from reference.conf. + val params = DoormanParameters(arrayOf("--keygen", "--keystorePath", testDummyPath, "--configFile", javaClass.getResource("/node_fail.conf").path)) + assertFailsWith { params.dataSourceProperties } + } } diff --git a/doorman/src/test/resources/node.conf b/doorman/src/test/resources/node.conf new file mode 100644 index 0000000000..cab1f1cf81 --- /dev/null +++ b/doorman/src/test/resources/node.conf @@ -0,0 +1,13 @@ +keystorePath = "/opt/doorman/certificates/caKeystore.jks" +keyStorePassword = "password" +caPrivateKeyPassword = "password" +host = "localhost" +port = 8080 +h2port = 0 + +dataSourceProperties { + "dataSourceClassName" = org.h2.jdbcx.JdbcDataSource + "dataSource.url" = "jdbc:h2:file:"${basedir}"/persistence;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=10000;WRITE_DELAY=0;AUTO_SERVER_PORT="${h2port} + "dataSource.user" = sa + "dataSource.password" = "" +} diff --git a/doorman/src/test/resources/node_fail.conf b/doorman/src/test/resources/node_fail.conf new file mode 100644 index 0000000000..0c6e89c3b3 --- /dev/null +++ b/doorman/src/test/resources/node_fail.conf @@ -0,0 +1,6 @@ +keystorePath = "/opt/doorman/certificates/caKeystore.jks" +keyStorePassword = "password" +caPrivateKeyPassword = "password" +host = "localhost" +port = 8080 +h2port = 0