Minor: auto-format of module: tools, verifier

This commit is contained in:
Mike Hearn 2017-04-11 12:54:17 +02:00
parent cda04b0e7b
commit 4d6d4c167e
55 changed files with 283 additions and 276 deletions

View File

@ -24,8 +24,8 @@ evaluationDependsOn(':tools:explorer:capsule')
mainClassName = 'net.corda.demobench.DemoBench'
applicationDefaultJvmArgs = [
'-Djava.util.logging.config.class=net.corda.demobench.config.LoggingConfig',
'-Dorg.jboss.logging.provider=slf4j'
'-Djava.util.logging.config.class=net.corda.demobench.config.LoggingConfig',
'-Dorg.jboss.logging.provider=slf4j'
]
repositories {
@ -76,9 +76,9 @@ dependencies {
jar {
manifest {
attributes(
'Corda-Version': corda_version,
'Main-Class': mainClassName,
'Class-Path': configurations.compile.collect { it.getName() }.join(' ')
'Corda-Version': corda_version,
'Main-Class': mainClassName,
'Class-Path': configurations.compile.collect { it.getName() }.join(' ')
)
}
}
@ -116,7 +116,7 @@ distributions {
rename 'bank-of-corda-demo-(.*)', 'bank-of-corda.jar'
into 'plugins'
}
}
}
}
}
@ -164,8 +164,8 @@ task javapackage(dependsOn: 'distZip') {
}
ant.taskdef(
resource: 'com/sun/javafx/tools/ant/antlib.xml',
classpath: "$pkg_source:$java_home/../lib/ant-javafx.jar"
resource: 'com/sun/javafx/tools/ant/antlib.xml',
classpath: "$pkg_source:$java_home/../lib/ant-javafx.jar"
)
ant.deploy(nativeBundles: packageType, outdir: pkg_outDir, outfile: 'DemoBench', verbose: 'true') {

View File

@ -1,11 +1,8 @@
package net.corda.demobench.config;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.logging.LogManager;
import java.io.*;
import java.nio.file.*;
import java.util.logging.*;
/**
* Configuration class for JUL / TornadoFX.

View File

@ -1,11 +1,10 @@
package net.corda.demobench
import java.io.InputStreamReader
import java.nio.charset.StandardCharsets.UTF_8
import javafx.scene.image.Image
import net.corda.demobench.views.DemoBenchView
import tornadofx.App
import tornadofx.addStageIcon
import tornadofx.*
import java.io.InputStreamReader
import java.nio.charset.StandardCharsets.UTF_8
/**
* README!

View File

@ -1,11 +1,11 @@
package net.corda.demobench.explorer
import java.io.IOException
import java.util.concurrent.Executors
import net.corda.core.utilities.loggerFor
import net.corda.demobench.readErrorLines
import net.corda.demobench.model.NodeConfig
import net.corda.demobench.model.forceDirectory
import net.corda.demobench.readErrorLines
import java.io.IOException
import java.util.concurrent.Executors
class Explorer internal constructor(private val explorerController: ExplorerController) : AutoCloseable {
private companion object {

View File

@ -1,7 +1,7 @@
package net.corda.demobench.explorer
import net.corda.demobench.model.JVMConfig
import tornadofx.Controller
import tornadofx.*
class ExplorerController : Controller() {

View File

@ -2,9 +2,10 @@ package net.corda.demobench.model
import com.google.common.net.HostAndPort
import com.typesafe.config.Config
import tornadofx.*
import java.io.IOException
import java.nio.file.*
import tornadofx.Controller
import java.nio.file.Files
import java.nio.file.Path
class InstallFactory : Controller() {
@ -21,15 +22,15 @@ class InstallFactory : Controller() {
val tempDir = Files.createTempDirectory(baseDir, ".node")
val nodeConfig = NodeConfig(
tempDir,
config.getString("myLegalName"),
p2pPort,
rpcPort,
config.getString("nearestCity"),
webPort,
h2Port,
extraServices,
config.getObjectList("rpcUsers").map { toUser(it.unwrapped()) }.toList()
tempDir,
config.getString("myLegalName"),
p2pPort,
rpcPort,
config.getString("nearestCity"),
webPort,
h2Port,
extraServices,
config.getObjectList("rpcUsers").map { toUser(it.unwrapped()) }.toList()
)
if (config.hasPath("networkMapService")) {
@ -52,11 +53,11 @@ class InstallFactory : Controller() {
private fun Config.parseExtraServices(path: String): List<String> {
val services = serviceController.services.toSortedSet()
return this.getStringList(path)
.filter { !it.isNullOrEmpty() }
.map { svc ->
require(svc in services, { "Unknown service '$svc'." } )
svc
}.toList()
.filter { !it.isNullOrEmpty() }
.map { svc ->
require(svc in services, { "Unknown service '$svc'." })
svc
}.toList()
}
}

View File

@ -1,11 +1,11 @@
package net.corda.demobench.model
import java.nio.file.Path
import java.nio.file.Paths
import javafx.scene.control.Alert
import javafx.scene.control.Alert.AlertType.ERROR
import javafx.stage.Stage
import tornadofx.Controller
import tornadofx.*
import java.nio.file.Path
import java.nio.file.Paths
class JVMConfig : Controller() {

View File

@ -47,9 +47,10 @@ class NodeConfig(
.withValue("nearestCity", valueFor(nearestCity))
.withValue("extraAdvertisedServiceIds", valueFor(extraServices))
.withFallback(optional("networkMapService", networkMap, {
c, n -> c.withValue("address", addressValueFor(n.p2pPort))
.withValue("legalName", valueFor(n.legalName))
} ))
c, n ->
c.withValue("address", addressValueFor(n.p2pPort))
.withValue("legalName", valueFor(n.legalName))
}))
.withValue("webAddress", addressValueFor(webPort))
.withValue("rpcAddress", addressValueFor(rpcPort))
.withValue("rpcUsers", valueFor(users.map(User::toMap).toList()))
@ -59,7 +60,7 @@ class NodeConfig(
fun toText(): String = toFileConfig().root().render(renderOptions)
fun moveTo(baseDir: Path) = NodeConfig(
baseDir, legalName, p2pPort, rpcPort, nearestCity, webPort, h2Port, extraServices, users, networkMap
baseDir, legalName, p2pPort, rpcPort, nearestCity, webPort, h2Port, extraServices, users, networkMap
)
fun install(plugins: Collection<Path>) {

View File

@ -1,5 +1,8 @@
package net.corda.demobench.model
import net.corda.demobench.plugin.PluginController
import net.corda.demobench.pty.R3Pty
import tornadofx.*
import java.io.IOException
import java.lang.management.ManagementFactory
import java.net.ServerSocket
@ -9,9 +12,6 @@ import java.text.SimpleDateFormat
import java.util.*
import java.util.concurrent.atomic.AtomicInteger
import java.util.logging.Level
import net.corda.demobench.plugin.PluginController
import net.corda.demobench.pty.R3Pty
import tornadofx.Controller
class NodeController(check: atRuntime = ::checkExists) : Controller() {
companion object {
@ -50,14 +50,14 @@ class NodeController(check: atRuntime = ::checkExists) : Controller() {
*/
fun validate(nodeData: NodeData): NodeConfig? {
val config = NodeConfig(
baseDir,
nodeData.legalName.value.trim(),
nodeData.p2pPort.value,
nodeData.rpcPort.value,
nodeData.nearestCity.value.trim(),
nodeData.webPort.value,
nodeData.h2Port.value,
nodeData.extraServices.value
baseDir,
nodeData.legalName.value.trim(),
nodeData.p2pPort.value,
nodeData.rpcPort.value,
nodeData.nearestCity.value.trim(),
nodeData.webPort.value,
nodeData.h2Port.value,
nodeData.extraServices.value
)
if (nodes.putIfAbsent(config.key, config) != null) {

View File

@ -1,9 +1,9 @@
package net.corda.demobench.model
import tornadofx.observable
import javafx.beans.property.SimpleIntegerProperty
import javafx.beans.property.SimpleListProperty
import javafx.beans.property.SimpleStringProperty
import tornadofx.*
class NodeData {

View File

@ -1,6 +1,6 @@
package net.corda.demobench.model
import tornadofx.ItemViewModel
import tornadofx.*
class NodeDataModel : ItemViewModel<NodeData>(NodeData()) {

View File

@ -1,11 +1,11 @@
package net.corda.demobench.model
import tornadofx.*
import java.io.IOException
import java.io.InputStreamReader
import java.net.URL
import java.util.*
import java.util.logging.Level
import tornadofx.Controller
class ServiceController(resourceName: String = "/services.conf") : Controller() {

View File

@ -1,20 +1,21 @@
@file:JvmName("User")
package net.corda.demobench.model
import net.corda.nodeapi.User
import java.util.*
fun User.toMap(): Map<String, Any> = mapOf(
"username" to username,
"password" to password,
"permissions" to permissions
"username" to username,
"password" to password,
"permissions" to permissions
)
@Suppress("UNCHECKED_CAST")
fun toUser(map: Map<String, Any>) = User(
map.getOrElse("username", { "none" }) as String,
map.getOrElse("password", { "none" }) as String,
LinkedHashSet<String>(map.getOrElse("permissions", { emptyList<String>() }) as Collection<String>)
map.getOrElse("username", { "none" }) as String,
map.getOrElse("password", { "none" }) as String,
LinkedHashSet<String>(map.getOrElse("permissions", { emptyList<String>() }) as Collection<String>)
)
fun user(name: String) = User(name, "letmein", setOf("ALL"))

View File

@ -1,13 +1,13 @@
package net.corda.demobench.plugin
import java.io.IOException
import java.nio.file.Files
import java.nio.file.Path
import java.util.stream.Stream
import net.corda.demobench.model.HasPlugins
import net.corda.demobench.model.JVMConfig
import net.corda.demobench.model.NodeConfig
import tornadofx.*
import java.io.IOException
import java.nio.file.Files
import java.nio.file.Path
import java.util.stream.Stream
class PluginController : Controller() {
@ -22,7 +22,7 @@ class PluginController : Controller() {
fun populate(config: NodeConfig) {
// Nodes cannot issue cash unless they contain the "Bank of Corda" plugin.
if (config.isCashIssuer && bankOfCorda.isFile) {
bankOfCorda.copyTo(config.pluginDir.resolve(bankOfCorda.name).toFile(), overwrite=true)
bankOfCorda.copyTo(config.pluginDir.resolve(bankOfCorda.name).toFile(), overwrite = true)
log.info("Installed 'Bank of Corda' plugin")
}
}

View File

@ -2,22 +2,27 @@ package net.corda.demobench.profile
import com.typesafe.config.Config
import com.typesafe.config.ConfigFactory
import javafx.stage.FileChooser
import javafx.stage.FileChooser.ExtensionFilter
import net.corda.demobench.model.InstallConfig
import net.corda.demobench.model.InstallFactory
import net.corda.demobench.model.JVMConfig
import net.corda.demobench.model.NodeController
import net.corda.demobench.plugin.PluginController
import net.corda.demobench.plugin.inPluginsDir
import net.corda.demobench.plugin.isPlugin
import tornadofx.*
import java.io.File
import java.io.IOException
import java.net.URI
import java.nio.charset.StandardCharsets.UTF_8
import java.nio.file.*
import java.nio.file.FileSystems
import java.nio.file.Files
import java.nio.file.Path
import java.util.*
import java.util.function.BiPredicate
import java.util.logging.Level
import java.util.stream.StreamSupport
import javafx.stage.FileChooser
import javafx.stage.FileChooser.ExtensionFilter
import net.corda.demobench.model.*
import net.corda.demobench.plugin.PluginController
import net.corda.demobench.plugin.inPluginsDir
import net.corda.demobench.plugin.isPlugin
import tornadofx.Controller
class ProfileController : Controller() {
@ -93,40 +98,40 @@ class ProfileController : Controller() {
FileSystems.newFileSystem(chosen.toPath(), null).use { fs ->
// Identify the nodes first...
StreamSupport.stream(fs.rootDirectories.spliterator(), false)
.flatMap { Files.find(it, 2, BiPredicate { p, attr -> "node.conf" == p?.fileName.toString() && attr.isRegularFile }) }
.map { file ->
try {
val config = installFactory.toInstallConfig(parse(file), baseDir)
log.info("Loaded: $file")
config
} catch (e: Exception) {
log.log(Level.SEVERE, "Failed to parse '$file': ${e.message}", e)
throw e
}
// Java seems to "walk" through the ZIP file backwards.
// So add new config to the front of the list, so that
// our final list is ordered to match the file.
}.forEach { configs.addFirst(it) }
.flatMap { Files.find(it, 2, BiPredicate { p, attr -> "node.conf" == p?.fileName.toString() && attr.isRegularFile }) }
.map { file ->
try {
val config = installFactory.toInstallConfig(parse(file), baseDir)
log.info("Loaded: $file")
config
} catch (e: Exception) {
log.log(Level.SEVERE, "Failed to parse '$file': ${e.message}", e)
throw e
}
// Java seems to "walk" through the ZIP file backwards.
// So add new config to the front of the list, so that
// our final list is ordered to match the file.
}.forEach { configs.addFirst(it) }
val nodeIndex = configs.map { it.key to it }.toMap()
// Now extract all of the plugins from the ZIP file,
// and copy them to a temporary location.
StreamSupport.stream(fs.rootDirectories.spliterator(), false)
.flatMap { Files.find(it, 3, BiPredicate { p, attr -> p.inPluginsDir() && p.isPlugin() && attr.isRegularFile }) }
.forEach { plugin ->
val config = nodeIndex[plugin.getName(0).toString()] ?: return@forEach
.flatMap { Files.find(it, 3, BiPredicate { p, attr -> p.inPluginsDir() && p.isPlugin() && attr.isRegularFile }) }
.forEach { plugin ->
val config = nodeIndex[plugin.getName(0).toString()] ?: return@forEach
try {
val pluginDir = Files.createDirectories(config.pluginDir)
Files.copy(plugin, pluginDir.resolve(plugin.fileName.toString()))
log.info("Loaded: $plugin")
} catch (e: Exception) {
log.log(Level.SEVERE, "Failed to extract '$plugin': ${e.message}", e)
configs.forEach { c -> c.deleteBaseDir() }
throw e
try {
val pluginDir = Files.createDirectories(config.pluginDir)
Files.copy(plugin, pluginDir.resolve(plugin.fileName.toString()))
log.info("Loaded: $plugin")
} catch (e: Exception) {
log.log(Level.SEVERE, "Failed to extract '$plugin': ${e.message}", e)
configs.forEach { c -> c.deleteBaseDir() }
throw e
}
}
}
}
return configs

View File

@ -11,9 +11,9 @@ import java.nio.charset.Charset
* @author traff
*/
class PtyProcessTtyConnector(
private val name: String,
private val process: PtyProcess,
charset: Charset
private val name: String,
private val process: PtyProcess,
charset: Charset
) : ProcessTtyConnector(process.zeroFiltered(), charset) {
override fun getName() = name
@ -23,10 +23,10 @@ class PtyProcessTtyConnector(
override fun resizeImmediately() {
if (pendingTermSize != null && pendingPixelSize != null) {
process.winSize = WinSize(
pendingTermSize.width,
pendingTermSize.height,
pendingPixelSize.width,
pendingPixelSize.height
pendingTermSize.width,
pendingTermSize.height,
pendingPixelSize.width,
pendingPixelSize.height
)
}
}

View File

@ -1,11 +1,11 @@
package net.corda.demobench.pty
import com.jediterm.terminal.ui.*
import com.jediterm.terminal.ui.JediTermWidget
import com.jediterm.terminal.ui.UIUtil
import com.jediterm.terminal.ui.settings.SettingsProvider
import com.pty4j.PtyProcess
import net.corda.core.utilities.loggerFor
import java.awt.*
import java.awt.Dimension
import java.io.IOException
import java.nio.charset.StandardCharsets.UTF_8
import java.util.concurrent.Executors

View File

@ -1,14 +1,14 @@
package net.corda.demobench.rpc
import com.google.common.net.HostAndPort
import java.util.*
import java.util.concurrent.TimeUnit.SECONDS
import net.corda.client.rpc.CordaRPCClient
import net.corda.core.messaging.CordaRPCOps
import net.corda.core.utilities.loggerFor
import net.corda.demobench.model.NodeConfig
import java.util.*
import java.util.concurrent.TimeUnit.SECONDS
class NodeRPC(config: NodeConfig, start: () -> Unit, invoke: (CordaRPCOps) -> Unit): AutoCloseable {
class NodeRPC(config: NodeConfig, start: () -> Unit, invoke: (CordaRPCOps) -> Unit) : AutoCloseable {
private companion object {
val log = loggerFor<NodeRPC>()
@ -33,7 +33,7 @@ class NodeRPC(config: NodeConfig, start: () -> Unit, invoke: (CordaRPCOps) -> Un
start()
// Schedule a new task that will refresh the display once per second.
timer.schedule(object: TimerTask() {
timer.schedule(object : TimerTask() {
override fun run() {
invoke(ops)
}

View File

@ -8,7 +8,7 @@ class PropertyLabel() : HBox() {
val nameLabel = Label()
val valueLabel = Label()
var name : String
var name: String
get() = nameLabel.text
set(value) {
nameLabel.text = value

View File

@ -1,6 +1,5 @@
package net.corda.demobench.views
import java.util.*
import javafx.application.Platform
import javafx.scene.Parent
import javafx.scene.control.Button
@ -13,6 +12,7 @@ import net.corda.demobench.profile.ProfileController
import net.corda.demobench.ui.CloseableTab
import org.controlsfx.dialog.ExceptionDialog
import tornadofx.*
import java.util.*
class DemoBenchView : View("Corda DemoBench") {

View File

@ -1,8 +1,5 @@
package net.corda.demobench.views
import java.nio.file.Path
import java.text.DecimalFormat
import java.util.*
import javafx.application.Platform
import javafx.scene.control.SelectionMode.MULTIPLE
import javafx.scene.input.KeyCode
@ -12,6 +9,9 @@ import javafx.util.converter.NumberStringConverter
import net.corda.demobench.model.*
import net.corda.demobench.ui.CloseableTab
import tornadofx.*
import java.nio.file.Path
import java.text.DecimalFormat
import java.util.*
class NodeTabView : Fragment() {
override val root = stackpane {}

View File

@ -3,9 +3,6 @@ package net.corda.demobench.views
import com.jediterm.terminal.TerminalColor
import com.jediterm.terminal.TextStyle
import com.jediterm.terminal.ui.settings.DefaultSettingsProvider
import java.awt.Dimension
import java.util.logging.Level
import javax.swing.SwingUtilities
import javafx.application.Platform
import javafx.embed.swing.SwingNode
import javafx.scene.control.Button
@ -13,13 +10,18 @@ import javafx.scene.control.Label
import javafx.scene.layout.VBox
import net.corda.client.rpc.notUsed
import net.corda.demobench.explorer.ExplorerController
import net.corda.demobench.model.*
import net.corda.demobench.model.NodeConfig
import net.corda.demobench.model.NodeController
import net.corda.demobench.model.NodeState
import net.corda.demobench.pty.R3Pty
import net.corda.demobench.rpc.NodeRPC
import net.corda.demobench.ui.PropertyLabel
import net.corda.demobench.web.DBViewer
import net.corda.demobench.web.WebServerController
import tornadofx.Fragment
import java.awt.Dimension
import java.util.logging.Level
import javax.swing.SwingUtilities
class NodeTerminalView : Fragment() {
override val root by fxml<VBox>()
@ -139,8 +141,8 @@ class NodeTerminalView : Fragment() {
val verifiedTx = ops.verifiedTransactions()
val statesInVault = ops.vaultAndUpdates()
val cashBalances = ops.getCashBalances().entries.joinToString(
separator = ", ",
transform = { e -> e.value.toString() }
separator = ", ",
transform = { e -> e.value.toString() }
)
Platform.runLater {

View File

@ -1,13 +1,13 @@
package net.corda.demobench.web
import net.corda.core.utilities.loggerFor
import java.sql.SQLException
import java.util.concurrent.Executors
import kotlin.reflect.jvm.jvmName
import org.h2.Driver
import org.h2.server.web.LocalWebServer
import org.h2.tools.Server
import org.h2.util.JdbcUtils
import java.sql.SQLException
import java.util.concurrent.Executors
import kotlin.reflect.jvm.jvmName
class DBViewer : AutoCloseable {
private companion object {
@ -40,10 +40,10 @@ class DBViewer : AutoCloseable {
@Throws(SQLException::class)
fun openBrowser(h2Port: Int) {
val conn = JdbcUtils.getConnection(
Driver::class.jvmName,
"jdbc:h2:tcp://localhost:$h2Port/node",
"sa",
""
Driver::class.jvmName,
"jdbc:h2:tcp://localhost:$h2Port/node",
"sa",
""
)
val url = (webServer.service as LocalWebServer).addSession(conn)

View File

@ -1,10 +1,10 @@
package net.corda.demobench.web
import net.corda.core.utilities.loggerFor
import net.corda.demobench.model.NodeConfig
import net.corda.demobench.readErrorLines
import java.io.IOException
import java.util.concurrent.Executors
import net.corda.core.utilities.loggerFor
import net.corda.demobench.readErrorLines
import net.corda.demobench.model.NodeConfig
class WebServer internal constructor(private val webServerController: WebServerController) : AutoCloseable {
private companion object {

View File

@ -1,7 +1,7 @@
package net.corda.demobench.web
import net.corda.demobench.model.JVMConfig
import tornadofx.Controller
import tornadofx.*
class WebServerController : Controller() {

View File

@ -41,7 +41,7 @@
<Loggers>
<Root level="${sys:defaultLogLevel}">
<AppenderRef ref="RollingFile-Appender" />
<AppenderRef ref="RollingFile-Appender"/>
</Root>
</Loggers>
</Configuration>

View File

@ -1,3 +1,3 @@
# Register SLF4JBridgeHandler as handler for the j.u.l. root logger
# See http://www.slf4j.org/legacy.html#jul-to-slf4j
handlers = org.slf4j.bridge.SLF4JBridgeHandler
handlers=org.slf4j.bridge.SLF4JBridgeHandler

View File

@ -4,7 +4,7 @@
*/
.header {
-fx-background-color: #505050;
-fx-background-color: #505050;
-fx-padding: 15px;
}

View File

@ -1,14 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<VBox xmlns="http://javafx.com/javafx/8.0.102" xmlns:fx="http://javafx.com/fxml/1">
<MenuBar useSystemMenuBar="true">
<Menu text="File">
@ -17,10 +11,12 @@
</Menu>
</MenuBar>
<StackPane VBox.vgrow="ALWAYS">
<TabPane fx:id="nodeTabPane" minHeight="444.0" minWidth="800.0" prefHeight="613.0" prefWidth="1231.0" tabClosingPolicy="UNAVAILABLE" tabMinHeight="30.0"/>
<Button fx:id="addNodeButton" mnemonicParsing="false" styleClass="add-node-button" text="Add Node" StackPane.alignment="TOP_RIGHT">
<TabPane fx:id="nodeTabPane" minHeight="444.0" minWidth="800.0" prefHeight="613.0" prefWidth="1231.0"
tabClosingPolicy="UNAVAILABLE" tabMinHeight="30.0"/>
<Button fx:id="addNodeButton" mnemonicParsing="false" styleClass="add-node-button" text="Add Node"
StackPane.alignment="TOP_RIGHT">
<StackPane.margin>
<Insets right="5.0" top="5.0" />
<Insets right="5.0" top="5.0"/>
</StackPane.margin>
</Button>
</StackPane>

View File

@ -1,26 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.VBox?>
<?import net.corda.demobench.ui.PropertyLabel?>
<VBox visible="false" prefHeight="953.0" prefWidth="1363.0" xmlns="http://javafx.com/javafx/8.0.102" xmlns:fx="http://javafx.com/fxml/1">
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import net.corda.demobench.ui.*?>
<VBox visible="false" prefHeight="953.0" prefWidth="1363.0" xmlns="http://javafx.com/javafx/8.0.102"
xmlns:fx="http://javafx.com/fxml/1">
<HBox prefHeight="95.0" prefWidth="800.0" spacing="15.0" styleClass="header">
<VBox prefHeight="66.0" prefWidth="296.0" spacing="20.0">
<Label fx:id="nodeName" style="-fx-font-size: 40; -fx-text-fill: red;" />
<PropertyLabel fx:id="p2pPort" name="P2P port: " />
<Label fx:id="nodeName" style="-fx-font-size: 40; -fx-text-fill: red;"/>
<PropertyLabel fx:id="p2pPort" name="P2P port: "/>
</VBox>
<VBox prefHeight="93.0" prefWidth="267.0">
<PropertyLabel fx:id="states" name="States in vault: " />
<PropertyLabel fx:id="transactions" name="Known transactions: " />
<PropertyLabel fx:id="balance" name="Balance: " />
<PropertyLabel fx:id="states" name="States in vault: "/>
<PropertyLabel fx:id="transactions" name="Known transactions: "/>
<PropertyLabel fx:id="balance" name="Balance: "/>
</VBox>
<Pane prefHeight="200.0" prefWidth="200.0" HBox.hgrow="ALWAYS" />
<Button fx:id="viewDatabaseButton" disable="true" mnemonicParsing="false" prefHeight="92.0" prefWidth="115.0" styleClass="big-button" text="View&#10;Database" textAlignment="CENTER" />
<Button fx:id="launchWebButton" disable="true" mnemonicParsing="false" prefHeight="92.0" prefWidth="115.0" styleClass="big-button" text="Launch&#10;Web Server" textAlignment="CENTER" />
<Button fx:id="launchExplorerButton" disable="true" mnemonicParsing="false" prefHeight="92.0" prefWidth="115.0" styleClass="big-button" text="Launch&#10;Explorer" textAlignment="CENTER" />
<Pane prefHeight="200.0" prefWidth="200.0" HBox.hgrow="ALWAYS"/>
<Button fx:id="viewDatabaseButton" disable="true" mnemonicParsing="false" prefHeight="92.0" prefWidth="115.0"
styleClass="big-button" text="View&#10;Database" textAlignment="CENTER"/>
<Button fx:id="launchWebButton" disable="true" mnemonicParsing="false" prefHeight="92.0" prefWidth="115.0"
styleClass="big-button" text="Launch&#10;Web Server" textAlignment="CENTER"/>
<Button fx:id="launchExplorerButton" disable="true" mnemonicParsing="false" prefHeight="92.0" prefWidth="115.0"
styleClass="big-button" text="Launch&#10;Explorer" textAlignment="CENTER"/>
</HBox>
</VBox>

View File

@ -13,9 +13,9 @@ import org.junit.runners.Suite
*/
@RunWith(Suite::class)
@Suite.SuiteClasses(
ServiceControllerTest::class,
NodeControllerTest::class,
JVMConfigTest::class
ServiceControllerTest::class,
NodeControllerTest::class,
JVMConfigTest::class
)
class LoggingTestSuite {

View File

@ -1,11 +1,12 @@
package net.corda.demobench.model
import com.jediterm.terminal.ui.UIUtil
import org.junit.Test
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import kotlin.test.*
import org.junit.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
class JVMConfigTest {
@ -13,7 +14,7 @@ class JVMConfigTest {
@Test
fun `test Java path`() {
assertTrue(Files.isExecutable(jvm.javaPath.onFileSystem()))
assertTrue(Files.isExecutable(jvm.javaPath.onFileSystem()))
}
@Test
@ -41,7 +42,7 @@ class JVMConfigTest {
}
private fun Path.onFileSystem(): Path
= if (UIUtil.isWindows) this.parent.resolve(Paths.get(this.fileName.toString() + ".exe"))
else this
= if (UIUtil.isWindows) this.parent.resolve(Paths.get(this.fileName.toString() + ".exe"))
else this
}

View File

@ -1,7 +1,7 @@
package net.corda.demobench.model
import kotlin.test.*
import org.junit.Test
import kotlin.test.assertEquals
class NetworkMapConfigTest {

View File

@ -31,19 +31,19 @@ class NodeConfigTest {
@Test
fun `test node directory`() {
val config = createConfig(legalName = "My Name")
assertEquals(baseDir/"myname", config.nodeDir)
assertEquals(baseDir / "myname", config.nodeDir)
}
@Test
fun `test explorer directory`() {
val config = createConfig(legalName = "My Name")
assertEquals(baseDir/"myname-explorer", config.explorerDir)
assertEquals(baseDir / "myname-explorer", config.explorerDir)
}
@Test
fun `test plugin directory`() {
val config = createConfig(legalName = "My Name")
assertEquals(baseDir/"myname"/"plugins", config.pluginDir)
assertEquals(baseDir / "myname" / "plugins", config.pluginDir)
}
@Test
@ -116,71 +116,71 @@ class NodeConfigTest {
@Test
fun `test config text`() {
val config = createConfig(
legalName = "My Name",
nearestCity = "Stockholm",
p2pPort = 10001,
rpcPort = 40002,
webPort = 20001,
h2Port = 30001,
services = listOf("my.service"),
users = listOf(user("jenny"))
legalName = "My Name",
nearestCity = "Stockholm",
p2pPort = 10001,
rpcPort = 40002,
webPort = 20001,
h2Port = 30001,
services = listOf("my.service"),
users = listOf(user("jenny"))
)
assertEquals("{"
+ "\"extraAdvertisedServiceIds\":[\"my.service\"],"
+ "\"h2port\":30001,"
+ "\"myLegalName\":\"MyName\","
+ "\"nearestCity\":\"Stockholm\","
+ "\"p2pAddress\":\"localhost:10001\","
+ "\"rpcAddress\":\"localhost:40002\","
+ "\"rpcUsers\":["
+ "{\"password\":\"letmein\",\"permissions\":[\"ALL\"],\"username\":\"jenny\"}"
+ "],"
+ "\"useTestClock\":true,"
+ "\"webAddress\":\"localhost:20001\""
+ "\"extraAdvertisedServiceIds\":[\"my.service\"],"
+ "\"h2port\":30001,"
+ "\"myLegalName\":\"MyName\","
+ "\"nearestCity\":\"Stockholm\","
+ "\"p2pAddress\":\"localhost:10001\","
+ "\"rpcAddress\":\"localhost:40002\","
+ "\"rpcUsers\":["
+ "{\"password\":\"letmein\",\"permissions\":[\"ALL\"],\"username\":\"jenny\"}"
+ "],"
+ "\"useTestClock\":true,"
+ "\"webAddress\":\"localhost:20001\""
+ "}", config.toText().stripWhitespace())
}
@Test
fun `test config text with network map`() {
val config = createConfig(
legalName = "My Name",
nearestCity = "Stockholm",
p2pPort = 10001,
rpcPort = 40002,
webPort = 20001,
h2Port = 30001,
services = listOf("my.service"),
users = listOf(user("jenny"))
legalName = "My Name",
nearestCity = "Stockholm",
p2pPort = 10001,
rpcPort = 40002,
webPort = 20001,
h2Port = 30001,
services = listOf("my.service"),
users = listOf(user("jenny"))
)
config.networkMap = NetworkMapConfig("Notary", 12345)
assertEquals("{"
+ "\"extraAdvertisedServiceIds\":[\"my.service\"],"
+ "\"h2port\":30001,"
+ "\"myLegalName\":\"MyName\","
+ "\"nearestCity\":\"Stockholm\","
+ "\"networkMapService\":{\"address\":\"localhost:12345\",\"legalName\":\"Notary\"},"
+ "\"p2pAddress\":\"localhost:10001\","
+ "\"rpcAddress\":\"localhost:40002\","
+ "\"rpcUsers\":["
+ "{\"password\":\"letmein\",\"permissions\":[\"ALL\"],\"username\":\"jenny\"}"
+ "],"
+ "\"useTestClock\":true,"
+ "\"webAddress\":\"localhost:20001\""
+ "\"extraAdvertisedServiceIds\":[\"my.service\"],"
+ "\"h2port\":30001,"
+ "\"myLegalName\":\"MyName\","
+ "\"nearestCity\":\"Stockholm\","
+ "\"networkMapService\":{\"address\":\"localhost:12345\",\"legalName\":\"Notary\"},"
+ "\"p2pAddress\":\"localhost:10001\","
+ "\"rpcAddress\":\"localhost:40002\","
+ "\"rpcUsers\":["
+ "{\"password\":\"letmein\",\"permissions\":[\"ALL\"],\"username\":\"jenny\"}"
+ "],"
+ "\"useTestClock\":true,"
+ "\"webAddress\":\"localhost:20001\""
+ "}", config.toText().stripWhitespace())
}
@Test
fun `reading node configuration`() {
val config = createConfig(
legalName = "My Name",
nearestCity = "Stockholm",
p2pPort = 10001,
rpcPort = 40002,
webPort = 20001,
h2Port = 30001,
services = listOf("my.service"),
users = listOf(user("jenny"))
legalName = "My Name",
nearestCity = "Stockholm",
p2pPort = 10001,
rpcPort = 40002,
webPort = 20001,
h2Port = 30001,
services = listOf("my.service"),
users = listOf(user("jenny"))
)
config.networkMap = NetworkMapConfig("Notary", 12345)
@ -231,11 +231,11 @@ class NodeConfigTest {
fun `test moving`() {
val config = createConfig(legalName = "My Name")
val elsewhere = baseDir/"elsewhere"
val elsewhere = baseDir / "elsewhere"
val moved = config.moveTo(elsewhere)
assertEquals(elsewhere/"myname", moved.nodeDir)
assertEquals(elsewhere/"myname-explorer", moved.explorerDir)
assertEquals(elsewhere/"myname"/"plugins", moved.pluginDir)
assertEquals(elsewhere / "myname", moved.nodeDir)
assertEquals(elsewhere / "myname-explorer", moved.explorerDir)
assertEquals(elsewhere / "myname" / "plugins", moved.pluginDir)
}
private fun createConfig(

View File

@ -1,15 +1,15 @@
package net.corda.demobench.model
import net.corda.nodeapi.User
import org.junit.Test
import java.nio.file.Path
import java.nio.file.Paths
import kotlin.test.*
import org.junit.Test
class NodeControllerTest {
private val baseDir: Path = Paths.get(".").toAbsolutePath()
private val controller = NodeController({_,_ ->})
private val controller = NodeController({ _, _ -> })
@Test
fun `test unique nodes after validate`() {

View File

@ -1,7 +1,9 @@
package net.corda.demobench.model
import kotlin.test.*
import org.junit.Test
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
import kotlin.test.assertTrue
class ServiceControllerTest {

View File

@ -17,9 +17,9 @@ class UserTest {
@Test
fun createFromMap() {
val map = mapOf(
"username" to "MyName",
"password" to "MyPassword",
"permissions" to listOf("Flow.MyFlow")
"username" to "MyName",
"password" to "MyPassword",
"permissions" to listOf("Flow.MyFlow")
)
val user = toUser(map)
assertEquals("MyName", user.username)

View File

@ -3,7 +3,7 @@
<Appenders>
<Console name="Console-Appender" target="SYSTEM_OUT">
<PatternLayout pattern="%date %highlight{%level %c{1}.%M - %msg%n}{INFO=white,WARN=red,FATAL=bright red}" />
<PatternLayout pattern="%date %highlight{%level %c{1}.%M - %msg%n}{INFO=white,WARN=red,FATAL=bright red}"/>
</Console>
</Appenders>

View File

@ -1,7 +1,6 @@
import java.io.File;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.io.*;
import java.nio.file.*;
import java.util.*;
public class ExplorerCaplet extends Capsule {

View File

@ -12,12 +12,12 @@ val Positivity.sign: String get() = when (this) {
Positivity.Negative -> "-"
}
data class AmountDiff<T: Any>(
data class AmountDiff<T : Any>(
val positivity: Positivity,
val amount: Amount<T>
) {
companion object {
fun <T: Any> fromLong(quantity: Long, token: T) =
fun <T : Any> fromLong(quantity: Long, token: T) =
AmountDiff(
positivity = if (quantity < 0) Positivity.Negative else Positivity.Positive,
amount = Amount(Math.abs(quantity), token)

View File

@ -4,9 +4,7 @@ import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon
import javafx.beans.property.SimpleObjectProperty
import javafx.collections.ObservableList
import javafx.scene.Node
import tornadofx.View
import tornadofx.find
import tornadofx.observable
import tornadofx.*
class CordaViewModel {
val selectedView = SimpleObjectProperty<CordaView>()

View File

@ -1,14 +1,14 @@
package net.corda.explorer.model
import javafx.collections.ObservableList
import net.corda.client.jfx.utils.ChosenList
import net.corda.client.jfx.utils.map
import net.corda.client.jfx.model.NetworkIdentityModel
import net.corda.client.jfx.model.observableList
import net.corda.client.jfx.model.observableValue
import net.corda.client.jfx.utils.ChosenList
import net.corda.client.jfx.utils.map
import net.corda.core.contracts.currency
import net.corda.core.node.NodeInfo
import tornadofx.observable
import tornadofx.*
val ISSUER_SERVICE_TYPE = Regex("corda.issuer.(USD|GBP|CHF)")

View File

@ -1,16 +1,16 @@
package net.corda.explorer.model
import javafx.beans.value.ObservableValue
import net.corda.client.jfx.utils.AmountBindings
import net.corda.client.jfx.model.ExchangeRate
import net.corda.client.jfx.model.ExchangeRateModel
import net.corda.client.jfx.model.observableValue
import net.corda.client.jfx.utils.AmountBindings
import net.corda.core.contracts.Amount
import net.corda.core.contracts.CHF
import net.corda.core.contracts.GBP
import net.corda.core.contracts.USD
import org.fxmisc.easybind.EasyBind
import tornadofx.observable
import tornadofx.*
import java.util.*
class ReportingCurrencyModel {

View File

@ -8,7 +8,7 @@ import net.corda.core.contracts.currency
import net.corda.core.createDirectories
import net.corda.core.div
import net.corda.core.exists
import tornadofx.Component
import tornadofx.*
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths

View File

@ -1,16 +1,16 @@
package net.corda.explorer.plugin
import net.corda.flows.IssuerFlow
import net.corda.core.contracts.Amount
import net.corda.core.crypto.Party
import net.corda.core.node.CordaPluginRegistry
import net.corda.core.serialization.OpaqueBytes
import net.corda.flows.IssuerFlow
import java.util.function.Function
class ExplorerPlugin : CordaPluginRegistry() {
// A list of flow that are required for this cordapp
override val requiredFlows: Map<String, Set<String>> =
mapOf(IssuerFlow.IssuanceRequester::class.java.name to setOf(Amount::class.java.name, Party::class.java.name, OpaqueBytes::class.java.name, Party::class.java.name)
)
mapOf(IssuerFlow.IssuanceRequester::class.java.name to setOf(Amount::class.java.name, Party::class.java.name, OpaqueBytes::class.java.name, Party::class.java.name)
)
override val servicePlugins = listOf(Function(IssuerFlow.Issuer::Service))
}

View File

@ -90,4 +90,5 @@ fun <A, B> Collection<A>.cross(other: Collection<B>) = this.flatMap { a -> other
// TODO: This is a temporary fix for the UI to show the correct issuer identity, this will break when we start randomizing keys. More work is needed here when the identity work is done.
fun StateAndRef<Cash.State>.resolveIssuer(): ObservableValue<Party?> = state.data.amount.token.issuer.party.resolveIssuer()
fun AnonymousParty.resolveIssuer(): ObservableValue<Party?> = Models.get(NetworkIdentityModel::class, javaClass.kotlin).lookup(owningKey).map { it?.legalIdentity }

View File

@ -16,8 +16,7 @@ import javafx.scene.input.MouseButton
import javafx.scene.input.MouseEvent
import net.corda.client.jfx.utils.ChosenList
import net.corda.client.jfx.utils.map
import tornadofx.UIComponent
import tornadofx.observable
import tornadofx.*
/**
* Generic search bar filters [ObservableList] with provided filterCriteria.

View File

@ -46,7 +46,7 @@ class TransactionViewer : CordaView("Transactions") {
private val transactionViewTable by fxid<TableView<Transaction>>()
private val matchingTransactionsLabel by fxid<Label>()
// Inject data
private val transactions by observableListReadOnly(TransactionDataModel::partiallyResolvedTransactions)
private val transactions by observableListReadOnly(TransactionDataModel::partiallyResolvedTransactions)
private val reportingExchange by observableValue(ReportingCurrencyModel::reportingExchange)
private val reportingCurrency by observableValue(ReportingCurrencyModel::reportingCurrency)
private val myIdentity by observableValue(NetworkIdentityModel::myIdentity)
@ -157,7 +157,7 @@ class TransactionViewer : CordaView("Transactions") {
private fun ObservableList<StateAndRef<ContractState>>.toText() = map { it.contract().javaClass.simpleName }.groupBy { it }.map { "${it.key} (${it.value.size})" }.joinToString()
private class TransactionWidget() : BorderPane() {
private val partiallyResolvedTransactions by observableListReadOnly(TransactionDataModel::partiallyResolvedTransactions)
private val partiallyResolvedTransactions by observableListReadOnly(TransactionDataModel::partiallyResolvedTransactions)
// TODO : Add a scrolling table to show latest transaction.
// TODO : Add a chart to show types of transactions.

View File

@ -158,15 +158,15 @@
-fx-background-color: -color-4;
}
.certificateButton.button, .certificateButton.button:hover{
.certificateButton.button, .certificateButton.button:hover {
-fx-background-color: transparent;
}
.certificateIcon{
.certificateIcon {
-fx-fill: -color-2;
}
.certificateIcon:hover{
.certificateIcon:hover {
-fx-fill: -color-3;
}
@ -253,6 +253,7 @@
#setting-edit-label:hover .text, #setting-edit-label:hover .glyph-icon {
-fx-fill: -color-4;
}
/* Styles for firing bullets between nodes in Network view. */
.bullet {
-fx-fill: black;

View File

@ -1,10 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView?>
<DialogPane styleClass="login" stylesheets="@../css/corda.css" xmlns="http://javafx.com/javafx/8.0.112-ea"
xmlns:fx="http://javafx.com/fxml/1">
<padding>

View File

@ -30,7 +30,7 @@ dependencies {
}
run {
if (project.hasProperty('loadtest-config') ) {
args project["loadtest-config"]
}
if (project.hasProperty('loadtest-config')) {
args project["loadtest-config"]
}
}

View File

@ -5,7 +5,6 @@ import com.jcraft.jsch.*
import com.jcraft.jsch.agentproxy.AgentProxy
import com.jcraft.jsch.agentproxy.connector.SSHAgentConnector
import com.jcraft.jsch.agentproxy.usocket.JNAUSocketFactory
import kotlin.streams.toList
import net.corda.client.rpc.CordaRPCClient
import net.corda.core.messaging.CordaRPCOps
import net.corda.node.driver.PortAllocation
@ -13,6 +12,7 @@ import org.slf4j.LoggerFactory
import java.io.ByteArrayOutputStream
import java.io.Closeable
import java.util.*
import kotlin.streams.toList
private val log = LoggerFactory.getLogger(ConnectionManager::class.java)

View File

@ -1,7 +1,6 @@
package net.corda.loadtest
import net.corda.client.mock.Generator
import net.corda.core.div
import net.corda.node.driver.PortAllocation
import net.corda.node.services.network.NetworkMapService
import net.corda.node.services.transactions.ValidatingNotaryService

View File

@ -214,6 +214,7 @@ fun commandGenerator(partiesToPickFrom: Collection<Party>): Generator<Pair<Comma
)
}
}
val partyGenerator: Generator<Party> = Generator.int().combine(publicKeyGenerator) { n, key -> Party("Party$n", key) }
fun <A> pickOneOrMaybeNew(from: Collection<A>, generator: Generator<A>): Generator<A> {

View File

@ -44,17 +44,21 @@ import java.util.concurrent.atomic.AtomicInteger
interface VerifierExposedDSLInterface : DriverDSLExposedInterface {
/** Starts a lightweight verification requestor that implements the Node's Verifier API */
fun startVerificationRequestor(name: String): ListenableFuture<VerificationRequestorHandle>
/** Starts an out of process verifier connected to [address] */
fun startVerifier(address: HostAndPort): ListenableFuture<VerifierHandle>
/**
* Waits until [number] verifiers are listening for verification requests coming from the Node. Check
* [VerificationRequestorHandle.waitUntilNumberOfVerifiers] for an equivalent for requestors.
*/
fun NodeHandle.waitUntilNumberOfVerifiers(number: Int)
}
/** Starts a verifier connecting to the specified node */
fun VerifierExposedDSLInterface.startVerifier(nodeHandle: NodeHandle) =
startVerifier(nodeHandle.configuration.p2pAddress)
/** Starts a verifier connecting to the specified requestor */
fun VerifierExposedDSLInterface.startVerifier(verificationRequestorHandle: VerificationRequestorHandle) =
startVerifier(verificationRequestorHandle.p2pAddress)
@ -190,6 +194,7 @@ data class VerifierDriverDSL(
val securityManager = object : ActiveMQSecurityManager {
// We don't need auth, SSL is good enough
override fun validateUser(user: String?, password: String?) = true
override fun validateUserAndRole(user: String?, password: String?, roles: MutableSet<Role>?, checkType: CheckType?) = true
}