diff --git a/client/jackson/src/test/kotlin/net/corda/client/jackson/JacksonSupportTest.kt b/client/jackson/src/test/kotlin/net/corda/client/jackson/JacksonSupportTest.kt index d5b311e9f4..65800b7a8f 100644 --- a/client/jackson/src/test/kotlin/net/corda/client/jackson/JacksonSupportTest.kt +++ b/client/jackson/src/test/kotlin/net/corda/client/jackson/JacksonSupportTest.kt @@ -12,6 +12,7 @@ import net.corda.core.transactions.SignedTransaction import net.corda.finance.USD import net.corda.testing.* import net.corda.testing.contracts.DummyContract +import net.corda.testing.internal.rigorousMock import org.junit.Before import org.junit.Rule import org.junit.Test diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/Measure.kt b/client/rpc/src/test/kotlin/net/corda/client/rpc/Measure.kt similarity index 98% rename from testing/test-utils/src/main/kotlin/net/corda/testing/Measure.kt rename to client/rpc/src/test/kotlin/net/corda/client/rpc/Measure.kt index a44c28ade2..1e288f2741 100644 --- a/testing/test-utils/src/main/kotlin/net/corda/testing/Measure.kt +++ b/client/rpc/src/test/kotlin/net/corda/client/rpc/Measure.kt @@ -1,4 +1,4 @@ -package net.corda.testing +package net.corda.client.rpc import net.corda.core.internal.uncheckedCast import kotlin.reflect.KCallable diff --git a/client/rpc/src/test/kotlin/net/corda/client/rpc/RPCPerformanceTests.kt b/client/rpc/src/test/kotlin/net/corda/client/rpc/RPCPerformanceTests.kt index 85d3351ade..b945487cb9 100644 --- a/client/rpc/src/test/kotlin/net/corda/client/rpc/RPCPerformanceTests.kt +++ b/client/rpc/src/test/kotlin/net/corda/client/rpc/RPCPerformanceTests.kt @@ -12,7 +12,6 @@ import net.corda.testing.node.internal.performance.startPublishingFixedRateInjec import net.corda.testing.node.internal.performance.startReporter import net.corda.testing.node.internal.performance.startTightLoopInjector import net.corda.testing.node.internal.rpcDriver -import net.corda.testing.measure import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith diff --git a/core/src/test/kotlin/net/corda/core/concurrent/ConcurrencyUtilsTest.kt b/core/src/test/kotlin/net/corda/core/concurrent/ConcurrencyUtilsTest.kt index 830398964c..78f1586d8a 100644 --- a/core/src/test/kotlin/net/corda/core/concurrent/ConcurrencyUtilsTest.kt +++ b/core/src/test/kotlin/net/corda/core/concurrent/ConcurrencyUtilsTest.kt @@ -3,7 +3,7 @@ package net.corda.core.concurrent import com.nhaarman.mockito_kotlin.* import net.corda.core.internal.concurrent.openFuture import net.corda.core.utilities.getOrThrow -import net.corda.testing.rigorousMock +import net.corda.testing.internal.rigorousMock import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.Test import org.slf4j.Logger diff --git a/core/src/test/kotlin/net/corda/core/contracts/DummyContractV2Tests.kt b/core/src/test/kotlin/net/corda/core/contracts/DummyContractV2Tests.kt index 460fda3328..f7f1abf245 100644 --- a/core/src/test/kotlin/net/corda/core/contracts/DummyContractV2Tests.kt +++ b/core/src/test/kotlin/net/corda/core/contracts/DummyContractV2Tests.kt @@ -9,6 +9,7 @@ import net.corda.core.node.ServicesForResolution import net.corda.testing.* import net.corda.testing.contracts.DummyContract import net.corda.testing.contracts.DummyContractV2 +import net.corda.testing.internal.rigorousMock import org.junit.Rule import org.junit.Test import kotlin.test.assertEquals diff --git a/core/src/test/kotlin/net/corda/core/crypto/CompositeKeyTests.kt b/core/src/test/kotlin/net/corda/core/crypto/CompositeKeyTests.kt index 12ea44c72b..f20a4b20c9 100644 --- a/core/src/test/kotlin/net/corda/core/crypto/CompositeKeyTests.kt +++ b/core/src/test/kotlin/net/corda/core/crypto/CompositeKeyTests.kt @@ -9,7 +9,7 @@ import net.corda.core.serialization.serialize import net.corda.core.utilities.OpaqueBytes import net.corda.core.utilities.toBase58String import net.corda.nodeapi.internal.crypto.* -import net.corda.testing.kryoSpecific +import net.corda.testing.internal.kryoSpecific import net.corda.testing.SerializationEnvironmentRule import org.junit.Rule import org.junit.Test diff --git a/core/src/test/kotlin/net/corda/core/crypto/PartialMerkleTreeTest.kt b/core/src/test/kotlin/net/corda/core/crypto/PartialMerkleTreeTest.kt index 4b3f5b7f48..18ecbcfd24 100644 --- a/core/src/test/kotlin/net/corda/core/crypto/PartialMerkleTreeTest.kt +++ b/core/src/test/kotlin/net/corda/core/crypto/PartialMerkleTreeTest.kt @@ -14,6 +14,10 @@ import net.corda.finance.`issued by` import net.corda.finance.contracts.asset.Cash import net.corda.node.services.api.IdentityServiceInternal import net.corda.testing.* +import net.corda.testing.dsl.LedgerDSL +import net.corda.testing.dsl.TestLedgerDSLInterpreter +import net.corda.testing.dsl.TestTransactionDSLInterpreter +import net.corda.testing.internal.rigorousMock import net.corda.testing.node.MockServices import net.corda.testing.node.ledger import org.junit.Before diff --git a/core/src/test/kotlin/net/corda/core/flows/CollectSignaturesFlowTests.kt b/core/src/test/kotlin/net/corda/core/flows/CollectSignaturesFlowTests.kt index 944e7eaca5..6da0ce7f18 100644 --- a/core/src/test/kotlin/net/corda/core/flows/CollectSignaturesFlowTests.kt +++ b/core/src/test/kotlin/net/corda/core/flows/CollectSignaturesFlowTests.kt @@ -14,6 +14,7 @@ import net.corda.core.utilities.getOrThrow import net.corda.node.internal.StartedNode import net.corda.testing.* import net.corda.testing.contracts.DummyContract +import net.corda.testing.internal.rigorousMock import net.corda.testing.node.MockNetwork import net.corda.testing.node.MockServices import net.corda.testing.node.startFlow diff --git a/core/src/test/kotlin/net/corda/core/internal/concurrent/CordaFutureImplTest.kt b/core/src/test/kotlin/net/corda/core/internal/concurrent/CordaFutureImplTest.kt index 0b52c89491..d04fae86bb 100644 --- a/core/src/test/kotlin/net/corda/core/internal/concurrent/CordaFutureImplTest.kt +++ b/core/src/test/kotlin/net/corda/core/internal/concurrent/CordaFutureImplTest.kt @@ -4,7 +4,7 @@ import com.nhaarman.mockito_kotlin.* import net.corda.core.concurrent.CordaFuture import net.corda.core.internal.join import net.corda.core.utilities.getOrThrow -import net.corda.testing.rigorousMock +import net.corda.testing.internal.rigorousMock import org.assertj.core.api.Assertions import org.junit.Test import org.slf4j.Logger diff --git a/core/src/test/kotlin/net/corda/core/serialization/TransactionSerializationTests.kt b/core/src/test/kotlin/net/corda/core/serialization/TransactionSerializationTests.kt index 838fd196ae..8f70d9610d 100644 --- a/core/src/test/kotlin/net/corda/core/serialization/TransactionSerializationTests.kt +++ b/core/src/test/kotlin/net/corda/core/serialization/TransactionSerializationTests.kt @@ -9,6 +9,7 @@ import net.corda.core.transactions.TransactionBuilder import net.corda.core.utilities.seconds import net.corda.finance.POUNDS import net.corda.testing.* +import net.corda.testing.internal.rigorousMock import net.corda.testing.node.MockServices import org.junit.Before import org.junit.Rule diff --git a/core/src/test/kotlin/net/corda/core/transactions/LedgerTransactionQueryTests.kt b/core/src/test/kotlin/net/corda/core/transactions/LedgerTransactionQueryTests.kt index 2d9c80bd44..fe7e977962 100644 --- a/core/src/test/kotlin/net/corda/core/transactions/LedgerTransactionQueryTests.kt +++ b/core/src/test/kotlin/net/corda/core/transactions/LedgerTransactionQueryTests.kt @@ -10,6 +10,7 @@ import net.corda.core.identity.Party import net.corda.node.services.api.IdentityServiceInternal import net.corda.testing.* import net.corda.testing.contracts.DummyContract +import net.corda.testing.internal.rigorousMock import net.corda.testing.node.MockServices import org.junit.Before import org.junit.Rule diff --git a/core/src/test/kotlin/net/corda/core/transactions/TransactionEncumbranceTests.kt b/core/src/test/kotlin/net/corda/core/transactions/TransactionEncumbranceTests.kt index 1bdaa030ed..3e923c5a7d 100644 --- a/core/src/test/kotlin/net/corda/core/transactions/TransactionEncumbranceTests.kt +++ b/core/src/test/kotlin/net/corda/core/transactions/TransactionEncumbranceTests.kt @@ -12,6 +12,7 @@ import net.corda.finance.`issued by` import net.corda.finance.contracts.asset.Cash import net.corda.node.services.api.IdentityServiceInternal import net.corda.testing.* +import net.corda.testing.internal.rigorousMock import net.corda.testing.node.MockServices import net.corda.testing.node.ledger import org.junit.Rule diff --git a/core/src/test/kotlin/net/corda/core/transactions/TransactionTests.kt b/core/src/test/kotlin/net/corda/core/transactions/TransactionTests.kt index 9ef046072b..8191dce1ae 100644 --- a/core/src/test/kotlin/net/corda/core/transactions/TransactionTests.kt +++ b/core/src/test/kotlin/net/corda/core/transactions/TransactionTests.kt @@ -6,6 +6,7 @@ import net.corda.core.crypto.CompositeKey import net.corda.core.identity.Party import net.corda.testing.* import net.corda.testing.contracts.DummyContract +import net.corda.testing.internal.rigorousMock import org.junit.Rule import org.junit.Test import java.math.BigInteger diff --git a/docs/source/example-code/src/main/kotlin/net/corda/docs/tutorial/testdsl/TutorialTestDSL.kt b/docs/source/example-code/src/main/kotlin/net/corda/docs/tutorial/testdsl/TutorialTestDSL.kt index 82dc28b8c6..1fc5f4c832 100644 --- a/docs/source/example-code/src/main/kotlin/net/corda/docs/tutorial/testdsl/TutorialTestDSL.kt +++ b/docs/source/example-code/src/main/kotlin/net/corda/docs/tutorial/testdsl/TutorialTestDSL.kt @@ -14,6 +14,7 @@ import net.corda.finance.contracts.asset.CASH import net.corda.finance.contracts.asset.Cash import net.corda.node.services.api.IdentityServiceInternal import net.corda.testing.* +import net.corda.testing.internal.rigorousMock import net.corda.testing.node.MockServices import net.corda.testing.node.ledger import net.corda.testing.node.transaction diff --git a/experimental/src/test/kotlin/net/corda/finance/contracts/universal/Cap.kt b/experimental/src/test/kotlin/net/corda/finance/contracts/universal/Cap.kt index bb458188e6..ed12e6190c 100644 --- a/experimental/src/test/kotlin/net/corda/finance/contracts/universal/Cap.kt +++ b/experimental/src/test/kotlin/net/corda/finance/contracts/universal/Cap.kt @@ -9,6 +9,10 @@ import net.corda.finance.contracts.Frequency import net.corda.finance.contracts.Tenor import net.corda.node.services.api.IdentityServiceInternal import net.corda.testing.* +import net.corda.testing.dsl.EnforceVerifyOrFail +import net.corda.testing.dsl.TransactionDSL +import net.corda.testing.dsl.TransactionDSLInterpreter +import net.corda.testing.internal.rigorousMock import net.corda.testing.node.MockServices import net.corda.testing.node.transaction import org.junit.Ignore diff --git a/finance/src/test/java/net/corda/finance/contracts/asset/CashTestsJava.java b/finance/src/test/java/net/corda/finance/contracts/asset/CashTestsJava.java index 6702c92e4b..5d3f27286a 100644 --- a/finance/src/test/java/net/corda/finance/contracts/asset/CashTestsJava.java +++ b/finance/src/test/java/net/corda/finance/contracts/asset/CashTestsJava.java @@ -16,7 +16,7 @@ import static java.util.Collections.emptyList; import static net.corda.finance.Currencies.DOLLARS; import static net.corda.finance.Currencies.issuedBy; import static net.corda.testing.node.NodeTestUtils.transaction; -import static net.corda.testing.CoreTestUtils.rigorousMock; +import static net.corda.testing.internal.InternalTestUtilsKt.rigorousMock; import static net.corda.testing.TestConstants.DUMMY_NOTARY_NAME; import static org.mockito.Mockito.doReturn; diff --git a/finance/src/test/kotlin/net/corda/finance/contracts/CommercialPaperTests.kt b/finance/src/test/kotlin/net/corda/finance/contracts/CommercialPaperTests.kt index 14c4d2798f..dc011b5fa7 100644 --- a/finance/src/test/kotlin/net/corda/finance/contracts/CommercialPaperTests.kt +++ b/finance/src/test/kotlin/net/corda/finance/contracts/CommercialPaperTests.kt @@ -18,7 +18,11 @@ import net.corda.finance.`issued by` import net.corda.finance.contracts.asset.* import net.corda.node.services.api.IdentityServiceInternal import net.corda.testing.* -import net.corda.testing.contracts.VaultFiller +import net.corda.testing.dsl.EnforceVerifyOrFail +import net.corda.testing.dsl.TransactionDSL +import net.corda.testing.dsl.TransactionDSLInterpreter +import net.corda.testing.internal.rigorousMock +import net.corda.testing.internal.vault.VaultFiller import net.corda.testing.node.MockServices import net.corda.testing.node.MockServices.Companion.makeTestDatabaseAndMockServices import net.corda.testing.node.ledger diff --git a/finance/src/test/kotlin/net/corda/finance/contracts/asset/CashTests.kt b/finance/src/test/kotlin/net/corda/finance/contracts/asset/CashTests.kt index 946c8c1ea5..af3900486e 100644 --- a/finance/src/test/kotlin/net/corda/finance/contracts/asset/CashTests.kt +++ b/finance/src/test/kotlin/net/corda/finance/contracts/asset/CashTests.kt @@ -20,7 +20,12 @@ import net.corda.node.services.vault.NodeVaultService import net.corda.nodeapi.internal.persistence.CordaPersistence import net.corda.testing.* import net.corda.testing.contracts.DummyState -import net.corda.testing.contracts.VaultFiller +import net.corda.testing.internal.LogHelper +import net.corda.testing.dsl.EnforceVerifyOrFail +import net.corda.testing.dsl.TransactionDSL +import net.corda.testing.dsl.TransactionDSLInterpreter +import net.corda.testing.internal.rigorousMock +import net.corda.testing.internal.vault.VaultFiller import net.corda.testing.node.MockServices import net.corda.testing.node.MockServices.Companion.makeTestDatabaseAndMockServices import net.corda.testing.node.ledger diff --git a/finance/src/test/kotlin/net/corda/finance/contracts/asset/ObligationTests.kt b/finance/src/test/kotlin/net/corda/finance/contracts/asset/ObligationTests.kt index f8baae1aeb..73f1363d36 100644 --- a/finance/src/test/kotlin/net/corda/finance/contracts/asset/ObligationTests.kt +++ b/finance/src/test/kotlin/net/corda/finance/contracts/asset/ObligationTests.kt @@ -22,6 +22,8 @@ import net.corda.node.services.api.IdentityServiceInternal import net.corda.testing.* import net.corda.testing.contracts.DummyContract import net.corda.testing.contracts.DummyState +import net.corda.testing.dsl.* +import net.corda.testing.internal.rigorousMock import net.corda.testing.node.MockServices import net.corda.testing.node.ledger import net.corda.testing.node.transaction diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/Eventually.kt b/node-api/src/test/kotlin/net/corda/nodeapi/Eventually.kt similarity index 96% rename from testing/test-utils/src/main/kotlin/net/corda/testing/Eventually.kt rename to node-api/src/test/kotlin/net/corda/nodeapi/Eventually.kt index 693fffeca9..4c8136d1d3 100644 --- a/testing/test-utils/src/main/kotlin/net/corda/testing/Eventually.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/Eventually.kt @@ -1,4 +1,4 @@ -package net.corda.testing +package net.corda.nodeapi import java.time.Duration diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/NodeInfoFilesCopierTest.kt b/node-api/src/test/kotlin/net/corda/nodeapi/NodeInfoFilesCopierTest.kt index c14f2c854d..d2a18c7191 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/NodeInfoFilesCopierTest.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/NodeInfoFilesCopierTest.kt @@ -2,7 +2,6 @@ package net.corda.nodeapi import net.corda.cordform.CordformNode import net.corda.nodeapi.internal.NodeInfoFilesCopier -import net.corda.testing.eventually import org.junit.Before import org.junit.Rule import org.junit.Test diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/AttachmentsClassLoaderStaticContractTests.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/AttachmentsClassLoaderStaticContractTests.kt index f3a24002cd..d0dd03ad6d 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/AttachmentsClassLoaderStaticContractTests.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/AttachmentsClassLoaderStaticContractTests.kt @@ -14,6 +14,7 @@ import net.corda.core.transactions.TransactionBuilder import net.corda.node.internal.cordapp.CordappLoader import net.corda.node.internal.cordapp.CordappProviderImpl import net.corda.testing.* +import net.corda.testing.internal.rigorousMock import net.corda.testing.services.MockAttachmentStorage import org.junit.Assert.* import org.junit.Rule diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/AttachmentsClassLoaderTests.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/AttachmentsClassLoaderTests.kt index 1d624a32f3..bbf8e5ca21 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/AttachmentsClassLoaderTests.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/AttachmentsClassLoaderTests.kt @@ -19,6 +19,8 @@ import net.corda.nodeapi.internal.serialization.SerializeAsTokenContextImpl import net.corda.nodeapi.internal.serialization.attachmentsClassLoaderEnabledPropertyName import net.corda.nodeapi.internal.serialization.withTokenContext import net.corda.testing.* +import net.corda.testing.internal.kryoSpecific +import net.corda.testing.internal.rigorousMock import net.corda.testing.services.MockAttachmentStorage import org.apache.commons.io.IOUtils import org.junit.Assert.* diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/ContractAttachmentSerializerTest.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/ContractAttachmentSerializerTest.kt index 341ee3a162..e24dc671dd 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/ContractAttachmentSerializerTest.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/ContractAttachmentSerializerTest.kt @@ -5,6 +5,7 @@ import net.corda.core.identity.CordaX500Name import net.corda.core.serialization.* import net.corda.testing.* import net.corda.testing.contracts.DummyContract +import net.corda.testing.internal.rigorousMock import net.corda.testing.node.MockServices import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatThrownBy diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/CordaClassResolverTests.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/CordaClassResolverTests.kt index 654bf323e3..1743d9ee46 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/CordaClassResolverTests.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/CordaClassResolverTests.kt @@ -13,7 +13,7 @@ import net.corda.nodeapi.internal.AttachmentsClassLoaderTests import net.corda.nodeapi.internal.serialization.kryo.CordaKryo import net.corda.nodeapi.internal.serialization.kryo.KryoHeaderV0_1 import net.corda.testing.services.MockAttachmentStorage -import net.corda.testing.rigorousMock +import net.corda.testing.internal.rigorousMock import org.junit.Rule import org.junit.Test import org.junit.rules.ExpectedException diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/ListsSerializationTest.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/ListsSerializationTest.kt index 5663a78beb..d732033477 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/ListsSerializationTest.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/ListsSerializationTest.kt @@ -8,8 +8,8 @@ import net.corda.nodeapi.internal.serialization.amqp.DeserializationInput import net.corda.nodeapi.internal.serialization.amqp.Envelope import net.corda.nodeapi.internal.serialization.amqp.SerializerFactory import net.corda.nodeapi.internal.serialization.kryo.KryoHeaderV0_1 -import net.corda.testing.amqpSpecific -import net.corda.testing.kryoSpecific +import net.corda.testing.internal.amqpSpecific +import net.corda.testing.internal.kryoSpecific import net.corda.testing.SerializationEnvironmentRule import org.assertj.core.api.Assertions import org.junit.Assert.assertArrayEquals diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/MapsSerializationTest.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/MapsSerializationTest.kt index f726d0b97a..d2ba294d2b 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/MapsSerializationTest.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/MapsSerializationTest.kt @@ -9,8 +9,8 @@ import net.corda.core.serialization.serialize import net.corda.node.services.statemachine.SessionData import net.corda.nodeapi.internal.serialization.kryo.KryoHeaderV0_1 import net.corda.testing.SerializationEnvironmentRule -import net.corda.testing.amqpSpecific -import net.corda.testing.kryoSpecific +import net.corda.testing.internal.amqpSpecific +import net.corda.testing.internal.kryoSpecific import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.Assert.assertArrayEquals import org.junit.Rule diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/SerializationTokenTest.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/SerializationTokenTest.kt index a51f5934e1..70f165d9a4 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/SerializationTokenTest.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/SerializationTokenTest.kt @@ -8,7 +8,7 @@ import net.corda.core.utilities.OpaqueBytes import net.corda.nodeapi.internal.serialization.kryo.CordaKryo import net.corda.nodeapi.internal.serialization.kryo.DefaultKryoCustomizer import net.corda.nodeapi.internal.serialization.kryo.KryoHeaderV0_1 -import net.corda.testing.rigorousMock +import net.corda.testing.internal.rigorousMock import net.corda.testing.SerializationEnvironmentRule import org.assertj.core.api.Assertions.assertThat import org.junit.Before diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/SetsSerializationTest.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/SetsSerializationTest.kt index 243b73a803..9a910aeb3a 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/SetsSerializationTest.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/serialization/SetsSerializationTest.kt @@ -6,7 +6,7 @@ import net.corda.core.serialization.deserialize import net.corda.core.serialization.serialize import net.corda.node.services.statemachine.SessionData import net.corda.nodeapi.internal.serialization.kryo.KryoHeaderV0_1 -import net.corda.testing.kryoSpecific +import net.corda.testing.internal.kryoSpecific import net.corda.testing.SerializationEnvironmentRule import org.junit.Assert.assertArrayEquals import org.junit.Assert.assertEquals diff --git a/node/src/integration-test/kotlin/net/corda/node/amqp/AMQPBridgeTest.kt b/node/src/integration-test/kotlin/net/corda/node/amqp/AMQPBridgeTest.kt index 1e094f4194..4c2f0ee881 100644 --- a/node/src/integration-test/kotlin/net/corda/node/amqp/AMQPBridgeTest.kt +++ b/node/src/integration-test/kotlin/net/corda/node/amqp/AMQPBridgeTest.kt @@ -17,6 +17,7 @@ import net.corda.nodeapi.internal.ArtemisMessagingComponent import net.corda.nodeapi.internal.ArtemisMessagingComponent.Companion.P2P_QUEUE import net.corda.nodeapi.internal.crypto.loadKeyStore import net.corda.testing.* +import net.corda.testing.internal.rigorousMock import org.apache.activemq.artemis.api.core.Message.HDR_DUPLICATE_DETECTION_ID import org.apache.activemq.artemis.api.core.RoutingType import org.apache.activemq.artemis.api.core.SimpleString diff --git a/node/src/integration-test/kotlin/net/corda/node/amqp/ProtonWrapperTests.kt b/node/src/integration-test/kotlin/net/corda/node/amqp/ProtonWrapperTests.kt index 3f6c8444f7..871c7de400 100644 --- a/node/src/integration-test/kotlin/net/corda/node/amqp/ProtonWrapperTests.kt +++ b/node/src/integration-test/kotlin/net/corda/node/amqp/ProtonWrapperTests.kt @@ -21,6 +21,7 @@ import net.corda.node.services.messaging.ArtemisMessagingServer import net.corda.nodeapi.internal.ArtemisMessagingComponent.Companion.PEER_USER import net.corda.nodeapi.internal.crypto.loadKeyStore import net.corda.testing.* +import net.corda.testing.internal.rigorousMock import org.apache.activemq.artemis.api.core.RoutingType import org.junit.Assert.assertArrayEquals import org.junit.Rule diff --git a/node/src/integration-test/kotlin/net/corda/node/services/AttachmentLoadingTests.kt b/node/src/integration-test/kotlin/net/corda/node/services/AttachmentLoadingTests.kt index 60e781e9c4..7fdc7a6d06 100644 --- a/node/src/integration-test/kotlin/net/corda/node/services/AttachmentLoadingTests.kt +++ b/node/src/integration-test/kotlin/net/corda/node/services/AttachmentLoadingTests.kt @@ -26,7 +26,7 @@ import net.corda.testing.driver.NodeHandle import net.corda.testing.driver.driver import net.corda.testing.internal.withoutTestSerialization import net.corda.testing.services.MockAttachmentStorage -import net.corda.testing.rigorousMock +import net.corda.testing.internal.rigorousMock import org.junit.Assert.assertEquals import org.junit.Rule import org.junit.Test diff --git a/node/src/integration-test/kotlin/net/corda/node/services/network/NetworkMapTest.kt b/node/src/integration-test/kotlin/net/corda/node/services/network/NetworkMapTest.kt index 329e259714..251034a035 100644 --- a/node/src/integration-test/kotlin/net/corda/node/services/network/NetworkMapTest.kt +++ b/node/src/integration-test/kotlin/net/corda/node/services/network/NetworkMapTest.kt @@ -15,7 +15,7 @@ import net.corda.testing.BOB_NAME import net.corda.testing.driver.NodeHandle import net.corda.testing.driver.PortAllocation import net.corda.testing.node.internal.internalDriver -import net.corda.testing.node.network.NetworkMapServer +import net.corda.testing.node.internal.network.NetworkMapServer import org.assertj.core.api.Assertions.assertThat import org.junit.After import org.junit.Before diff --git a/node/src/integration-test/kotlin/net/corda/node/utilities/registration/NodeRegistrationTest.kt b/node/src/integration-test/kotlin/net/corda/node/utilities/registration/NodeRegistrationTest.kt index a59809eb8e..83526ba759 100644 --- a/node/src/integration-test/kotlin/net/corda/node/utilities/registration/NodeRegistrationTest.kt +++ b/node/src/integration-test/kotlin/net/corda/node/utilities/registration/NodeRegistrationTest.kt @@ -18,7 +18,7 @@ import net.corda.testing.SerializationEnvironmentRule import net.corda.testing.node.internal.CompatibilityZoneParams import net.corda.testing.driver.PortAllocation import net.corda.testing.node.internal.internalDriver -import net.corda.testing.node.network.NetworkMapServer +import net.corda.testing.node.internal.network.NetworkMapServer import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatThrownBy import org.bouncycastle.pkcs.PKCS10CertificationRequest diff --git a/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityAsNodeTest.kt b/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityAsNodeTest.kt index 94eb96a7a8..f8da5302a4 100644 --- a/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityAsNodeTest.kt +++ b/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityAsNodeTest.kt @@ -8,7 +8,6 @@ import net.corda.nodeapi.internal.ArtemisMessagingComponent.Companion.PEER_USER import net.corda.nodeapi.RPCApi import net.corda.nodeapi.internal.config.SSLConfiguration import net.corda.nodeapi.internal.crypto.* -import net.corda.testing.messaging.SimpleMQClient import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration import org.apache.activemq.artemis.api.core.ActiveMQClusterSecurityException import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException diff --git a/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityAsRPCTest.kt b/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityAsRPCTest.kt index d4cd7ca4e4..eab85f937a 100644 --- a/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityAsRPCTest.kt +++ b/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityAsRPCTest.kt @@ -1,7 +1,6 @@ package net.corda.services.messaging import net.corda.nodeapi.internal.config.User -import net.corda.testing.messaging.SimpleMQClient import org.junit.Test /** diff --git a/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityTest.kt b/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityTest.kt index cdbb84c8e8..5ec0dca2c4 100644 --- a/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityTest.kt +++ b/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityTest.kt @@ -27,7 +27,6 @@ import net.corda.nodeapi.internal.config.User import net.corda.nodeapi.internal.config.SSLConfiguration import net.corda.testing.* import net.corda.testing.node.internal.NodeBasedTest -import net.corda.testing.messaging.SimpleMQClient import net.corda.testing.node.startFlow import org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException import org.apache.activemq.artemis.api.core.ActiveMQSecurityException diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/messaging/SimpleMQClient.kt b/node/src/integration-test/kotlin/net/corda/services/messaging/SimpleMQClient.kt similarity index 98% rename from testing/test-utils/src/main/kotlin/net/corda/testing/messaging/SimpleMQClient.kt rename to node/src/integration-test/kotlin/net/corda/services/messaging/SimpleMQClient.kt index 235692b111..4257e7e3c0 100644 --- a/testing/test-utils/src/main/kotlin/net/corda/testing/messaging/SimpleMQClient.kt +++ b/node/src/integration-test/kotlin/net/corda/services/messaging/SimpleMQClient.kt @@ -1,4 +1,4 @@ -package net.corda.testing.messaging +package net.corda.services.messaging import net.corda.core.identity.CordaX500Name import net.corda.core.serialization.internal.nodeSerializationEnv diff --git a/node/src/test/java/net/corda/node/services/vault/VaultQueryJavaTests.java b/node/src/test/java/net/corda/node/services/vault/VaultQueryJavaTests.java index f8fd0950e7..9ab2c4a2b4 100644 --- a/node/src/test/java/net/corda/node/services/vault/VaultQueryJavaTests.java +++ b/node/src/test/java/net/corda/node/services/vault/VaultQueryJavaTests.java @@ -24,8 +24,8 @@ import net.corda.nodeapi.internal.persistence.CordaPersistence; import net.corda.nodeapi.internal.persistence.DatabaseTransaction; import net.corda.testing.SerializationEnvironmentRule; import net.corda.testing.TestIdentity; -import net.corda.testing.contracts.DummyLinearContract; -import net.corda.testing.contracts.VaultFiller; +import net.corda.testing.internal.vault.DummyLinearContract; +import net.corda.testing.internal.vault.VaultFiller; import net.corda.testing.node.MockServices; import org.junit.After; import org.junit.Before; @@ -45,7 +45,7 @@ import java.util.stream.StreamSupport; import static net.corda.core.node.services.vault.QueryCriteriaUtils.DEFAULT_PAGE_NUM; import static net.corda.core.node.services.vault.QueryCriteriaUtils.MAX_PAGE_SIZE; import static net.corda.core.utilities.ByteArrays.toHexString; -import static net.corda.testing.CoreTestUtils.rigorousMock; +import static net.corda.testing.internal.InternalTestUtilsKt.rigorousMock; import static net.corda.testing.TestConstants.BOC_NAME; import static net.corda.testing.TestConstants.CHARLIE_NAME; import static net.corda.testing.TestConstants.DUMMY_NOTARY_NAME; @@ -69,7 +69,7 @@ public class VaultQueryJavaTests { @Before public void setUp() throws CertificateException, InvalidAlgorithmParameterException { - List cordappPackages = Arrays.asList("net.corda.testing.contracts", "net.corda.finance.contracts.asset", CashSchemaV1.class.getPackage().getName()); + List cordappPackages = Arrays.asList("net.corda.testing.internal.vault", "net.corda.finance.contracts.asset", CashSchemaV1.class.getPackage().getName()); IdentityServiceInternal identitySvc = makeTestIdentityService(MEGA_CORP.getIdentity(), DUMMY_CASH_ISSUER_INFO.getIdentity(), DUMMY_NOTARY.getIdentity()); Pair databaseAndServices = makeTestDatabaseAndMockServices( cordappPackages, diff --git a/node/src/test/kotlin/net/corda/node/InteractiveShellTest.kt b/node/src/test/kotlin/net/corda/node/InteractiveShellTest.kt index c94dc637ab..eb3e5ba532 100644 --- a/node/src/test/kotlin/net/corda/node/InteractiveShellTest.kt +++ b/node/src/test/kotlin/net/corda/node/InteractiveShellTest.kt @@ -17,7 +17,7 @@ import net.corda.node.internal.configureDatabase import net.corda.testing.TestIdentity import net.corda.testing.node.MockServices import net.corda.testing.node.makeTestIdentityService -import net.corda.testing.rigorousMock +import net.corda.testing.internal.rigorousMock import org.junit.After import org.junit.Before import org.junit.Test diff --git a/node/src/test/kotlin/net/corda/node/messaging/InMemoryMessagingTests.kt b/node/src/test/kotlin/net/corda/node/messaging/InMemoryMessagingTests.kt index 5959c32ff2..f049b040e0 100644 --- a/node/src/test/kotlin/net/corda/node/messaging/InMemoryMessagingTests.kt +++ b/node/src/test/kotlin/net/corda/node/messaging/InMemoryMessagingTests.kt @@ -1,8 +1,10 @@ package net.corda.node.messaging +import net.corda.core.messaging.AllPossibleRecipients import net.corda.node.services.messaging.Message import net.corda.node.services.messaging.TopicStringValidator import net.corda.node.services.messaging.createMessage +import net.corda.testing.internal.rigorousMock import net.corda.testing.node.MockNetwork import org.junit.After import org.junit.Before @@ -73,7 +75,7 @@ class InMemoryMessagingTests { var counter = 0 listOf(node1, node2, node3).forEach { it.network.addMessageHandler { _, _ -> counter++ } } - node1.network.send(node2.network.createMessage("test.topic", data = bits), mockNet.messagingNetwork.everyoneOnline) + node1.network.send(node2.network.createMessage("test.topic", data = bits), rigorousMock()) mockNet.runNetwork(rounds = 1) assertEquals(3, counter) } 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 921637ba47..0af608e531 100644 --- a/node/src/test/kotlin/net/corda/node/messaging/TwoPartyTradeFlowTests.kt +++ b/node/src/test/kotlin/net/corda/node/messaging/TwoPartyTradeFlowTests.kt @@ -41,7 +41,12 @@ import net.corda.node.services.persistence.DBTransactionStorage import net.corda.node.services.persistence.checkpoints import net.corda.nodeapi.internal.persistence.CordaPersistence import net.corda.testing.* -import net.corda.testing.contracts.VaultFiller +import net.corda.testing.internal.LogHelper +import net.corda.testing.dsl.LedgerDSL +import net.corda.testing.dsl.TestLedgerDSLInterpreter +import net.corda.testing.dsl.TestTransactionDSLInterpreter +import net.corda.testing.internal.rigorousMock +import net.corda.testing.internal.vault.VaultFiller import net.corda.testing.node.* import org.assertj.core.api.Assertions.assertThat import org.junit.After diff --git a/node/src/test/kotlin/net/corda/node/services/events/NodeSchedulerServiceTest.kt b/node/src/test/kotlin/net/corda/node/services/events/NodeSchedulerServiceTest.kt index 4ae3dc09ad..d2998cf641 100644 --- a/node/src/test/kotlin/net/corda/node/services/events/NodeSchedulerServiceTest.kt +++ b/node/src/test/kotlin/net/corda/node/services/events/NodeSchedulerServiceTest.kt @@ -11,6 +11,7 @@ import net.corda.core.flows.FlowLogicRefFactory import net.corda.core.identity.AbstractParty import net.corda.core.identity.CordaX500Name import net.corda.core.identity.Party +import net.corda.core.internal.concurrent.doneFuture import net.corda.core.node.NodeInfo import net.corda.core.node.ServiceHub import net.corda.core.serialization.SingletonSerializeAsToken @@ -22,7 +23,6 @@ import net.corda.node.internal.cordapp.CordappLoader import net.corda.node.internal.cordapp.CordappProviderImpl import net.corda.node.services.api.MonitoringService import net.corda.node.services.api.ServiceHubInternal -import net.corda.node.services.network.NetworkMapCacheImpl import net.corda.node.services.persistence.DBCheckpointStorage import net.corda.node.services.statemachine.FlowLogicRefFactoryImpl import net.corda.node.services.statemachine.StateMachineManager @@ -30,11 +30,13 @@ import net.corda.node.services.statemachine.StateMachineManagerImpl import net.corda.node.services.vault.NodeVaultService import net.corda.node.utilities.AffinityExecutor import net.corda.node.internal.configureDatabase +import net.corda.node.services.api.NetworkMapCacheInternal import net.corda.node.services.config.NodeConfiguration import net.corda.nodeapi.internal.persistence.CordaPersistence import net.corda.nodeapi.internal.persistence.DatabaseConfig import net.corda.testing.* import net.corda.testing.contracts.DummyContract +import net.corda.testing.internal.rigorousMock import net.corda.testing.node.* import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties import net.corda.testing.services.MockAttachmentStorage @@ -107,7 +109,9 @@ class NodeSchedulerServiceTest : SingletonSerializeAsToken() { doReturn(configuration).whenever(it).configuration doReturn(MonitoringService(MetricRegistry())).whenever(it).monitoringService doReturn(validatedTransactions).whenever(it).validatedTransactions - doReturn(NetworkMapCacheImpl(MockNetworkMapCache(database), identityService)).whenever(it).networkMapCache + doReturn(rigorousMock().also { + doReturn(doneFuture(null)).whenever(it).nodeReady + }).whenever(it).networkMapCache doReturn(myInfo).whenever(it).myInfo doReturn(kms).whenever(it).keyManagementService doReturn(CordappProviderImpl(CordappLoader.createWithTestPackages(listOf("net.corda.testing.contracts")), MockAttachmentStorage())).whenever(it).cordappProvider diff --git a/node/src/test/kotlin/net/corda/node/services/messaging/ArtemisMessagingTests.kt b/node/src/test/kotlin/net/corda/node/services/messaging/ArtemisMessagingTests.kt index def1012235..5ddeddb6eb 100644 --- a/node/src/test/kotlin/net/corda/node/services/messaging/ArtemisMessagingTests.kt +++ b/node/src/test/kotlin/net/corda/node/services/messaging/ArtemisMessagingTests.kt @@ -18,6 +18,8 @@ import net.corda.node.utilities.AffinityExecutor.ServiceAffinityExecutor import net.corda.nodeapi.internal.persistence.CordaPersistence import net.corda.nodeapi.internal.persistence.DatabaseConfig import net.corda.testing.* +import net.corda.testing.internal.LogHelper +import net.corda.testing.internal.rigorousMock import net.corda.testing.node.MockServices.Companion.MOCK_VERSION_INFO import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties import org.assertj.core.api.Assertions.assertThat diff --git a/node/src/test/kotlin/net/corda/node/services/network/NetworkMapClientTest.kt b/node/src/test/kotlin/net/corda/node/services/network/NetworkMapClientTest.kt index 23bed3ec85..0cfa199402 100644 --- a/node/src/test/kotlin/net/corda/node/services/network/NetworkMapClientTest.kt +++ b/node/src/test/kotlin/net/corda/node/services/network/NetworkMapClientTest.kt @@ -9,7 +9,7 @@ import net.corda.node.services.network.TestNodeInfoFactory.createNodeInfo import net.corda.testing.DEV_TRUST_ROOT import net.corda.testing.SerializationEnvironmentRule import net.corda.testing.driver.PortAllocation -import net.corda.testing.node.network.NetworkMapServer +import net.corda.testing.node.internal.network.NetworkMapServer import org.assertj.core.api.Assertions.assertThat import org.junit.After import org.junit.Before diff --git a/node/src/test/kotlin/net/corda/node/services/persistence/DBCheckpointStorageTests.kt b/node/src/test/kotlin/net/corda/node/services/persistence/DBCheckpointStorageTests.kt index 41190a8355..e6326128bf 100644 --- a/node/src/test/kotlin/net/corda/node/services/persistence/DBCheckpointStorageTests.kt +++ b/node/src/test/kotlin/net/corda/node/services/persistence/DBCheckpointStorageTests.kt @@ -8,10 +8,10 @@ import net.corda.node.services.transactions.PersistentUniquenessProvider import net.corda.node.internal.configureDatabase import net.corda.nodeapi.internal.persistence.CordaPersistence import net.corda.nodeapi.internal.persistence.DatabaseConfig -import net.corda.testing.LogHelper +import net.corda.testing.internal.LogHelper import net.corda.testing.SerializationEnvironmentRule import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties -import net.corda.testing.rigorousMock +import net.corda.testing.internal.rigorousMock import org.assertj.core.api.Assertions.assertThat import org.junit.After import org.junit.Before diff --git a/node/src/test/kotlin/net/corda/node/services/persistence/DBTransactionStorageTests.kt b/node/src/test/kotlin/net/corda/node/services/persistence/DBTransactionStorageTests.kt index 7defd484ab..3f559113da 100644 --- a/node/src/test/kotlin/net/corda/node/services/persistence/DBTransactionStorageTests.kt +++ b/node/src/test/kotlin/net/corda/node/services/persistence/DBTransactionStorageTests.kt @@ -13,6 +13,8 @@ import net.corda.node.internal.configureDatabase import net.corda.nodeapi.internal.persistence.CordaPersistence import net.corda.nodeapi.internal.persistence.DatabaseConfig import net.corda.testing.* +import net.corda.testing.internal.LogHelper +import net.corda.testing.internal.rigorousMock import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties import org.assertj.core.api.Assertions.assertThat import org.junit.After diff --git a/node/src/test/kotlin/net/corda/node/services/persistence/HibernateConfigurationTest.kt b/node/src/test/kotlin/net/corda/node/services/persistence/HibernateConfigurationTest.kt index 2d144d4520..6b56a5d291 100644 --- a/node/src/test/kotlin/net/corda/node/services/persistence/HibernateConfigurationTest.kt +++ b/node/src/test/kotlin/net/corda/node/services/persistence/HibernateConfigurationTest.kt @@ -37,11 +37,12 @@ import net.corda.nodeapi.internal.persistence.CordaPersistence import net.corda.nodeapi.internal.persistence.DatabaseConfig import net.corda.nodeapi.internal.persistence.HibernateConfiguration import net.corda.testing.* -import net.corda.testing.contracts.* +import net.corda.testing.internal.rigorousMock +import net.corda.testing.internal.vault.VaultFiller import net.corda.testing.node.MockServices import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties -import net.corda.testing.schemas.DummyLinearStateSchemaV1 -import net.corda.testing.schemas.DummyLinearStateSchemaV2 +import net.corda.testing.internal.vault.DummyLinearStateSchemaV1 +import net.corda.testing.internal.vault.DummyLinearStateSchemaV2 import org.assertj.core.api.Assertions import org.assertj.core.api.Assertions.assertThat import org.hibernate.SessionFactory @@ -92,7 +93,7 @@ class HibernateConfigurationTest { @Before fun setUp() { - val cordappPackages = listOf("net.corda.testing.contracts", "net.corda.finance.contracts.asset") + val cordappPackages = listOf("net.corda.testing.internal.vault", "net.corda.finance.contracts.asset") bankServices = MockServices(cordappPackages, rigorousMock(), BOC.name, BOC_KEY) issuerServices = MockServices(cordappPackages, rigorousMock(), dummyCashIssuer) notaryServices = MockServices(cordappPackages, rigorousMock(), dummyNotary) diff --git a/node/src/test/kotlin/net/corda/node/services/persistence/NodeAttachmentStorageTest.kt b/node/src/test/kotlin/net/corda/node/services/persistence/NodeAttachmentStorageTest.kt index d21cd6d6db..5995f3c177 100644 --- a/node/src/test/kotlin/net/corda/node/services/persistence/NodeAttachmentStorageTest.kt +++ b/node/src/test/kotlin/net/corda/node/services/persistence/NodeAttachmentStorageTest.kt @@ -17,9 +17,9 @@ import net.corda.node.services.transactions.PersistentUniquenessProvider import net.corda.node.internal.configureDatabase import net.corda.nodeapi.internal.persistence.CordaPersistence import net.corda.nodeapi.internal.persistence.DatabaseConfig -import net.corda.testing.LogHelper +import net.corda.testing.internal.LogHelper import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties -import net.corda.testing.rigorousMock +import net.corda.testing.internal.rigorousMock import org.junit.After import org.junit.Before import org.junit.Ignore diff --git a/node/src/test/kotlin/net/corda/node/services/schema/HibernateObserverTests.kt b/node/src/test/kotlin/net/corda/node/services/schema/HibernateObserverTests.kt index 16fa18453a..f40fa4a6ba 100644 --- a/node/src/test/kotlin/net/corda/node/services/schema/HibernateObserverTests.kt +++ b/node/src/test/kotlin/net/corda/node/services/schema/HibernateObserverTests.kt @@ -15,11 +15,11 @@ import net.corda.node.services.api.SchemaService import net.corda.node.internal.configureDatabase import net.corda.nodeapi.internal.persistence.DatabaseConfig import net.corda.nodeapi.internal.persistence.DatabaseTransactionManager -import net.corda.testing.LogHelper +import net.corda.testing.internal.LogHelper import net.corda.testing.TestIdentity import net.corda.testing.contracts.DummyContract import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties -import net.corda.testing.rigorousMock +import net.corda.testing.internal.rigorousMock import org.junit.After import org.junit.Before import org.junit.Test diff --git a/node/src/test/kotlin/net/corda/node/services/schema/NodeSchemaServiceTest.kt b/node/src/test/kotlin/net/corda/node/services/schema/NodeSchemaServiceTest.kt index 27a363864f..5a2a81913e 100644 --- a/node/src/test/kotlin/net/corda/node/services/schema/NodeSchemaServiceTest.kt +++ b/node/src/test/kotlin/net/corda/node/services/schema/NodeSchemaServiceTest.kt @@ -12,7 +12,7 @@ import net.corda.node.services.api.ServiceHubInternal import net.corda.testing.driver.NodeHandle import net.corda.testing.driver.driver import net.corda.testing.node.MockNetwork -import net.corda.testing.schemas.DummyLinearStateSchemaV1 +import net.corda.testing.internal.vault.DummyLinearStateSchemaV1 import org.hibernate.annotations.Cascade import org.hibernate.annotations.CascadeType import org.junit.Test diff --git a/node/src/test/kotlin/net/corda/node/services/statemachine/FlowFrameworkTests.kt b/node/src/test/kotlin/net/corda/node/services/statemachine/FlowFrameworkTests.kt index 90714adc40..b5ba9320ca 100644 --- a/node/src/test/kotlin/net/corda/node/services/statemachine/FlowFrameworkTests.kt +++ b/node/src/test/kotlin/net/corda/node/services/statemachine/FlowFrameworkTests.kt @@ -31,6 +31,7 @@ import net.corda.node.services.persistence.checkpoints import net.corda.testing.* import net.corda.testing.contracts.DummyContract import net.corda.testing.contracts.DummyState +import net.corda.testing.internal.LogHelper import net.corda.testing.node.InMemoryMessagingNetwork.MessageTransfer import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin import net.corda.testing.node.MockNetwork diff --git a/node/src/test/kotlin/net/corda/node/services/transactions/DistributedImmutableMapTests.kt b/node/src/test/kotlin/net/corda/node/services/transactions/DistributedImmutableMapTests.kt index ff8a0780c1..7443507cb8 100644 --- a/node/src/test/kotlin/net/corda/node/services/transactions/DistributedImmutableMapTests.kt +++ b/node/src/test/kotlin/net/corda/node/services/transactions/DistributedImmutableMapTests.kt @@ -13,11 +13,11 @@ import net.corda.core.utilities.getOrThrow import net.corda.node.internal.configureDatabase import net.corda.nodeapi.internal.persistence.CordaPersistence import net.corda.nodeapi.internal.persistence.DatabaseConfig -import net.corda.testing.LogHelper +import net.corda.testing.internal.LogHelper import net.corda.testing.SerializationEnvironmentRule import net.corda.testing.freeLocalHostAndPort import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties -import net.corda.testing.rigorousMock +import net.corda.testing.internal.rigorousMock import org.junit.After import org.junit.Before import org.junit.Rule diff --git a/node/src/test/kotlin/net/corda/node/services/transactions/PersistentUniquenessProviderTests.kt b/node/src/test/kotlin/net/corda/node/services/transactions/PersistentUniquenessProviderTests.kt index 1c26932b19..f4d03c9c39 100644 --- a/node/src/test/kotlin/net/corda/node/services/transactions/PersistentUniquenessProviderTests.kt +++ b/node/src/test/kotlin/net/corda/node/services/transactions/PersistentUniquenessProviderTests.kt @@ -7,6 +7,8 @@ import net.corda.node.internal.configureDatabase import net.corda.nodeapi.internal.persistence.CordaPersistence import net.corda.nodeapi.internal.persistence.DatabaseConfig import net.corda.testing.* +import net.corda.testing.internal.LogHelper +import net.corda.testing.internal.rigorousMock import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties import org.junit.After import org.junit.Before diff --git a/node/src/test/kotlin/net/corda/node/services/vault/NodeVaultServiceTest.kt b/node/src/test/kotlin/net/corda/node/services/vault/NodeVaultServiceTest.kt index 3d08fef1e7..bb7a01c77a 100644 --- a/node/src/test/kotlin/net/corda/node/services/vault/NodeVaultServiceTest.kt +++ b/node/src/test/kotlin/net/corda/node/services/vault/NodeVaultServiceTest.kt @@ -31,7 +31,9 @@ import net.corda.finance.utils.sumCash import net.corda.node.services.api.IdentityServiceInternal import net.corda.nodeapi.internal.persistence.CordaPersistence import net.corda.testing.* -import net.corda.testing.contracts.VaultFiller +import net.corda.testing.internal.LogHelper +import net.corda.testing.internal.rigorousMock +import net.corda.testing.internal.vault.VaultFiller import net.corda.testing.node.MockServices import net.corda.testing.node.makeTestIdentityService import org.assertj.core.api.Assertions.assertThat diff --git a/node/src/test/kotlin/net/corda/node/services/vault/VaultQueryTests.kt b/node/src/test/kotlin/net/corda/node/services/vault/VaultQueryTests.kt index 84ff1a5bed..836939050e 100644 --- a/node/src/test/kotlin/net/corda/node/services/vault/VaultQueryTests.kt +++ b/node/src/test/kotlin/net/corda/node/services/vault/VaultQueryTests.kt @@ -26,11 +26,14 @@ import net.corda.node.internal.configureDatabase import net.corda.nodeapi.internal.persistence.CordaPersistence import net.corda.nodeapi.internal.persistence.DatabaseConfig import net.corda.testing.* -import net.corda.testing.contracts.* +import net.corda.testing.internal.rigorousMock +import net.corda.testing.internal.vault.DUMMY_LINEAR_CONTRACT_PROGRAM_ID +import net.corda.testing.internal.vault.DummyLinearContract +import net.corda.testing.internal.vault.VaultFiller import net.corda.testing.node.MockServices import net.corda.testing.node.MockServices.Companion.makeTestDatabaseAndMockServices import net.corda.testing.node.makeTestIdentityService -import net.corda.testing.schemas.DummyLinearStateSchemaV1 +import net.corda.testing.internal.vault.DummyLinearStateSchemaV1 import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.* diff --git a/node/src/test/kotlin/net/corda/node/services/vault/VaultSoftLockManagerTest.kt b/node/src/test/kotlin/net/corda/node/services/vault/VaultSoftLockManagerTest.kt index 66f4973877..f55943c9f6 100644 --- a/node/src/test/kotlin/net/corda/node/services/vault/VaultSoftLockManagerTest.kt +++ b/node/src/test/kotlin/net/corda/node/services/vault/VaultSoftLockManagerTest.kt @@ -28,7 +28,7 @@ import net.corda.node.services.api.VaultServiceInternal import net.corda.nodeapi.internal.persistence.HibernateConfiguration import net.corda.testing.chooseIdentity import net.corda.testing.node.MockNetwork -import net.corda.testing.rigorousMock +import net.corda.testing.internal.rigorousMock import net.corda.testing.node.MockNodeParameters import net.corda.testing.node.startFlow import org.junit.After diff --git a/node/src/test/kotlin/net/corda/node/services/vault/VaultWithCashTest.kt b/node/src/test/kotlin/net/corda/node/services/vault/VaultWithCashTest.kt index b68d555d5b..cac2e8db20 100644 --- a/node/src/test/kotlin/net/corda/node/services/vault/VaultWithCashTest.kt +++ b/node/src/test/kotlin/net/corda/node/services/vault/VaultWithCashTest.kt @@ -21,7 +21,9 @@ import net.corda.finance.contracts.getCashBalance import net.corda.finance.schemas.CashSchemaV1 import net.corda.nodeapi.internal.persistence.CordaPersistence import net.corda.testing.* -import net.corda.testing.contracts.* +import net.corda.testing.internal.LogHelper +import net.corda.testing.internal.rigorousMock +import net.corda.testing.internal.vault.* import net.corda.testing.node.MockServices import net.corda.testing.node.MockServices.Companion.makeTestDatabaseAndMockServices import net.corda.testing.node.makeTestIdentityService @@ -39,7 +41,7 @@ import kotlin.test.fail class VaultWithCashTest { private companion object { - val cordappPackages = listOf("net.corda.testing.contracts", "net.corda.finance.contracts.asset", CashSchemaV1::class.packageName) + val cordappPackages = listOf("net.corda.testing.internal.vault", "net.corda.finance.contracts.asset", CashSchemaV1::class.packageName) val BOB = TestIdentity(BOB_NAME, 80).party val dummyCashIssuer = TestIdentity(CordaX500Name("Snake Oil Issuer", "London", "GB"), 10) val DUMMY_CASH_ISSUER = dummyCashIssuer.ref(1) diff --git a/node/src/test/kotlin/net/corda/node/utilities/ObservablesTests.kt b/node/src/test/kotlin/net/corda/node/utilities/ObservablesTests.kt index f48a38ac0c..91210f052a 100644 --- a/node/src/test/kotlin/net/corda/node/utilities/ObservablesTests.kt +++ b/node/src/test/kotlin/net/corda/node/utilities/ObservablesTests.kt @@ -6,7 +6,7 @@ import net.corda.core.internal.tee import net.corda.node.internal.configureDatabase import net.corda.nodeapi.internal.persistence.* import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties -import net.corda.testing.rigorousMock +import net.corda.testing.internal.rigorousMock import org.assertj.core.api.Assertions.assertThat import org.junit.After import org.junit.Test diff --git a/node/src/test/kotlin/net/corda/node/utilities/registration/NetworkRegistrationHelperTest.kt b/node/src/test/kotlin/net/corda/node/utilities/registration/NetworkRegistrationHelperTest.kt index 94f2c181ff..50922e9fde 100644 --- a/node/src/test/kotlin/net/corda/node/utilities/registration/NetworkRegistrationHelperTest.kt +++ b/node/src/test/kotlin/net/corda/node/utilities/registration/NetworkRegistrationHelperTest.kt @@ -14,7 +14,7 @@ import net.corda.nodeapi.internal.crypto.X509Utilities import net.corda.nodeapi.internal.crypto.getX509Certificate import net.corda.nodeapi.internal.crypto.loadKeyStore import net.corda.testing.ALICE_NAME -import net.corda.testing.rigorousMock +import net.corda.testing.internal.rigorousMock import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.Before import org.junit.Rule diff --git a/samples/irs-demo/cordapp/src/test/kotlin/net/corda/irs/api/NodeInterestRatesTest.kt b/samples/irs-demo/cordapp/src/test/kotlin/net/corda/irs/api/NodeInterestRatesTest.kt index 019b91c128..1cbbadd253 100644 --- a/samples/irs-demo/cordapp/src/test/kotlin/net/corda/irs/api/NodeInterestRatesTest.kt +++ b/samples/irs-demo/cordapp/src/test/kotlin/net/corda/irs/api/NodeInterestRatesTest.kt @@ -20,6 +20,8 @@ import net.corda.nodeapi.internal.persistence.CordaPersistence import net.corda.nodeapi.internal.persistence.DatabaseConfig import net.corda.testing.* import net.corda.testing.internal.withoutTestSerialization +import net.corda.testing.internal.LogHelper +import net.corda.testing.internal.rigorousMock import net.corda.testing.node.* import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties import org.junit.After diff --git a/samples/irs-demo/cordapp/src/test/kotlin/net/corda/irs/contract/IRSTests.kt b/samples/irs-demo/cordapp/src/test/kotlin/net/corda/irs/contract/IRSTests.kt index 4a55ce11f2..b0d72e4917 100644 --- a/samples/irs-demo/cordapp/src/test/kotlin/net/corda/irs/contract/IRSTests.kt +++ b/samples/irs-demo/cordapp/src/test/kotlin/net/corda/irs/contract/IRSTests.kt @@ -25,6 +25,8 @@ import net.corda.finance.contracts.PaymentRule import net.corda.finance.contracts.Tenor import net.corda.node.services.api.IdentityServiceInternal import net.corda.testing.* +import net.corda.testing.dsl.* +import net.corda.testing.internal.rigorousMock import net.corda.testing.node.MockServices import net.corda.testing.node.ledger import net.corda.testing.node.transaction diff --git a/samples/network-visualiser/src/test/kotlin/net/corda/netmap/simulation/IRSSimulationTest.kt b/samples/network-visualiser/src/test/kotlin/net/corda/netmap/simulation/IRSSimulationTest.kt index 6da9d13091..424071d5b3 100644 --- a/samples/network-visualiser/src/test/kotlin/net/corda/netmap/simulation/IRSSimulationTest.kt +++ b/samples/network-visualiser/src/test/kotlin/net/corda/netmap/simulation/IRSSimulationTest.kt @@ -1,7 +1,7 @@ package net.corda.netmap.simulation import net.corda.core.utilities.getOrThrow -import net.corda.testing.LogHelper +import net.corda.testing.internal.LogHelper import org.junit.Test class IRSSimulationTest { diff --git a/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/TraderDemoClientApi.kt b/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/TraderDemoClientApi.kt index 9dde805ec6..7c2a65c031 100644 --- a/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/TraderDemoClientApi.kt +++ b/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/TraderDemoClientApi.kt @@ -18,7 +18,7 @@ import net.corda.finance.contracts.getCashBalance import net.corda.finance.flows.CashIssueFlow import net.corda.finance.flows.CashPaymentFlow import net.corda.node.services.vault.VaultSchemaV1 -import net.corda.testing.contracts.VaultFiller.Companion.calculateRandomlySizedAmounts +import net.corda.testing.internal.vault.VaultFiller.Companion.calculateRandomlySizedAmounts import net.corda.traderdemo.flow.CommercialPaperIssueFlow import net.corda.traderdemo.flow.SellerFlow import java.util.* diff --git a/samples/trader-demo/src/test/kotlin/net/corda/traderdemo/TransactionGraphSearchTests.kt b/samples/trader-demo/src/test/kotlin/net/corda/traderdemo/TransactionGraphSearchTests.kt index eff4a70136..bf36525538 100644 --- a/samples/trader-demo/src/test/kotlin/net/corda/traderdemo/TransactionGraphSearchTests.kt +++ b/samples/trader-demo/src/test/kotlin/net/corda/traderdemo/TransactionGraphSearchTests.kt @@ -9,6 +9,7 @@ import net.corda.core.transactions.WireTransaction import net.corda.testing.* import net.corda.testing.contracts.DummyContract import net.corda.testing.contracts.DummyState +import net.corda.testing.internal.rigorousMock import net.corda.testing.node.MockServices import net.corda.testing.node.MockTransactionStorage import org.junit.Rule diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/InMemoryMessagingNetwork.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/InMemoryMessagingNetwork.kt index 427179a1ef..5d805a22b4 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/InMemoryMessagingNetwork.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/InMemoryMessagingNetwork.kt @@ -42,8 +42,8 @@ import kotlin.concurrent.thread * a service is addressed. */ @ThreadSafe -class InMemoryMessagingNetwork( - val sendManuallyPumped: Boolean, +class InMemoryMessagingNetwork internal constructor( + private val sendManuallyPumped: Boolean, private val servicePeerAllocationStrategy: ServicePeerAllocationStrategy = InMemoryMessagingNetwork.ServicePeerAllocationStrategy.Random(), private val messagesInFlight: ReusableLatch = ReusableLatch() ) : SingletonSerializeAsToken() { @@ -91,7 +91,7 @@ class InMemoryMessagingNetwork( /** * Creates a node at the given address: useful if you want to recreate a node to simulate a restart. * - * @param manuallyPumped if set to true, then you are expected to call the [InMemoryMessaging.pump] method on the [InMemoryMessaging] + * @param manuallyPumped if set to true, then you are expected to call [InMemoryMessaging.pumpReceive] * in order to cause the delivery of a single message, which will occur on the thread of the caller. If set to false * then this class will set up a background thread to deliver messages asynchronously, if the handler specifies no * executor. @@ -150,9 +150,6 @@ class InMemoryMessagingNetwork( } } - - val everyoneOnline: AllPossibleRecipients = object : AllPossibleRecipients {} - fun stop() { val nodes = synchronized(this) { counter = -1 @@ -223,7 +220,7 @@ class InMemoryMessagingNetwork( return transfer } - fun pumpSendInternal(transfer: MessageTransfer) { + private fun pumpSendInternal(transfer: MessageTransfer) { when (transfer.recipients) { is PeerHandle -> getQueueForPeerHandle(transfer.recipients).add(transfer) is ServiceHandle -> { @@ -268,8 +265,8 @@ class InMemoryMessagingNetwork( private val peerHandle: PeerHandle, private val executor: AffinityExecutor, private val database: CordaPersistence) : SingletonSerializeAsToken(), MessagingService { - inner class Handler(val topicSession: TopicSession, - val callback: (ReceivedMessage, MessageHandlerRegistration) -> Unit) : MessageHandlerRegistration + private inner class Handler(val topicSession: TopicSession, + val callback: (ReceivedMessage, MessageHandlerRegistration) -> Unit) : MessageHandlerRegistration @Volatile private var running = true diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNetworkMapCache.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNetworkMapCache.kt deleted file mode 100644 index 654b99bb12..0000000000 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNetworkMapCache.kt +++ /dev/null @@ -1,39 +0,0 @@ -package net.corda.testing.node - -import net.corda.core.concurrent.CordaFuture -import net.corda.core.crypto.entropyToKeyPair -import net.corda.core.identity.CordaX500Name -import net.corda.core.internal.concurrent.doneFuture -import net.corda.core.node.NodeInfo -import net.corda.core.node.services.NetworkMapCache -import net.corda.core.utilities.NetworkHostAndPort -import net.corda.node.services.config.NodeConfiguration -import net.corda.node.services.network.PersistentNetworkMapCache -import net.corda.nodeapi.internal.persistence.CordaPersistence -import net.corda.testing.getTestPartyAndCertificate -import rx.Observable -import rx.subjects.PublishSubject -import java.math.BigInteger - -/** - * Network map cache with no backing map service. - */ -class MockNetworkMapCache(database: CordaPersistence) : PersistentNetworkMapCache(database, emptyList()) { - private companion object { - val BANK_C = getTestPartyAndCertificate(CordaX500Name(organisation = "Bank C", locality = "London", country = "GB"), entropyToKeyPair(BigInteger.valueOf(1000)).public) - val BANK_D = getTestPartyAndCertificate(CordaX500Name(organisation = "Bank D", locality = "London", country = "GB"), entropyToKeyPair(BigInteger.valueOf(2000)).public) - val BANK_C_ADDR = NetworkHostAndPort("bankC", 8080) - val BANK_D_ADDR = NetworkHostAndPort("bankD", 8080) - } - - override val changed: Observable = PublishSubject.create() - override val nodeReady: CordaFuture get() = doneFuture(null) - - init { - val mockNodeA = NodeInfo(listOf(BANK_C_ADDR), listOf(BANK_C), 1, serial = 1L) - val mockNodeB = NodeInfo(listOf(BANK_D_ADDR), listOf(BANK_D), 1, serial = 1L) - addNode(mockNodeA) - addNode(mockNodeB) - } -} - diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNode.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNode.kt index 1bd6d87f76..dde3cc1224 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNode.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNode.kt @@ -48,7 +48,7 @@ import net.corda.testing.common.internal.testNetworkParameters import net.corda.testing.internal.testThreadFactory import net.corda.testing.node.MockServices.Companion.MOCK_VERSION_INFO import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties -import net.corda.testing.rigorousMock +import net.corda.testing.internal.rigorousMock import net.corda.testing.setGlobalSerialization import org.apache.activemq.artemis.utils.ReusableLatch import org.apache.sshd.common.util.security.SecurityUtils diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/NodeTestUtils.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/NodeTestUtils.kt index d54d025af7..b4dd36315a 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/NodeTestUtils.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/NodeTestUtils.kt @@ -16,6 +16,7 @@ import net.corda.core.transactions.TransactionBuilder import net.corda.core.utilities.getOrThrow import net.corda.node.services.api.StartedNodeServices import net.corda.testing.* +import net.corda.testing.dsl.* /** * Creates and tests a ledger built by the passed in dsl. diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/network/NetworkMapServer.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/network/NetworkMapServer.kt similarity index 99% rename from testing/node-driver/src/main/kotlin/net/corda/testing/node/network/NetworkMapServer.kt rename to testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/network/NetworkMapServer.kt index b9ca504279..9d88561798 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/network/NetworkMapServer.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/network/NetworkMapServer.kt @@ -1,4 +1,4 @@ -package net.corda.testing.node.network +package net.corda.testing.node.internal.network import net.corda.core.crypto.* import net.corda.core.internal.cert diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/CoreTestUtils.kt b/testing/test-utils/src/main/kotlin/net/corda/testing/CoreTestUtils.kt index c68e470653..f133a9557d 100644 --- a/testing/test-utils/src/main/kotlin/net/corda/testing/CoreTestUtils.kt +++ b/testing/test-utils/src/main/kotlin/net/corda/testing/CoreTestUtils.kt @@ -13,26 +13,20 @@ import net.corda.core.internal.cert import net.corda.core.internal.x500Name import net.corda.core.node.NodeInfo import net.corda.core.utilities.NetworkHostAndPort -import net.corda.core.utilities.loggerFor import net.corda.node.services.config.configureDevKeyAndTrustStores import net.corda.nodeapi.internal.config.SSLConfiguration import net.corda.nodeapi.internal.crypto.CertificateAndKeyPair import net.corda.nodeapi.internal.crypto.CertificateType import net.corda.nodeapi.internal.crypto.X509CertificateFactory import net.corda.nodeapi.internal.crypto.X509Utilities -import net.corda.nodeapi.internal.serialization.amqp.AMQP_ENABLED import org.bouncycastle.asn1.x509.GeneralName import org.bouncycastle.asn1.x509.GeneralSubtree import org.bouncycastle.asn1.x509.NameConstraints import org.bouncycastle.cert.X509CertificateHolder -import org.mockito.Mockito.mock -import org.mockito.internal.stubbing.answers.ThrowsException -import java.lang.reflect.Modifier import java.math.BigInteger import java.nio.file.Files import java.security.KeyPair import java.security.PublicKey -import java.util.* import java.util.concurrent.atomic.AtomicInteger /** @@ -80,7 +74,7 @@ fun freePort(): Int = freePortCounter.getAndAccumulate(0) { prev, _ -> 30000 + ( */ fun getFreeLocalPorts(hostName: String, numberToAlloc: Int): List { val freePort = freePortCounter.getAndAccumulate(0) { prev, _ -> 30000 + (prev - 30000 + numberToAlloc) % 10000 } - return (freePort until freePort + numberToAlloc).map { NetworkHostAndPort(hostName, it) } + return (0 until numberToAlloc).map { NetworkHostAndPort(hostName, freePort + it) } } fun configureTestSSL(legalName: CordaX500Name): SSLConfiguration = object : SSLConfiguration { @@ -140,20 +134,6 @@ class TestIdentity(val name: CordaX500Name, val keyPair: KeyPair) { fun ref(vararg bytes: Byte): PartyAndReference = party.ref(*bytes) } -@Suppress("unused") -inline fun T.kryoSpecific(reason: String, function: () -> Unit) = if (!AMQP_ENABLED) { - function() -} else { - loggerFor().info("Ignoring Kryo specific test, reason: $reason") -} - -@Suppress("unused") -inline fun T.amqpSpecific(reason: String, function: () -> Unit) = if (AMQP_ENABLED) { - function() -} else { - loggerFor().info("Ignoring AMQP specific test, reason: $reason") -} - /** * Until we have proper handling of multiple identities per node, for tests we use the first identity as special one. * TODO: Should be removed after multiple identities are introduced. @@ -170,25 +150,3 @@ fun NodeInfo.singleIdentityAndCert(): PartyAndCertificate = legalIdentitiesAndCe * Extract a single identity from the node info. Throws an error if the node has multiple identities. */ fun NodeInfo.singleIdentity(): Party = singleIdentityAndCert().party - -/** - * A method on a mock was called, but no behaviour was previously specified for that method. - * You can use [com.nhaarman.mockito_kotlin.doReturn] or similar to specify behaviour, see Mockito documentation for details. - */ -class UndefinedMockBehaviorException(message: String) : RuntimeException(message) - -inline fun rigorousMock() = rigorousMock(T::class.java) -/** - * Create a Mockito mock that has [UndefinedMockBehaviorException] as the default behaviour of all abstract methods, - * and [org.mockito.invocation.InvocationOnMock.callRealMethod] as the default for all concrete methods. - * @param T the type to mock. Note if you want concrete methods of a Kotlin interface to be invoked, - * it won't work unless you mock a (trivial) abstract implementation of that interface instead. - */ -fun rigorousMock(clazz: Class): T = mock(clazz) { - if (Modifier.isAbstract(it.method.modifiers)) { - // Use ThrowsException to hack the stack trace, and lazily so we can customise the message: - ThrowsException(UndefinedMockBehaviorException("Please specify what should happen when '${it.method}' is called, or don't call it. Args: ${Arrays.toString(it.arguments)}")).answer(it) - } else { - it.callRealMethod() - } -} diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/SerializationTestHelpers.kt b/testing/test-utils/src/main/kotlin/net/corda/testing/SerializationTestHelpers.kt index a0061db572..8aa5a0cc61 100644 --- a/testing/test-utils/src/main/kotlin/net/corda/testing/SerializationTestHelpers.kt +++ b/testing/test-utils/src/main/kotlin/net/corda/testing/SerializationTestHelpers.kt @@ -9,6 +9,7 @@ import net.corda.nodeapi.internal.serialization.* import net.corda.nodeapi.internal.serialization.amqp.AMQPClientSerializationScheme import net.corda.nodeapi.internal.serialization.amqp.AMQPServerSerializationScheme import net.corda.testing.common.internal.asContextEnv +import net.corda.testing.internal.rigorousMock import net.corda.testing.internal.testThreadFactory import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnector import org.junit.rules.TestRule diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/TestDependencyInjectionBase.kt b/testing/test-utils/src/main/kotlin/net/corda/testing/TestDependencyInjectionBase.kt deleted file mode 100644 index 27a16a64f9..0000000000 --- a/testing/test-utils/src/main/kotlin/net/corda/testing/TestDependencyInjectionBase.kt +++ /dev/null @@ -1,10 +0,0 @@ -package net.corda.testing - -import org.junit.Rule - -@Deprecated("Instead of extending this class, use SerializationEnvironmentRule in the same way.") -abstract class TestDependencyInjectionBase { - @Rule - @JvmField - val testSerialization = SerializationEnvironmentRule() -} \ No newline at end of file diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/TestTimestamp.kt b/testing/test-utils/src/main/kotlin/net/corda/testing/TestTimestamp.kt deleted file mode 100644 index f9cef533b0..0000000000 --- a/testing/test-utils/src/main/kotlin/net/corda/testing/TestTimestamp.kt +++ /dev/null @@ -1,20 +0,0 @@ -package net.corda.testing - -import net.corda.testing.TestTimestamp.Companion.timestamp -import java.text.SimpleDateFormat -import java.util.* - -/** - * [timestamp] holds a formatted (UTC) timestamp that's set the first time it is queried. This is used to - * provide a uniform timestamp for tests. - */ -class TestTimestamp { - companion object { - val timestamp: String = { - val tz = TimeZone.getTimeZone("UTC") - val df = SimpleDateFormat("yyyyMMddHHmmss") - df.timeZone = tz - df.format(Date()) - }() - } -} diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/LedgerDSLInterpreter.kt b/testing/test-utils/src/main/kotlin/net/corda/testing/dsl/LedgerDSLInterpreter.kt similarity index 99% rename from testing/test-utils/src/main/kotlin/net/corda/testing/LedgerDSLInterpreter.kt rename to testing/test-utils/src/main/kotlin/net/corda/testing/dsl/LedgerDSLInterpreter.kt index 47d3f68b62..869643d2aa 100644 --- a/testing/test-utils/src/main/kotlin/net/corda/testing/LedgerDSLInterpreter.kt +++ b/testing/test-utils/src/main/kotlin/net/corda/testing/dsl/LedgerDSLInterpreter.kt @@ -1,4 +1,4 @@ -package net.corda.testing +package net.corda.testing.dsl import net.corda.core.contracts.ContractState import net.corda.core.contracts.StateAndRef diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/TestDSL.kt b/testing/test-utils/src/main/kotlin/net/corda/testing/dsl/TestDSL.kt similarity index 99% rename from testing/test-utils/src/main/kotlin/net/corda/testing/TestDSL.kt rename to testing/test-utils/src/main/kotlin/net/corda/testing/dsl/TestDSL.kt index 1fa551c6a1..bf48a07240 100644 --- a/testing/test-utils/src/main/kotlin/net/corda/testing/TestDSL.kt +++ b/testing/test-utils/src/main/kotlin/net/corda/testing/dsl/TestDSL.kt @@ -1,4 +1,4 @@ -package net.corda.testing +package net.corda.testing.dsl import net.corda.core.contracts.* import net.corda.core.cordapp.CordappProvider @@ -12,9 +12,9 @@ import net.corda.core.node.ServicesForResolution import net.corda.core.transactions.SignedTransaction import net.corda.core.transactions.TransactionBuilder import net.corda.core.transactions.WireTransaction -import net.corda.testing.contracts.DummyContract import net.corda.testing.services.MockAttachmentStorage import net.corda.testing.services.MockCordappProvider +import net.corda.testing.dummyCommand import java.io.InputStream import java.security.PublicKey import java.util.* diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/TransactionDSLInterpreter.kt b/testing/test-utils/src/main/kotlin/net/corda/testing/dsl/TransactionDSLInterpreter.kt similarity index 99% rename from testing/test-utils/src/main/kotlin/net/corda/testing/TransactionDSLInterpreter.kt rename to testing/test-utils/src/main/kotlin/net/corda/testing/dsl/TransactionDSLInterpreter.kt index 668a53e2aa..b905e62462 100644 --- a/testing/test-utils/src/main/kotlin/net/corda/testing/TransactionDSLInterpreter.kt +++ b/testing/test-utils/src/main/kotlin/net/corda/testing/dsl/TransactionDSLInterpreter.kt @@ -1,4 +1,4 @@ -package net.corda.testing +package net.corda.testing.dsl import net.corda.core.contracts.* import net.corda.core.crypto.SecureHash diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/internal/InternalTestUtils.kt b/testing/test-utils/src/main/kotlin/net/corda/testing/internal/InternalTestUtils.kt new file mode 100644 index 0000000000..fc65d3603c --- /dev/null +++ b/testing/test-utils/src/main/kotlin/net/corda/testing/internal/InternalTestUtils.kt @@ -0,0 +1,44 @@ +package net.corda.testing.internal + +import net.corda.core.utilities.loggerFor +import net.corda.nodeapi.internal.serialization.amqp.AMQP_ENABLED +import org.mockito.Mockito +import org.mockito.internal.stubbing.answers.ThrowsException +import java.lang.reflect.Modifier +import java.util.* + +@Suppress("unused") +inline fun T.kryoSpecific(reason: String, function: () -> Unit) = if (!AMQP_ENABLED) { + function() +} else { + loggerFor().info("Ignoring Kryo specific test, reason: $reason") +} + +@Suppress("unused") +inline fun T.amqpSpecific(reason: String, function: () -> Unit) = if (AMQP_ENABLED) { + function() +} else { + loggerFor().info("Ignoring AMQP specific test, reason: $reason") +} + +/** + * A method on a mock was called, but no behaviour was previously specified for that method. + * You can use [com.nhaarman.mockito_kotlin.doReturn] or similar to specify behaviour, see Mockito documentation for details. + */ +class UndefinedMockBehaviorException(message: String) : RuntimeException(message) + +inline fun rigorousMock() = rigorousMock(T::class.java) +/** + * Create a Mockito mock that has [UndefinedMockBehaviorException] as the default behaviour of all abstract methods, + * and [org.mockito.invocation.InvocationOnMock.callRealMethod] as the default for all concrete methods. + * @param T the type to mock. Note if you want concrete methods of a Kotlin interface to be invoked, + * it won't work unless you mock a (trivial) abstract implementation of that interface instead. + */ +fun rigorousMock(clazz: Class): T = Mockito.mock(clazz) { + if (Modifier.isAbstract(it.method.modifiers)) { + // Use ThrowsException to hack the stack trace, and lazily so we can customise the message: + ThrowsException(UndefinedMockBehaviorException("Please specify what should happen when '${it.method}' is called, or don't call it. Args: ${Arrays.toString(it.arguments)}")).answer(it) + } else { + it.callRealMethod() + } +} diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/LogHelper.kt b/testing/test-utils/src/main/kotlin/net/corda/testing/internal/LogHelper.kt similarity index 98% rename from testing/test-utils/src/main/kotlin/net/corda/testing/LogHelper.kt rename to testing/test-utils/src/main/kotlin/net/corda/testing/internal/LogHelper.kt index 1fab8508fc..2a8a575bdd 100644 --- a/testing/test-utils/src/main/kotlin/net/corda/testing/LogHelper.kt +++ b/testing/test-utils/src/main/kotlin/net/corda/testing/internal/LogHelper.kt @@ -1,4 +1,4 @@ -package net.corda.testing +package net.corda.testing.internal import net.corda.core.internal.packageName import org.apache.logging.log4j.Level diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/contracts/DummyDealContract.kt b/testing/test-utils/src/main/kotlin/net/corda/testing/internal/vault/DummyDealContract.kt similarity index 90% rename from testing/test-utils/src/main/kotlin/net/corda/testing/contracts/DummyDealContract.kt rename to testing/test-utils/src/main/kotlin/net/corda/testing/internal/vault/DummyDealContract.kt index b19bfac076..453dac658c 100644 --- a/testing/test-utils/src/main/kotlin/net/corda/testing/contracts/DummyDealContract.kt +++ b/testing/test-utils/src/main/kotlin/net/corda/testing/internal/vault/DummyDealContract.kt @@ -1,4 +1,4 @@ -package net.corda.testing.contracts +package net.corda.testing.internal.vault import net.corda.core.contracts.Contract import net.corda.core.contracts.UniqueIdentifier @@ -10,9 +10,8 @@ import net.corda.core.schemas.QueryableState import net.corda.core.transactions.LedgerTransaction import net.corda.core.transactions.TransactionBuilder import net.corda.finance.contracts.DealState -import net.corda.testing.schemas.DummyDealStateSchemaV1 -val DUMMY_DEAL_PROGRAM_ID = "net.corda.testing.contracts.DummyDealContract" +val DUMMY_DEAL_PROGRAM_ID = "net.corda.testing.internal.vault.DummyDealContract" class DummyDealContract : Contract { override fun verify(tx: LedgerTransaction) {} diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/schemas/DummyDealStateSchemaV1.kt b/testing/test-utils/src/main/kotlin/net/corda/testing/internal/vault/DummyDealStateSchemaV1.kt similarity index 96% rename from testing/test-utils/src/main/kotlin/net/corda/testing/schemas/DummyDealStateSchemaV1.kt rename to testing/test-utils/src/main/kotlin/net/corda/testing/internal/vault/DummyDealStateSchemaV1.kt index 33c6a44c8e..493e4688a5 100644 --- a/testing/test-utils/src/main/kotlin/net/corda/testing/schemas/DummyDealStateSchemaV1.kt +++ b/testing/test-utils/src/main/kotlin/net/corda/testing/internal/vault/DummyDealStateSchemaV1.kt @@ -1,4 +1,4 @@ -package net.corda.testing.schemas +package net.corda.testing.internal.vault import net.corda.core.contracts.UniqueIdentifier import net.corda.core.identity.AbstractParty diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/contracts/DummyLinearContract.kt b/testing/test-utils/src/main/kotlin/net/corda/testing/internal/vault/DummyLinearContract.kt similarity index 94% rename from testing/test-utils/src/main/kotlin/net/corda/testing/contracts/DummyLinearContract.kt rename to testing/test-utils/src/main/kotlin/net/corda/testing/internal/vault/DummyLinearContract.kt index 17737f4caa..0a2a962084 100644 --- a/testing/test-utils/src/main/kotlin/net/corda/testing/contracts/DummyLinearContract.kt +++ b/testing/test-utils/src/main/kotlin/net/corda/testing/internal/vault/DummyLinearContract.kt @@ -1,4 +1,4 @@ -package net.corda.testing.contracts +package net.corda.testing.internal.vault import net.corda.core.contracts.Contract import net.corda.core.contracts.LinearState @@ -10,12 +10,10 @@ import net.corda.core.schemas.MappedSchema import net.corda.core.schemas.PersistentState import net.corda.core.schemas.QueryableState import net.corda.core.transactions.LedgerTransaction -import net.corda.testing.schemas.DummyLinearStateSchemaV1 -import net.corda.testing.schemas.DummyLinearStateSchemaV2 import java.time.LocalDateTime import java.time.ZoneOffset.UTC -const val DUMMY_LINEAR_CONTRACT_PROGRAM_ID = "net.corda.testing.contracts.DummyLinearContract" +const val DUMMY_LINEAR_CONTRACT_PROGRAM_ID = "net.corda.testing.internal.vault.DummyLinearContract" class DummyLinearContract : Contract { override fun verify(tx: LedgerTransaction) { diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/schemas/DummyLinearStateSchemaV1.kt b/testing/test-utils/src/main/kotlin/net/corda/testing/internal/vault/DummyLinearStateSchemaV1.kt similarity index 97% rename from testing/test-utils/src/main/kotlin/net/corda/testing/schemas/DummyLinearStateSchemaV1.kt rename to testing/test-utils/src/main/kotlin/net/corda/testing/internal/vault/DummyLinearStateSchemaV1.kt index 1a610c9372..aa649337ff 100644 --- a/testing/test-utils/src/main/kotlin/net/corda/testing/schemas/DummyLinearStateSchemaV1.kt +++ b/testing/test-utils/src/main/kotlin/net/corda/testing/internal/vault/DummyLinearStateSchemaV1.kt @@ -1,4 +1,4 @@ -package net.corda.testing.schemas +package net.corda.testing.internal.vault import net.corda.core.contracts.ContractState import net.corda.core.identity.AbstractParty diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/schemas/DummyLinearStateSchemaV2.kt b/testing/test-utils/src/main/kotlin/net/corda/testing/internal/vault/DummyLinearStateSchemaV2.kt similarity index 96% rename from testing/test-utils/src/main/kotlin/net/corda/testing/schemas/DummyLinearStateSchemaV2.kt rename to testing/test-utils/src/main/kotlin/net/corda/testing/internal/vault/DummyLinearStateSchemaV2.kt index 35ad6880c5..224d6fed87 100644 --- a/testing/test-utils/src/main/kotlin/net/corda/testing/schemas/DummyLinearStateSchemaV2.kt +++ b/testing/test-utils/src/main/kotlin/net/corda/testing/internal/vault/DummyLinearStateSchemaV2.kt @@ -1,4 +1,4 @@ -package net.corda.testing.schemas +package net.corda.testing.internal.vault import net.corda.core.contracts.UniqueIdentifier import net.corda.core.identity.AbstractParty diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/contracts/VaultFiller.kt b/testing/test-utils/src/main/kotlin/net/corda/testing/internal/vault/VaultFiller.kt similarity index 99% rename from testing/test-utils/src/main/kotlin/net/corda/testing/contracts/VaultFiller.kt rename to testing/test-utils/src/main/kotlin/net/corda/testing/internal/vault/VaultFiller.kt index 06e981c9b1..5febc72bd8 100644 --- a/testing/test-utils/src/main/kotlin/net/corda/testing/contracts/VaultFiller.kt +++ b/testing/test-utils/src/main/kotlin/net/corda/testing/internal/vault/VaultFiller.kt @@ -1,6 +1,4 @@ -@file:JvmName("VaultFiller") - -package net.corda.testing.contracts +package net.corda.testing.internal.vault import net.corda.core.contracts.* import net.corda.core.crypto.Crypto diff --git a/tools/demobench/src/test/kotlin/net/corda/demobench/pty/ZeroFilterTest.kt b/tools/demobench/src/test/kotlin/net/corda/demobench/pty/ZeroFilterTest.kt index 41ccda83bf..0f50441e86 100644 --- a/tools/demobench/src/test/kotlin/net/corda/demobench/pty/ZeroFilterTest.kt +++ b/tools/demobench/src/test/kotlin/net/corda/demobench/pty/ZeroFilterTest.kt @@ -3,7 +3,7 @@ package net.corda.demobench.pty import com.nhaarman.mockito_kotlin.doReturn import com.nhaarman.mockito_kotlin.verify import com.nhaarman.mockito_kotlin.whenever -import net.corda.testing.rigorousMock +import net.corda.testing.internal.rigorousMock import org.junit.Assert.assertEquals import org.junit.Before import org.junit.Test