diff --git a/provider/build.gradle b/provider/build.gradle index 11690dfd99..9b9afea81d 100644 --- a/provider/build.gradle +++ b/provider/build.gradle @@ -35,3 +35,8 @@ dependencies { } testImplementation 'org.hamcrest:hamcrest:2.2' } + +test { + useJUnitPlatform() + maxHeapSize = "1g" +} diff --git a/provider/junit/src/test/groovy/au/com/dius/pact/provider/junit/loader/PactBrokerLoaderSpec.groovy b/provider/src/test/groovy/au/com/dius/pact/provider/junitsupport/loader/PactBrokerLoaderSpec.groovy similarity index 96% rename from provider/junit/src/test/groovy/au/com/dius/pact/provider/junit/loader/PactBrokerLoaderSpec.groovy rename to provider/src/test/groovy/au/com/dius/pact/provider/junitsupport/loader/PactBrokerLoaderSpec.groovy index 32112e7542..50e2fc1b3b 100644 --- a/provider/junit/src/test/groovy/au/com/dius/pact/provider/junit/loader/PactBrokerLoaderSpec.groovy +++ b/provider/src/test/groovy/au/com/dius/pact/provider/junitsupport/loader/PactBrokerLoaderSpec.groovy @@ -1,4 +1,4 @@ -package au.com.dius.pact.provider.junit.loader +package au.com.dius.pact.provider.junitsupport.loader import au.com.dius.pact.core.model.Pact import au.com.dius.pact.core.model.PactBrokerSource @@ -12,14 +12,6 @@ import au.com.dius.pact.core.support.expressions.DataType import au.com.dius.pact.core.support.expressions.ExpressionParser import au.com.dius.pact.core.support.expressions.SystemPropertyResolver import au.com.dius.pact.core.support.expressions.ValueResolver -import au.com.dius.pact.provider.junitsupport.loader.IConsumerVersionSelectors -import au.com.dius.pact.provider.junitsupport.loader.PactBrokerConsumerVersionSelectors -import au.com.dius.pact.provider.junitsupport.loader.SelectorBuilder -import au.com.dius.pact.provider.junitsupport.loader.VersionSelector -import au.com.dius.pact.provider.junitsupport.loader.NoPactsFoundException -import au.com.dius.pact.provider.junitsupport.loader.PactBroker -import au.com.dius.pact.provider.junitsupport.loader.PactBrokerAuth -import au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader import com.github.michaelbull.result.Err import com.github.michaelbull.result.Ok import spock.lang.Issue @@ -1448,16 +1440,19 @@ class PactBrokerLoaderSpec extends Specification { where: - clazz | result - null | false - PactBrokerLoaderSpec | false - FullPactBrokerAnnotation | false - IncorrectTypesOnSelectorMethod | false - IncorrectTypesOnSelectorMethod2 | false - IncorrectScopeOnSelectorMethod | false - CorrectSelectorMethod | true - CorrectSelectorMethod2 | true - CorrectSelectorMethod3 | true + clazz | result + null | false + PactBrokerLoaderSpec | false + FullPactBrokerAnnotation | false + IncorrectTypesOnSelectorMethod | false + IncorrectTypesOnSelectorMethod2 | false + IncorrectScopeOnSelectorMethod | false + CorrectSelectorMethod | true + CorrectSelectorMethod2 | true + CorrectSelectorMethod3 | true + KotlinClassWithSelectorMethod | true + ExtendedFromKotlin | true + KotlinAbstractClassWithSelectorMethod | true } @Unroll @@ -1467,10 +1462,12 @@ class PactBrokerLoaderSpec extends Specification { where: - clazz | instance | result - CorrectSelectorMethod | new CorrectSelectorMethod() | [new ConsumerVersionSelectors.Environment('CorrectSelectorMethod')] - CorrectSelectorMethod2 | new CorrectSelectorMethod2() | [new ConsumerVersionSelectors.Environment('CorrectSelectorMethod2')] - CorrectSelectorMethod3 | null | [new ConsumerVersionSelectors.Environment('CorrectSelectorMethod3')] + clazz | instance | result + CorrectSelectorMethod | new CorrectSelectorMethod() | [new ConsumerVersionSelectors.Environment('CorrectSelectorMethod')] + CorrectSelectorMethod2 | new CorrectSelectorMethod2() | [new ConsumerVersionSelectors.Environment('CorrectSelectorMethod2')] + CorrectSelectorMethod3 | null | [new ConsumerVersionSelectors.Environment('CorrectSelectorMethod3')] + KotlinClassWithSelectorMethod | new KotlinClassWithSelectorMethod() | [new ConsumerVersionSelectors.Environment('KotlinSelectorMethod')] + ExtendedFromKotlin | new ExtendedFromKotlin() | [new ConsumerVersionSelectors.Environment('KotlinSelectorMethod')] } private static VersionSelector createVersionSelector(Map args = [:]) { @@ -1602,4 +1599,6 @@ class PactBrokerLoaderSpec extends Specification { new SelectorBuilder().environment('CorrectSelectorMethod3').build() } } + + static class ExtendedFromKotlin extends KotlinAbstractClassWithSelectorMethod { } } diff --git a/provider/src/test/kotlin/au/com/dius/pact/provider/junitsupport/loader/PactBrokerLoaderTestSupport.kt b/provider/src/test/kotlin/au/com/dius/pact/provider/junitsupport/loader/PactBrokerLoaderTestSupport.kt new file mode 100644 index 0000000000..ff22d7f025 --- /dev/null +++ b/provider/src/test/kotlin/au/com/dius/pact/provider/junitsupport/loader/PactBrokerLoaderTestSupport.kt @@ -0,0 +1,18 @@ +package au.com.dius.pact.provider.junitsupport.loader + +class KotlinClassWithSelectorMethod { + @PactBrokerConsumerVersionSelectors + fun consumerVersionSelectors() = SelectorBuilder().environment("KotlinSelectorMethod") +} + +abstract class KotlinAbstractClassWithSelectorMethod { + @PactBrokerConsumerVersionSelectors + fun consumerVersionSelectors() = SelectorBuilder().environment("KotlinSelectorMethod") +} + +class KotlinClassWithStaticSelectorMethod { + companion object { + @PactBrokerConsumerVersionSelectors + fun consumerVersionSelectors() = SelectorBuilder().environment("KotlinStaticSelectorMethod") + } +}