-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for non-repudiation-app option parser
- Loading branch information
1 parent
f3495a2
commit af4c13a
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...nts/non-repudiation-app/src/test/scala/com/daml/nonrepudiation/app/OptionParserSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package com.daml.nonrepudiation.app | ||
|
||
import java.net.InetSocketAddress | ||
|
||
import org.scalatest.OptionValues | ||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.should.Matchers | ||
|
||
final class OptionParserSpec extends AnyFlatSpec with Matchers with OptionValues { | ||
|
||
behavior of "OptionParser" | ||
|
||
it should "parse the expected options" in { | ||
|
||
val options = Array( | ||
"--ledger-host", | ||
"168.10.67.4", | ||
"--ledger-port", | ||
"7890", | ||
"--proxy-host", | ||
"168.10.67.5", | ||
"--proxy-port", | ||
"7891", | ||
"--api-host", | ||
"168.10.67.6", | ||
"--api-port", | ||
"7892", | ||
"--jdbc", | ||
"url=jdbc:postgresql:nr,user=psql,password=secret", | ||
"--database-max-pool-size", | ||
"30", | ||
) | ||
|
||
val expectedConfiguration = | ||
Configuration( | ||
participantAddress = new InetSocketAddress("168.10.67.4", 7890), | ||
proxyAddress = new InetSocketAddress("168.10.67.5", 7891), | ||
apiAddress = new InetSocketAddress("168.10.67.6", 7892), | ||
apiShutdownTimeout = Configuration.Default.apiShutdownTimeout, | ||
databaseJdbcUrl = "jdbc:postgresql:nr", | ||
databaseJdbcUsername = "psql", | ||
databaseJdbcPassword = "secret", | ||
databaseMaxPoolSize = 30, | ||
metricsReportingPeriod = Configuration.Default.metricsReportingPeriod, | ||
) | ||
|
||
OptionParser.parse(options, Configuration.Default).value shouldBe expectedConfiguration | ||
|
||
} | ||
|
||
} |