address PR issues

This commit is contained in:
Patrick Kuo 2017-03-08 13:47:05 +00:00
parent df74024b22
commit db2840c76a
3 changed files with 30 additions and 3 deletions

View File

@ -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<ConfigException.Missing> { params.dataSourceProperties }
}
}

View File

@ -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" = ""
}

View File

@ -0,0 +1,6 @@
keystorePath = "/opt/doorman/certificates/caKeystore.jks"
keyStorePassword = "password"
caPrivateKeyPassword = "password"
host = "localhost"
port = 8080
h2port = 0