diff --git a/build.gradle b/build.gradle index b3ed0c016d..43e567dd0b 100644 --- a/build.gradle +++ b/build.gradle @@ -125,6 +125,7 @@ buildscript { ext.commons_lang_version = '3.9' ext.commons_io_version = '2.6' ext.controlsfx_version = '8.40.15' + ext.detekt_version = constants.getProperty('detektVersion') if (JavaVersion.current() == JavaVersion.VERSION_11) { // has been compiled by a more recent version of the Java Runtime (class file version 55.0) ext.fontawesomefx_commons_version = '11.0' @@ -464,13 +465,14 @@ task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) { } } -task detekt(type: JavaExec) { +task detekt(type: JavaExec, dependsOn: ":detekt-plugins:jar") { main = "io.gitlab.arturbosch.detekt.cli.Main" classpath = configurations.detekt def input = "$projectDir" def config = "$projectDir/detekt-config.yml" def baseline = "$projectDir/detekt-baseline.xml" - def params = ['-i', input, '-c', config, '-b', baseline] + def plugins = "$projectDir/detekt-plugins/build/libs/detekt-plugins-${version}.jar" + def params = ['-i', input, '-c', config, '-b', baseline, '--plugins', plugins] args(params) } diff --git a/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/CordaRPCClientTest.kt b/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/CordaRPCClientTest.kt index 60271d97a3..59f05cb8e2 100644 --- a/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/CordaRPCClientTest.kt +++ b/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/CordaRPCClientTest.kt @@ -264,7 +264,7 @@ class CordaRPCClientTest : NodeBasedTest(listOf("net.corda.finance"), notaries = assertThat(outOfProcessRpc.waitFor()).isZero() // i.e. no exceptions were thrown } - @Test + @Test(timeout=300_000) fun `nonspecific reconnect errors dont trigger graceful reconnect`() { val inputJar1 = Thread.currentThread().contextClassLoader.getResourceAsStream(testJar)!! val inputJar2 = Thread.currentThread().contextClassLoader.getResourceAsStream(testJar)!! diff --git a/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/RpcCustomSerializersTest.kt b/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/RpcCustomSerializersTest.kt index a66052e814..5e3c50f976 100644 --- a/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/RpcCustomSerializersTest.kt +++ b/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/RpcCustomSerializersTest.kt @@ -72,7 +72,7 @@ class RpcCustomSerializersTest { } } - @Test + @Test(timeout=300_000) fun `when a custom serializer is missing from the rpc client the resulting exception progagtes and client does not reconnect`() { driver(DriverParameters(startNodesInProcess = false, cordappsForAllNodes = listOf(enclosedCordapp()))) { val server = startNode(providedName = ALICE_NAME).get() diff --git a/constants.properties b/constants.properties index 2d7ecca94b..d43a8afbe8 100644 --- a/constants.properties +++ b/constants.properties @@ -35,4 +35,5 @@ deterministicRtVersion=1.0-RC02 openSourceBranch=https://github.com/corda/corda/blob/release/os/4.4 openSourceSamplesBranch=https://github.com/corda/samples/blob/release-V4 jolokiaAgentVersion=1.6.1 +detektVersion=1.0.1 diff --git a/core-deterministic/testing/data/src/test/kotlin/net/corda/deterministic/data/GenerateData.kt b/core-deterministic/testing/data/src/test/kotlin/net/corda/deterministic/data/GenerateData.kt index 559530278f..4612f19c7a 100644 --- a/core-deterministic/testing/data/src/test/kotlin/net/corda/deterministic/data/GenerateData.kt +++ b/core-deterministic/testing/data/src/test/kotlin/net/corda/deterministic/data/GenerateData.kt @@ -71,7 +71,7 @@ class GenerateData { testSerialization.reset() } - @Test + @Test(timeout = 300_000) fun verifyTransactions() { URLClassLoader(arrayOf(TEST_DATA.toUri().toURL())).use { cl -> cl.loadResource("txverify/tx-success.bin") diff --git a/core-tests/src/test/kotlin/net/corda/coretests/contracts/ContractsDSLTests.kt b/core-tests/src/test/kotlin/net/corda/coretests/contracts/ContractsDSLTests.kt index 52e86e1336..4768cf9681 100644 --- a/core-tests/src/test/kotlin/net/corda/coretests/contracts/ContractsDSLTests.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/contracts/ContractsDSLTests.kt @@ -47,7 +47,7 @@ class RequireSingleCommandTests(private val testFunction: (Collection { + override fun apply(instant: Instant): String { + return instant.toString() + } + } + } + """.trimIndent() + + @Test(timeout = 300_000) + fun `catches missing timeout for junit 4 tests`() { + val rule = TestWithMissingTimeout() + val findings = rule.lint(junit4Code) + assertThat(findings).hasSize(1) + } + + @Test(timeout = 300_000) + fun `does not warn for junit 5 tests`() { + val rule = TestWithMissingTimeout() + val findings = rule.lint(junit5Code) + assertThat(findings).hasSize(0) + } +} diff --git a/docs/source/example-code/src/test/kotlin/net/corda/docs/kotlin/tutorial/testdsl/TutorialTestDSL.kt b/docs/source/example-code/src/test/kotlin/net/corda/docs/kotlin/tutorial/testdsl/TutorialTestDSL.kt index a981ad2467..b5670ef17c 100644 --- a/docs/source/example-code/src/test/kotlin/net/corda/docs/kotlin/tutorial/testdsl/TutorialTestDSL.kt +++ b/docs/source/example-code/src/test/kotlin/net/corda/docs/kotlin/tutorial/testdsl/TutorialTestDSL.kt @@ -77,7 +77,7 @@ class TutorialTestDSL { // DOCSTART 2 // This example test will fail with this exception. - @Test(expected = IllegalStateException::class) + @Test(expected = IllegalStateException::class, timeout=300_000) fun simpleCP() { val inState = getPaper() ledgerServices.ledger(dummyNotary.party) { @@ -92,7 +92,7 @@ class TutorialTestDSL { // DOCSTART 3 // This example test will fail with this exception. - @Test(expected = TransactionVerificationException.ContractRejection::class) + @Test(expected = TransactionVerificationException.ContractRejection::class, timeout=300_000) fun simpleCPMove() { val inState = getPaper() ledgerServices.ledger(dummyNotary.party) { diff --git a/experimental/src/test/kotlin/net/corda/finance/contracts/universal/Caplet.kt b/experimental/src/test/kotlin/net/corda/finance/contracts/universal/Caplet.kt index 61e3039a39..3565f6aee2 100644 --- a/experimental/src/test/kotlin/net/corda/finance/contracts/universal/Caplet.kt +++ b/experimental/src/test/kotlin/net/corda/finance/contracts/universal/Caplet.kt @@ -121,7 +121,7 @@ class Caplet { } } - @Test @Ignore + @Test(timeout=300_000) @Ignore fun `pretty print`() { println ( prettyPrint(contract) ) diff --git a/experimental/src/test/kotlin/net/corda/finance/contracts/universal/Examples.kt b/experimental/src/test/kotlin/net/corda/finance/contracts/universal/Examples.kt index e4b989a6bf..6e3f27dea5 100644 --- a/experimental/src/test/kotlin/net/corda/finance/contracts/universal/Examples.kt +++ b/experimental/src/test/kotlin/net/corda/finance/contracts/universal/Examples.kt @@ -117,7 +117,7 @@ class Examples { } } - @Test @Ignore + @Test(timeout=300_000) @Ignore fun `pretty print`() { println ( prettyPrint(cds_contract) ) diff --git a/experimental/src/test/kotlin/net/corda/finance/contracts/universal/FXFwdTimeOption.kt b/experimental/src/test/kotlin/net/corda/finance/contracts/universal/FXFwdTimeOption.kt index 57e1a04e7a..f78dae7eed 100644 --- a/experimental/src/test/kotlin/net/corda/finance/contracts/universal/FXFwdTimeOption.kt +++ b/experimental/src/test/kotlin/net/corda/finance/contracts/universal/FXFwdTimeOption.kt @@ -125,7 +125,7 @@ class FXFwdTimeOption { } } - @Test @Ignore + @Test(timeout=300_000) @Ignore fun `pretty print`() { println ( prettyPrint(initialContract) ) diff --git a/experimental/src/test/kotlin/net/corda/finance/contracts/universal/FXSwap.kt b/experimental/src/test/kotlin/net/corda/finance/contracts/universal/FXSwap.kt index c7458e355b..ca86d9a3a4 100644 --- a/experimental/src/test/kotlin/net/corda/finance/contracts/universal/FXSwap.kt +++ b/experimental/src/test/kotlin/net/corda/finance/contracts/universal/FXSwap.kt @@ -164,7 +164,7 @@ class FXSwap { } } - @Test @Ignore + @Test(timeout=300_000) @Ignore fun `pretty print`() { println ( prettyPrint(contract) ) } diff --git a/experimental/src/test/kotlin/net/corda/finance/contracts/universal/IRS.kt b/experimental/src/test/kotlin/net/corda/finance/contracts/universal/IRS.kt index c7d8895502..8e7dc274df 100644 --- a/experimental/src/test/kotlin/net/corda/finance/contracts/universal/IRS.kt +++ b/experimental/src/test/kotlin/net/corda/finance/contracts/universal/IRS.kt @@ -202,7 +202,7 @@ class IRS { } } - @Test @Ignore + @Test(timeout=300_000) @Ignore fun `pretty print`() { println ( prettyPrint(contractInitial) ) diff --git a/finance/contracts/src/test/kotlin/net/corda/finance/contracts/asset/CashTests.kt b/finance/contracts/src/test/kotlin/net/corda/finance/contracts/asset/CashTests.kt index 4f1ce792ff..bb9356a8c4 100644 --- a/finance/contracts/src/test/kotlin/net/corda/finance/contracts/asset/CashTests.kt +++ b/finance/contracts/src/test/kotlin/net/corda/finance/contracts/asset/CashTests.kt @@ -300,7 +300,7 @@ class CashTests { * Test that the issuance builder rejects building into a transaction with existing * cash inputs. */ - @Test(expected = IllegalStateException::class) + @Test(expected = IllegalStateException::class, timeout=300_000) fun `reject issuance with inputs`() { // Issue some cash var ptx = TransactionBuilder(dummyNotary.party) @@ -762,7 +762,7 @@ class CashTests { assertEquals(6000.DOLLARS `issued by` defaultIssuer, states.sumCashBy(megaCorp.party)) } - @Test(expected = UnsupportedOperationException::class) + @Test(expected = UnsupportedOperationException::class, timeout=300_000) fun `summing by owner throws`() { val states = listOf( Cash.State(2000.DOLLARS `issued by` defaultIssuer, megaCorp.party), @@ -778,7 +778,7 @@ class CashTests { assertNull(states.sumCashOrNull()) } - @Test(expected = UnsupportedOperationException::class) + @Test(expected = UnsupportedOperationException::class, timeout=300_000) fun `summing no currencies throws`() { val states = emptyList() states.sumCash() @@ -797,7 +797,7 @@ class CashTests { assertEquals(expected, actual) } - @Test(expected = IllegalArgumentException::class) + @Test(expected = IllegalArgumentException::class, timeout=300_000) fun `summing multiple currencies`() { val states = listOf( Cash.State(1000.DOLLARS `issued by` defaultIssuer, megaCorp.party), diff --git a/finance/contracts/src/test/kotlin/net/corda/finance/contracts/asset/ObligationTests.kt b/finance/contracts/src/test/kotlin/net/corda/finance/contracts/asset/ObligationTests.kt index 3cc9dd479c..9f417b9a35 100644 --- a/finance/contracts/src/test/kotlin/net/corda/finance/contracts/asset/ObligationTests.kt +++ b/finance/contracts/src/test/kotlin/net/corda/finance/contracts/asset/ObligationTests.kt @@ -253,7 +253,7 @@ class ObligationTests { * Test that the issuance builder rejects building into a transaction with existing * cash inputs. */ - @Test(expected = IllegalStateException::class) + @Test(expected = IllegalStateException::class, timeout=300_000) fun `reject issuance with inputs`() { // Issue some obligation val tx = TransactionBuilder(DUMMY_NOTARY).apply { @@ -854,7 +854,7 @@ class ObligationTests { fiveKDollarsFromMegaToMega.copy(template = megaCorpDollarSettlement.copy(acceptableIssuedProducts = miniCorpIssuer)).bilateralNetState) } - @Test(expected = IllegalStateException::class) + @Test(expected = IllegalStateException::class, timeout=300_000) fun `states cannot be netted if not in the normal state`() { inState.copy(lifecycle = Lifecycle.DEFAULTED).bilateralNetState } diff --git a/node/src/test/kotlin/net/corda/node/internal/NodeFlowManagerTest.kt b/node/src/test/kotlin/net/corda/node/internal/NodeFlowManagerTest.kt index ffab3c8e01..4a417f368a 100644 --- a/node/src/test/kotlin/net/corda/node/internal/NodeFlowManagerTest.kt +++ b/node/src/test/kotlin/net/corda/node/internal/NodeFlowManagerTest.kt @@ -57,7 +57,7 @@ class NodeFlowManagerTest { } - @Test(expected = IllegalStateException::class) + @Test(expected = IllegalStateException::class, timeout = 300_000) fun `should fail to validate if more than one registration with equal weight`() { val nodeFlowManager = NodeFlowManager() nodeFlowManager.registerInitiatedFlow(Init::class.java, Resp::class.java) @@ -65,7 +65,7 @@ class NodeFlowManagerTest { nodeFlowManager.validateRegistrations() } - @Test() + @Test(timeout = 300_000) fun `should allow registration of flows with different weights`() { val nodeFlowManager = NodeFlowManager() nodeFlowManager.registerInitiatedFlow(Init::class.java, Resp::class.java) @@ -76,7 +76,7 @@ class NodeFlowManagerTest { Assert.assertThat(flow, `is`(instanceOf(RespSub::class.java))) } - @Test() + @Test(timeout = 300_000) fun `should allow updating of registered responder at runtime`() { val nodeFlowManager = NodeFlowManager() nodeFlowManager.registerInitiatedFlow(Init::class.java, Resp::class.java) diff --git a/node/src/test/kotlin/net/corda/node/internal/cordapp/CordappConfigFileProviderTests.kt b/node/src/test/kotlin/net/corda/node/internal/cordapp/CordappConfigFileProviderTests.kt index b9633d3c0b..5dad12f765 100644 --- a/node/src/test/kotlin/net/corda/node/internal/cordapp/CordappConfigFileProviderTests.kt +++ b/node/src/test/kotlin/net/corda/node/internal/cordapp/CordappConfigFileProviderTests.kt @@ -45,7 +45,7 @@ class CordappConfigFileProviderTests { assertThat(provider.getConfigByName(cordappName)).isEqualTo(alternateValidConfig) } - @Test(expected = ConfigException.Parse::class) + @Test(expected = ConfigException.Parse::class, timeout=300_000) fun `an invalid config throws an exception`() { cordappConfFile.writeText(invalidConfig) provider.getConfigByName(cordappName) diff --git a/node/src/test/kotlin/net/corda/node/internal/cordapp/TypesafeCordappConfigTests.kt b/node/src/test/kotlin/net/corda/node/internal/cordapp/TypesafeCordappConfigTests.kt index a69d29abbe..18f20d6ad2 100644 --- a/node/src/test/kotlin/net/corda/node/internal/cordapp/TypesafeCordappConfigTests.kt +++ b/node/src/test/kotlin/net/corda/node/internal/cordapp/TypesafeCordappConfigTests.kt @@ -37,7 +37,7 @@ class TypesafeCordappConfigTests { assertThat(cordappConf.exists("notexists")).isFalse() } - @Test(expected = CordappConfigException::class) + @Test(expected = CordappConfigException::class, timeout=300_000) fun `test that an exception is thrown when trying to access a non-extant field`() { val config = ConfigFactory.empty() val cordappConf = TypesafeCordappConfig(config) diff --git a/node/src/test/kotlin/net/corda/node/messaging/TwoPartyTradeFlowTests.kt b/node/src/test/kotlin/net/corda/node/messaging/TwoPartyTradeFlowTests.kt index e25308e5ec..200b60742a 100644 --- a/node/src/test/kotlin/net/corda/node/messaging/TwoPartyTradeFlowTests.kt +++ b/node/src/test/kotlin/net/corda/node/messaging/TwoPartyTradeFlowTests.kt @@ -145,7 +145,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { } } - @Test(expected = InsufficientBalanceException::class) + @Test(expected = InsufficientBalanceException::class, timeout=300_000) fun `trade cash for commercial paper fails using soft locking`() { mockNet = InternalMockNetwork(cordappsForAllNodes = listOf(FINANCE_CONTRACTS_CORDAPP), threadPerNode = true) val notaryNode = mockNet.defaultNotaryNode diff --git a/node/src/test/kotlin/net/corda/node/services/statemachine/FlowLogicRefFactoryImplTest.kt b/node/src/test/kotlin/net/corda/node/services/statemachine/FlowLogicRefFactoryImplTest.kt index 7d6e8734a4..a780bfbf2f 100644 --- a/node/src/test/kotlin/net/corda/node/services/statemachine/FlowLogicRefFactoryImplTest.kt +++ b/node/src/test/kotlin/net/corda/node/services/statemachine/FlowLogicRefFactoryImplTest.kt @@ -77,7 +77,7 @@ class FlowLogicRefFactoryImplTest { flowLogicRefFactory.createKotlin(KotlinFlowLogic::class.java, args) } - @Test(expected = IllegalFlowLogicException::class) + @Test(expected = IllegalFlowLogicException::class, timeout=300_000) fun `create for non-schedulable flow logic`() { flowLogicRefFactory.create(NonSchedulableFlow::class.jvmName) } diff --git a/serialization-tests/src/test/kotlin/net/corda/serialization/internal/CordaClassResolverTests.kt b/serialization-tests/src/test/kotlin/net/corda/serialization/internal/CordaClassResolverTests.kt index a7945ab61b..5208324e7d 100644 --- a/serialization-tests/src/test/kotlin/net/corda/serialization/internal/CordaClassResolverTests.kt +++ b/serialization-tests/src/test/kotlin/net/corda/serialization/internal/CordaClassResolverTests.kt @@ -125,7 +125,7 @@ class CordaClassResolverTests { CordaClassResolver(emptyWhitelistContext).getRegistration(Foo.Bar::class.java) } - @Test(expected = KryoException::class) + @Test(expected = KryoException::class, timeout=300_000) fun `Unannotated specialised enum does not work`() { CordaClassResolver(emptyWhitelistContext).getRegistration(BadFood.Mud::class.java) } @@ -135,7 +135,7 @@ class CordaClassResolverTests { CordaClassResolver(emptyWhitelistContext).getRegistration(Simple.Easy::class.java) } - @Test(expected = KryoException::class) + @Test(expected = KryoException::class, timeout=300_000) fun `Unannotated simple enum does not work`() { CordaClassResolver(emptyWhitelistContext).getRegistration(BadSimple.Nasty::class.java) } @@ -146,7 +146,7 @@ class CordaClassResolverTests { CordaClassResolver(emptyWhitelistContext).getRegistration(values.javaClass) } - @Test(expected = KryoException::class) + @Test(expected = KryoException::class, timeout=300_000) fun `Unannotated array elements do not work`() { val values = arrayOf(NotSerializable()) CordaClassResolver(emptyWhitelistContext).getRegistration(values.javaClass) @@ -168,13 +168,13 @@ class CordaClassResolverTests { kryo.register(NotSerializable::class.java) } - @Test(expected = KryoException::class) + @Test(expected = KryoException::class, timeout=300_000) fun `Calling register method on unmodified Kryo does consult the whitelist`() { val kryo = Kryo(CordaClassResolver(emptyWhitelistContext), MapReferenceResolver()) kryo.register(NotSerializable::class.java) } - @Test(expected = KryoException::class) + @Test(expected = KryoException::class, timeout=300_000) fun `Annotation is needed without whitelisting`() { CordaClassResolver(emptyWhitelistContext).getRegistration(NotSerializable::class.java) } @@ -195,19 +195,19 @@ class CordaClassResolverTests { CordaClassResolver(emptyWhitelistContext).getRegistration(Integer.TYPE) } - @Test(expected = KryoException::class) + @Test(expected = KryoException::class, timeout=300_000) fun `Annotation does not work for custom serializable`() { CordaClassResolver(emptyWhitelistContext).getRegistration(CustomSerializable::class.java) } - @Test(expected = KryoException::class) + @Test(expected = KryoException::class, timeout=300_000) fun `Annotation does not work in conjunction with Kryo annotation`() { CordaClassResolver(emptyWhitelistContext).getRegistration(DefaultSerializable::class.java) } private fun importJar(storage: AttachmentStorage, uploader: String = DEPLOYED_CORDAPP_UPLOADER) = ISOLATED_CONTRACTS_JAR_PATH.openStream().use { storage.importAttachment(it, uploader, "") } - @Test(expected = KryoException::class) + @Test(expected = KryoException::class, timeout=300_000) fun `Annotation does not work in conjunction with AttachmentClassLoader annotation`() { val storage = InternalMockAttachmentStorage(MockAttachmentStorage()) val attachmentTrustCalculator = NodeAttachmentTrustCalculator(storage, TestingNamedCacheFactory()) @@ -217,7 +217,7 @@ class CordaClassResolverTests { CordaClassResolver(emptyWhitelistContext).getRegistration(attachedClass) } - @Test(expected = TransactionVerificationException.UntrustedAttachmentsException::class) + @Test(expected = TransactionVerificationException.UntrustedAttachmentsException::class, timeout=300_000) fun `Attempt to load contract attachment with untrusted uploader should fail with UntrustedAttachmentsException`() { val storage = InternalMockAttachmentStorage(MockAttachmentStorage()) val attachmentTrustCalculator = NodeAttachmentTrustCalculator(storage, TestingNamedCacheFactory()) diff --git a/serialization-tests/src/test/kotlin/net/corda/serialization/internal/SerializationTokenTest.kt b/serialization-tests/src/test/kotlin/net/corda/serialization/internal/SerializationTokenTest.kt index 1533d3d6a4..fbe7537199 100644 --- a/serialization-tests/src/test/kotlin/net/corda/serialization/internal/SerializationTokenTest.kt +++ b/serialization-tests/src/test/kotlin/net/corda/serialization/internal/SerializationTokenTest.kt @@ -70,7 +70,7 @@ class SerializationTokenTest { assertThat(tokenizableAfter).isSameAs(tokenizableBefore) } - @Test(expected = UnsupportedOperationException::class) + @Test(expected = UnsupportedOperationException::class, timeout=300_000) fun `new token encountered after context init`() { val tokenizableBefore = UnitSerializeAsToken() val context = serializeAsTokenContext(emptyList()) @@ -78,7 +78,7 @@ class SerializationTokenTest { tokenizableBefore.checkpointSerialize(testContext) } - @Test(expected = UnsupportedOperationException::class) + @Test(expected = UnsupportedOperationException::class, timeout=300_000) fun `deserialize unregistered token`() { val tokenizableBefore = UnitSerializeAsToken() val context = serializeAsTokenContext(emptyList()) @@ -87,13 +87,13 @@ class SerializationTokenTest { serializedBytes.checkpointDeserialize(testContext) } - @Test(expected = KryoException::class) + @Test(expected = KryoException::class, timeout=300_000) fun `no context set`() { val tokenizableBefore = UnitSerializeAsToken() tokenizableBefore.checkpointSerialize(context) } - @Test(expected = KryoException::class) + @Test(expected = KryoException::class, timeout=300_000) fun `deserialize non-token`() { val tokenizableBefore = UnitSerializeAsToken() val context = serializeAsTokenContext(tokenizableBefore) @@ -119,7 +119,7 @@ class SerializationTokenTest { override fun toToken(context: SerializeAsTokenContext): SerializationToken = UnitSerializationToken } - @Test(expected = KryoException::class) + @Test(expected = KryoException::class, timeout=300_000) fun `token returns unexpected type`() { val tokenizableBefore = WrongTypeSerializeAsToken() val context = serializeAsTokenContext(tokenizableBefore) diff --git a/serialization-tests/src/test/kotlin/net/corda/serialization/internal/amqp/SerializationOutputTests.kt b/serialization-tests/src/test/kotlin/net/corda/serialization/internal/amqp/SerializationOutputTests.kt index d13502075f..dade6b0f50 100644 --- a/serialization-tests/src/test/kotlin/net/corda/serialization/internal/amqp/SerializationOutputTests.kt +++ b/serialization-tests/src/test/kotlin/net/corda/serialization/internal/amqp/SerializationOutputTests.kt @@ -322,7 +322,7 @@ class SerializationOutputTests(private val compression: CordaSerializationEncodi serdes(obj) } - @Test(expected = IllegalArgumentException::class) + @Test(expected = IllegalArgumentException::class, timeout=300_000) fun `test dislike of HashMap`() { val obj = WrapHashMap(HashMap()) serdes(obj) @@ -364,7 +364,7 @@ class SerializationOutputTests(private val compression: CordaSerializationEncodi serdes(obj) } - @Test(expected = NotSerializableException::class) + @Test(expected = NotSerializableException::class, timeout=300_000) fun `test whitelist`() { val obj = Woo2(4) serdes(obj, SerializerFactoryBuilder.build(EmptyWhitelist, @@ -380,7 +380,7 @@ class SerializationOutputTests(private val compression: CordaSerializationEncodi )) } - @Test(expected = NotSerializableException::class) + @Test(expected = NotSerializableException::class, timeout=300_000) fun `test generic list subclass is not supported`() { val obj = FooList() serdes(obj) @@ -458,13 +458,13 @@ class SerializationOutputTests(private val compression: CordaSerializationEncodi serdes(obj) } - @Test(expected = NotSerializableException::class) + @Test(expected = NotSerializableException::class, timeout=300_000) fun `test mismatched property and constructor naming`() { val obj = Mismatch(456) serdes(obj) } - @Test(expected = NotSerializableException::class) + @Test(expected = NotSerializableException::class, timeout=300_000) fun `test mismatched property and constructor type`() { val obj = MismatchType(456) serdes(obj) diff --git a/serialization/src/test/kotlin/net/corda/serialization/internal/amqp/AMQPTypeIdentifierParserTests.kt b/serialization/src/test/kotlin/net/corda/serialization/internal/amqp/AMQPTypeIdentifierParserTests.kt index b4bdbad2e1..ff7825da1d 100644 --- a/serialization/src/test/kotlin/net/corda/serialization/internal/amqp/AMQPTypeIdentifierParserTests.kt +++ b/serialization/src/test/kotlin/net/corda/serialization/internal/amqp/AMQPTypeIdentifierParserTests.kt @@ -100,47 +100,47 @@ class AMQPTypeIdentifierParserTests { verify("java.util.List>>") } - @Test(expected = NotSerializableException::class) + @Test(expected = NotSerializableException::class, timeout = 300_000) fun `test trailing text`() { verify("java.util.Mapfoo") } - @Test(expected = NotSerializableException::class) + @Test(expected = NotSerializableException::class, timeout = 300_000) fun `test trailing comma`() { verify("java.util.Map") } - @Test(expected = NotSerializableException::class) + @Test(expected = NotSerializableException::class, timeout = 300_000) fun `test leading comma`() { verify("java.util.Map<,java.lang.String, java.lang.Integer>") } - @Test(expected = NotSerializableException::class) + @Test(expected = NotSerializableException::class, timeout = 300_000) fun `test middle comma`() { verify("java.util.Map<,java.lang.String,, java.lang.Integer>") } - @Test(expected = NotSerializableException::class) + @Test(expected = NotSerializableException::class, timeout = 300_000) fun `test trailing close`() { verify("java.util.Map>") } - @Test(expected = NotSerializableException::class) + @Test(expected = NotSerializableException::class, timeout = 300_000) fun `test empty params`() { verify("java.util.Map<>") } - @Test(expected = NotSerializableException::class) + @Test(expected = NotSerializableException::class, timeout = 300_000) fun `test mid whitespace`() { verify("java.u til.List") } - @Test(expected = NotSerializableException::class) + @Test(expected = NotSerializableException::class, timeout = 300_000) fun `test mid whitespace2`() { verify("java.util.List") } - @Test(expected = NotSerializableException::class) + @Test(expected = NotSerializableException::class, timeout = 300_000) fun `test wrong number of parameters`() { verify("java.util.List") } @@ -150,12 +150,12 @@ class AMQPTypeIdentifierParserTests { verify("java.lang.String") } - @Test(expected = NotSerializableException::class) + @Test(expected = NotSerializableException::class, timeout = 300_000) fun `test parameters on non-generic type`() { verify("java.lang.String") } - @Test(expected = NotSerializableException::class) + @Test(expected = NotSerializableException::class, timeout = 300_000) fun `test excessive nesting`() { var nested = "java.lang.Integer" for (i in 1..MAX_TYPE_PARAM_DEPTH) { diff --git a/serialization/src/test/kotlin/net/corda/serialization/internal/amqp/DeserializeMapTests.kt b/serialization/src/test/kotlin/net/corda/serialization/internal/amqp/DeserializeMapTests.kt index 431c438de3..f40e776cd8 100644 --- a/serialization/src/test/kotlin/net/corda/serialization/internal/amqp/DeserializeMapTests.kt +++ b/serialization/src/test/kotlin/net/corda/serialization/internal/amqp/DeserializeMapTests.kt @@ -28,7 +28,7 @@ class DeserializeMapTests { DeserializationInput(sf).deserialize(serialisedBytes) } - @Test(expected = java.io.NotSerializableException::class) + @Test(expected = java.io.NotSerializableException::class, timeout=300_000) fun abstractMapFromMapOf() { data class C(val c: AbstractMap) @@ -38,7 +38,7 @@ class DeserializeMapTests { DeserializationInput(sf).deserialize(serialisedBytes) } - @Test(expected = java.io.NotSerializableException::class) + @Test(expected = java.io.NotSerializableException::class, timeout=300_000) fun abstractMapFromTreeMap() { data class C(val c: AbstractMap) diff --git a/serialization/src/test/kotlin/net/corda/serialization/internal/amqp/EnumTests.kt b/serialization/src/test/kotlin/net/corda/serialization/internal/amqp/EnumTests.kt index 51f58c614c..c2cda2c1cf 100644 --- a/serialization/src/test/kotlin/net/corda/serialization/internal/amqp/EnumTests.kt +++ b/serialization/src/test/kotlin/net/corda/serialization/internal/amqp/EnumTests.kt @@ -155,7 +155,7 @@ class EnumTests { assertEquals(c.c, obj.c) } - @Test(expected = NotSerializableException::class) + @Test(expected = NotSerializableException::class, timeout=300_000) fun changedEnum1() { val url = EnumTests::class.java.getResource("EnumTests.changedEnum1") @@ -174,7 +174,7 @@ class EnumTests { DeserializationInput(sf1).deserialize(SerializedBytes(sc2)) } - @Test(expected = NotSerializableException::class) + @Test(expected = NotSerializableException::class, timeout=300_000) fun changedEnum2() { val url = EnumTests::class.java.getResource("EnumTests.changedEnum2") diff --git a/serialization/src/test/kotlin/net/corda/serialization/internal/amqp/EvolvabilityTests.kt b/serialization/src/test/kotlin/net/corda/serialization/internal/amqp/EvolvabilityTests.kt index 39d76fa62f..d565e34777 100644 --- a/serialization/src/test/kotlin/net/corda/serialization/internal/amqp/EvolvabilityTests.kt +++ b/serialization/src/test/kotlin/net/corda/serialization/internal/amqp/EvolvabilityTests.kt @@ -113,7 +113,7 @@ class EvolvabilityTests { assertEquals(null, deserializedC.b) } - @Test(expected = NotSerializableException::class) + @Test(expected = NotSerializableException::class, timeout=300_000) fun addAdditionalParam() { val sf = testDefaultFactory() val url = EvolvabilityTests::class.java.getResource("EvolvabilityTests.addAdditionalParam") @@ -321,7 +321,7 @@ class EvolvabilityTests { DeserializationInput(factory).deserialize(SerializedBytes(url.readBytes())) } - @Test(expected = NotSerializableException::class) + @Test(expected = NotSerializableException::class, timeout=300_000) @Suppress("UNUSED") fun addMandatoryFieldWithAltConstructorUnAnnotated() { val sf = testDefaultFactory() diff --git a/serialization/src/test/kotlin/net/corda/serialization/internal/amqp/StaticInitialisationOfSerializedObjectTest.kt b/serialization/src/test/kotlin/net/corda/serialization/internal/amqp/StaticInitialisationOfSerializedObjectTest.kt index 0d1b2d9cdc..bcdf0ee1e4 100644 --- a/serialization/src/test/kotlin/net/corda/serialization/internal/amqp/StaticInitialisationOfSerializedObjectTest.kt +++ b/serialization/src/test/kotlin/net/corda/serialization/internal/amqp/StaticInitialisationOfSerializedObjectTest.kt @@ -40,7 +40,7 @@ class C2(var b: Int) { } class StaticInitialisationOfSerializedObjectTest { - @Test(expected = java.lang.ExceptionInInitializerError::class) + @Test(expected = java.lang.ExceptionInInitializerError::class, timeout=300_000) fun itBlowsUp() { C() } diff --git a/serialization/src/test/kotlin/net/corda/serialization/internal/carpenter/ClassCarpenterTest.kt b/serialization/src/test/kotlin/net/corda/serialization/internal/carpenter/ClassCarpenterTest.kt index 84c04c8baf..1c315f1c5f 100644 --- a/serialization/src/test/kotlin/net/corda/serialization/internal/carpenter/ClassCarpenterTest.kt +++ b/serialization/src/test/kotlin/net/corda/serialization/internal/carpenter/ClassCarpenterTest.kt @@ -95,7 +95,7 @@ class ClassCarpenterTest { assertEquals("Person{age=32, name=Mike}", i.toString()) } - @Test(expected = DuplicateNameException::class) + @Test(expected = DuplicateNameException::class, timeout=300_000) fun duplicates() { cc.build(ClassSchema("gen.EmptyClass", emptyMap())) cc.build(ClassSchema("gen.EmptyClass", emptyMap())) @@ -301,7 +301,7 @@ class ClassCarpenterTest { assertEquals(testD, i["d"]) } - @Test(expected = java.lang.IllegalArgumentException::class) + @Test(expected = java.lang.IllegalArgumentException::class, timeout=300_000) fun `null parameter small int`() { val className = "iEnjoySwede" val schema = ClassSchema( @@ -313,7 +313,7 @@ class ClassCarpenterTest { clazz.constructors[0].newInstance(a) } - @Test(expected = NullablePrimitiveException::class) + @Test(expected = NullablePrimitiveException::class, timeout=300_000) fun `nullable parameter small int`() { val className = "iEnjoySwede" val schema = ClassSchema( @@ -351,7 +351,7 @@ class ClassCarpenterTest { clazz.constructors[0].newInstance(a) } - @Test(expected = java.lang.reflect.InvocationTargetException::class) + @Test(expected = java.lang.reflect.InvocationTargetException::class, timeout=300_000) fun `non nullable parameter integer with null`() { val className = "iEnjoyWibble" val schema = ClassSchema( @@ -383,7 +383,7 @@ class ClassCarpenterTest { assertEquals("$className{a=[1, 2, 3]}", i.toString()) } - @Test(expected = java.lang.reflect.InvocationTargetException::class) + @Test(expected = java.lang.reflect.InvocationTargetException::class, timeout=300_000) fun `nullable int array throws`() { val className = "iEnjoySwede" val schema = ClassSchema( diff --git a/settings.gradle b/settings.gradle index 6e8ff4ba1f..78f158b144 100644 --- a/settings.gradle +++ b/settings.gradle @@ -105,3 +105,5 @@ include 'core-deterministic:testing:verifier' include 'serialization-deterministic' include 'tools:checkpoint-agent' +include 'detekt-plugins' + diff --git a/testing/node-driver/src/test/kotlin/net/corda/testing/node/CustomNotaryTest.kt b/testing/node-driver/src/test/kotlin/net/corda/testing/node/CustomNotaryTest.kt index 502700a3dc..91ccdd05c5 100644 --- a/testing/node-driver/src/test/kotlin/net/corda/testing/node/CustomNotaryTest.kt +++ b/testing/node-driver/src/test/kotlin/net/corda/testing/node/CustomNotaryTest.kt @@ -50,7 +50,7 @@ class CustomNotaryTest { mockNet.stopNodes() } - @Test(expected = CustomNotaryException::class) + @Test(expected = CustomNotaryException::class, timeout=300_000) fun `custom notary service is active`() { val tx = DummyContract.generateInitial(Random().nextInt(), notary, alice.ref(0)) val stx = aliceNode.services.signInitialTransaction(tx) diff --git a/tools/shell/src/test/kotlin/net/corda/tools/shell/CustomTypeJsonParsingTests.kt b/tools/shell/src/test/kotlin/net/corda/tools/shell/CustomTypeJsonParsingTests.kt index 5d291987b0..60823aebd4 100644 --- a/tools/shell/src/test/kotlin/net/corda/tools/shell/CustomTypeJsonParsingTests.kt +++ b/tools/shell/src/test/kotlin/net/corda/tools/shell/CustomTypeJsonParsingTests.kt @@ -49,7 +49,7 @@ class CustomTypeJsonParsingTests { assertEquals("26b37265-a1fd-4c77-b2e0-715917ef619f", state.linearId.id.toString()) } - @Test(expected = JsonMappingException::class) + @Test(expected = JsonMappingException::class, timeout=300_000) fun `Deserializing by parsing string contain invalid uuid with underscore`() { val json = """{"linearId":"extkey564_26b37265-a1fd-4c77-b2e0"}""" objectMapper.readValue(json) @@ -63,7 +63,7 @@ class CustomTypeJsonParsingTests { assertEquals("26b37265-a1fd-4c77-b2e0-715917ef619f", state.uuid.toString()) } - @Test(expected = JsonMappingException::class) + @Test(expected = JsonMappingException::class, timeout=300_000) fun `Deserializing UUID by parsing invalid uuid string`() { val json = """{"uuid":"26b37265-a1fd-4c77-b2e0"}""" objectMapper.readValue(json) diff --git a/tools/shell/src/test/kotlin/net/corda/tools/shell/InteractiveShellTest.kt b/tools/shell/src/test/kotlin/net/corda/tools/shell/InteractiveShellTest.kt index 9bfb1d465d..4d4a49c169 100644 --- a/tools/shell/src/test/kotlin/net/corda/tools/shell/InteractiveShellTest.kt +++ b/tools/shell/src/test/kotlin/net/corda/tools/shell/InteractiveShellTest.kt @@ -171,13 +171,13 @@ class InteractiveShellTest { expected = "10 (1)++200 (2)" ) - @Test(expected = InteractiveShell.NoApplicableConstructor::class) + @Test(expected = InteractiveShell.NoApplicableConstructor::class, timeout=300_000) fun flowStartNoArgs() = check("", "") - @Test(expected = InteractiveShell.NoApplicableConstructor::class) + @Test(expected = InteractiveShell.NoApplicableConstructor::class, timeout=300_000) fun flowMissingParam() = check("d: Yo", "") - @Test(expected = InteractiveShell.NoApplicableConstructor::class) + @Test(expected = InteractiveShell.NoApplicableConstructor::class, timeout=300_000) fun flowTooManyParams() = check("b: 12, c: Yo, d: Bar", "") @Test(timeout=300_000)