Merge remote-tracking branch 'open/master' into os-merge-20180722

# Conflicts:
#	CONTRIBUTORS.md
#	constants.properties
#	docs/source/aws-vm-explore.rst
#	docs/source/azure-vm-explore.rst
#	docs/source/corda-networks-index.rst
#	docs/source/gcp-vm.rst
#	docs/source/getting-set-up.rst
#	docs/source/node-database.rst
#	finance/src/main/kotlin/net/corda/finance/contracts/asset/cash/selection/CashSelectionSQLServerImpl.kt
#	finance/src/main/resources/META-INF/services/net.corda.finance.contracts.asset.cash.selection.AbstractCashSelection
#	node/src/main/kotlin/net/corda/node/services/vault/NodeVaultService.kt
#	node/src/test/kotlin/net/corda/node/services/config/NodeConfigurationImplTest.kt
This commit is contained in:
Anthony Keenan
2018-07-22 23:06:43 +01:00
177 changed files with 359 additions and 9951 deletions

View File

@ -131,7 +131,7 @@ private fun Config.getSingleValue(path: String, type: KType, onUnknownKeys: (Set
Int::class -> getInt(path)
Long::class -> getLong(path)
Double::class -> getDouble(path)
Boolean::class -> getBoolean(path)
Boolean::class -> getBooleanCaseInsensitive(path)
LocalDate::class -> LocalDate.parse(getString(path))
Duration::class -> getDuration(path)
Instant::class -> Instant.parse(getString(path))
@ -286,6 +286,19 @@ private fun Iterable<*>.toConfigIterable(field: Field): Iterable<Any?> {
}
}
// The typesafe .getBoolean function is case sensitive, this is a case insensitive version
fun Config.getBooleanCaseInsensitive(path: String): Boolean {
try {
return getBoolean(path)
} catch(e:Exception) {
val stringVal = getString(path).toLowerCase()
if (stringVal == "true" || stringVal == "false") {
return stringVal.toBoolean()
}
throw e
}
}
private val logger = LoggerFactory.getLogger("net.corda.nodeapi.internal.config")
enum class UnknownConfigKeysPolicy(private val handle: (Set<String>, logger: Logger) -> Unit) {

View File

@ -31,6 +31,7 @@ import net.corda.core.utilities.days
import net.corda.core.utilities.getOrThrow
import net.corda.core.utilities.seconds
import net.corda.nodeapi.internal.*
import net.corda.nodeapi.internal.config.getBooleanCaseInsensitive
import net.corda.nodeapi.internal.network.NodeInfoFilesCopier.Companion.NODE_INFO_FILE_NAME_PREFIX
import net.corda.serialization.internal.AMQP_P2P_CONTEXT
import net.corda.serialization.internal.CordaSerializationMagic
@ -299,7 +300,7 @@ class NetworkBootstrapper
// The config contains the notary type
val nodeConfig = configs[nodeInfoFile.parent]!!
if (nodeConfig.hasPath("notary")) {
val validating = nodeConfig.getBoolean("notary.validating")
val validating = nodeConfig.getBooleanCaseInsensitive("notary.validating")
// And the node-info file contains the notary's identity
val nodeInfo = nodeInfoFile.readObject<SignedNodeInfo>().verified()
NotaryInfo(nodeInfo.notaryIdentity(), validating)

View File

@ -11,6 +11,7 @@
package net.corda.nodeapi.internal.config
import com.typesafe.config.Config
import com.typesafe.config.ConfigException
import com.typesafe.config.ConfigFactory.empty
import com.typesafe.config.ConfigRenderOptions.defaults
import com.typesafe.config.ConfigValueFactory
@ -18,6 +19,7 @@ import net.corda.core.identity.CordaX500Name
import net.corda.core.internal.div
import net.corda.core.utilities.NetworkHostAndPort
import org.assertj.core.api.Assertions.*
import org.hibernate.exception.DataException
import org.junit.Test
import java.net.URL
import java.nio.file.Path
@ -51,8 +53,16 @@ class ConfigParsingTest {
@Test
fun Boolean() {
testPropertyType<BooleanData, BooleanListData, Boolean>(true, false)
assertThat(config(Pair("value", "false")).parseAs<BooleanData>().value).isEqualTo(false)
assertThat(config(Pair("value", "False")).parseAs<BooleanData>().value).isEqualTo(false)
assertThat(config(Pair("value", "FALSE")).parseAs<BooleanData>().value).isEqualTo(false)
assertThat(config(Pair("value", "true")).parseAs<BooleanData>().value).isEqualTo(true)
assertThat(config(Pair("value", "True")).parseAs<BooleanData>().value).isEqualTo(true)
assertThat(config(Pair("value", "TRUE")).parseAs<BooleanData>().value).isEqualTo(true)
assertThatThrownBy { config(Pair("value", "stilton")).parseAs<BooleanData>().value }
.isInstanceOf(ConfigException.WrongType::class.java)
.hasMessageContaining("hardcoded value: value has type STRING rather than BOOLEAN")
}
@Test
fun Enum() {
testPropertyType<EnumData, EnumListData, TestEnum>(TestEnum.Value2, TestEnum.Value1, valuesToString = true)