File tree Expand file tree Collapse file tree
guides2/src/main/kotlin/app/cash/tempest2/guides
guides/src/main/kotlin/app/cash/tempest/guides
tempest-testing-junit4/src/main/kotlin/app/cash/tempest/testing
tempest-testing-junit5/src/main/kotlin/app/cash/tempest/testing
tempest2-testing-junit4/src/main/kotlin/app/cash/tempest2/testing
tempest2-testing-junit5/src/main/kotlin/app/cash/tempest2/testing
main/kotlin/app/cash/tempest2/internal
test/kotlin/app/cash/tempest2 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,4 +34,4 @@ class DataModeling(private val db: MusicDb) {
3434 val mapper = DynamoDBMapper (client, mapperConfig)
3535 val db: MusicDb = LogicalDb (mapper)
3636 }
37- }
37+ }
Original file line number Diff line number Diff line change @@ -32,4 +32,4 @@ class AsynchronousProgramming(
3232 .expressionValues(mapOf (" :playlist_version" to AttributeValue .builder().n(" $playlist_version " ).build()))
3333 .build()
3434 }
35- }
35+ }
Original file line number Diff line number Diff line change @@ -29,4 +29,4 @@ class DataModeling(private val db: MusicDb) {
2929 .build()
3030 val db: MusicDb = LogicalDb (enhancedClient)
3131 }
32- }
32+ }
Original file line number Diff line number Diff line change @@ -86,7 +86,9 @@ class QueryNScan(
8686 .expression(" run_length > :duration" )
8787 .expressionValues(
8888 mapOf (
89- " :duration" to AttributeValue .builder().s(duration.toString()).build()))
89+ " :duration" to AttributeValue .builder().s(duration.toString()).build()
90+ )
91+ )
9092 .build()
9193 }
9294
Original file line number Diff line number Diff line change @@ -19,7 +19,8 @@ include(":samples:guides-junit5")
1919include(" :samples:guides2" )
2020include(" :samples:guides2-junit4" )
2121include(" :samples:guides2-junit5" )
22- include(" :samples:javarecord" )
22+ // Don't enable this module, which depends on Java 14.
23+ // include(":samples:javarecord")
2324include(" :samples:musiclibrary" )
2425include(" :samples:musiclibrary2" )
2526include(" :samples:musiclibrary-testing" )
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ class TestDynamoDb private constructor(
7979 }
8080
8181 fun build (): TestDynamoDb {
82- val port = port ? : pickRandomPort( )
82+ val port = port ? : defaultPort(serverFactory.toString() )
8383 return TestDynamoDb (
8484 DefaultTestDynamoDbClient (tables, port),
8585 serverFactory.create(port)
@@ -88,6 +88,12 @@ class TestDynamoDb private constructor(
8888 }
8989
9090 companion object {
91+ private val defaultPorts = ConcurrentHashMap <String , Int >()
92+ fun defaultPort (key : String ): Int {
93+ // Only pick random port once to share one test server with multiple tests.
94+ return defaultPorts.getOrPut(key, ::pickRandomPort)
95+ }
96+
9197 private val runningServers = ConcurrentHashMap .newKeySet<String >()
9298 private val log = getLogger<TestDynamoDb >()
9399 }
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ class TestDynamoDb private constructor(
8181 }
8282
8383 fun build (): TestDynamoDb {
84- val port = port ? : pickRandomPort( )
84+ val port = port ? : defaultPort(serverFactory.toString() )
8585 return TestDynamoDb (
8686 DefaultTestDynamoDbClient (tables, port),
8787 serverFactory.create(port)
@@ -90,6 +90,12 @@ class TestDynamoDb private constructor(
9090 }
9191
9292 companion object {
93+ private val defaultPorts = ConcurrentHashMap <String , Int >()
94+ fun defaultPort (key : String ): Int {
95+ // Only pick random port once to share one test server with multiple tests.
96+ return defaultPorts.getOrPut(key, ::pickRandomPort)
97+ }
98+
9399 private val runningServers = ConcurrentHashMap .newKeySet<String >()
94100 private val log = getLogger<TestDynamoDb >()
95101 }
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ class TestDynamoDb private constructor(
7979 }
8080
8181 fun build (): TestDynamoDb {
82- val port = port ? : pickRandomPort( )
82+ val port = port ? : defaultPort(serverFactory.toString() )
8383 return TestDynamoDb (
8484 DefaultTestDynamoDbClient (tables, port),
8585 serverFactory.create(port)
@@ -88,6 +88,12 @@ class TestDynamoDb private constructor(
8888 }
8989
9090 companion object {
91+ private val defaultPorts = ConcurrentHashMap <String , Int >()
92+ fun defaultPort (key : String ): Int {
93+ // Only pick random port once to share one test server with multiple tests.
94+ return defaultPorts.getOrPut(key, ::pickRandomPort)
95+ }
96+
9197 private val runningServers = ConcurrentHashMap .newKeySet<String >()
9298 private val log = getLogger<TestDynamoDb >()
9399 }
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ class TestDynamoDb private constructor(
8181 }
8282
8383 fun build (): TestDynamoDb {
84- val port = port ? : pickRandomPort( )
84+ val port = port ? : defaultPort(serverFactory.toString() )
8585 return TestDynamoDb (
8686 DefaultTestDynamoDbClient (tables, port),
8787 serverFactory.create(port)
@@ -90,6 +90,12 @@ class TestDynamoDb private constructor(
9090 }
9191
9292 companion object {
93+ private val defaultPorts = ConcurrentHashMap <String , Int >()
94+ fun defaultPort (key : String ): Int {
95+ // Only pick random port once to share one test server with multiple tests.
96+ return defaultPorts.getOrPut(key, ::pickRandomPort)
97+ }
98+
9399 private val runningServers = ConcurrentHashMap .newKeySet<String >()
94100 private val log = getLogger<TestDynamoDb >()
95101 }
Original file line number Diff line number Diff line change @@ -150,8 +150,9 @@ internal class DynamoDbLogicalDb(
150150 val writeRequest = toTransactionWriteRequest(writeSet)
151151 return dynamoDbEnhancedClient.transactWriteItems(writeRequest)
152152 .exceptionally { e ->
153- if (e is TransactionCanceledException ) {
154- toTransactionWriteException(writeSet, e) as Void
153+ // `e` is a java.util.concurrent.CancellationException.
154+ if (e.cause is TransactionCanceledException ) {
155+ toTransactionWriteException(writeSet, e.cause as TransactionCanceledException ) as Void
155156 } else {
156157 throw e
157158 }
You can’t perform that action at this time.
0 commit comments