Skip to content

Commit

Permalink
chore: Upgrade Groovy to 3.0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
rholshausen committed Jan 3, 2023
1 parent 5184f5b commit 51c076f
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 32 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
bytebuddyVersion=1.10.8
commonsLang3Version=3.12.0
commonsCollections4=4.4
groovyVersion=3.0.9
groovyVersion=3.0.14
guavaVersion=30.1.1-jre
httpBuilderVersion=1.0.4
httpClientVersion=5.1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package au.com.dius.pact.provider.junit

import au.com.dius.pact.core.model.Pact
import au.com.dius.pact.core.support.Utils
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ import au.com.dius.pact.provider.junitsupport.loader.PactSource
import au.com.dius.pact.provider.junitsupport.loader.PactUrl
import au.com.dius.pact.provider.junitsupport.target.Target
import au.com.dius.pact.provider.junitsupport.target.TestTarget
import org.apache.commons.lang3.JavaVersion
import org.apache.commons.lang3.SystemUtils
import org.junit.jupiter.api.extension.ExtensionContext
import spock.lang.Ignore
import spock.lang.Issue
import spock.lang.Requires
import spock.lang.Specification
import spock.lang.Unroll
import spock.util.environment.RestoreSystemProperties

import java.util.stream.Collectors

// TODO: Groovy mocks don't work on JDK 16
@Ignore
@SuppressWarnings(['EmptyMethod', 'UnusedMethodParameter', 'LineLength'])
class PactVerificationInvocationContextProviderSpec extends Specification {

Expand Down Expand Up @@ -132,6 +132,8 @@ class PactVerificationInvocationContextProviderSpec extends Specification {
}

@Unroll
// TODO: Groovy mocks don't work on JDK 16
@Requires(reason = "Groovy mocks don't work on JDK 16", value = { SystemUtils.isJavaVersionAtMost(JavaVersion.JAVA_15) })
def 'only supports tests with a provider annotation'() {
expect:
provider.supportsTestTemplate(['getTestClass': { Optional.of(testClass) } ] as ExtensionContext) == isSupported
Expand All @@ -144,6 +146,8 @@ class PactVerificationInvocationContextProviderSpec extends Specification {
ChildClass | true
}

// TODO: Groovy mocks don't work on JDK 16
@Requires(reason = "Groovy mocks don't work on JDK 16", value = { SystemUtils.isJavaVersionAtMost(JavaVersion.JAVA_15) })
def 'findPactSources throws an exception if there are no defined pact sources on the test class'() {
when:
provider.findPactSources(['getTestClass': {
Expand All @@ -158,11 +162,15 @@ class PactVerificationInvocationContextProviderSpec extends Specification {
def 'findPactSources returns a pact loader for each discovered pact source annotation'() {
when:
def sources = provider.findPactSources([
'getTestClass': { Optional.of(TestClassWithAnnotation) } ] as ExtensionContext
)
'getTestClass': { Optional.of(TestClassWithAnnotation) },
'getRequiredTestClass': { TestClassWithAnnotation },
'getTestInstance': { Optional.empty() }
] as ExtensionContext)
def childSources = provider.findPactSources([
'getTestClass': { Optional.of(ChildClass) } ] as ExtensionContext
)
'getTestClass': { Optional.of(ChildClass) },
'getRequiredTestClass': { ChildClass },
'getTestInstance': { Optional.empty() }
] as ExtensionContext)

then:
sources.size() == 1
Expand All @@ -178,8 +186,10 @@ class PactVerificationInvocationContextProviderSpec extends Specification {
def 'findPactSources returns a pact loader for each discovered pact source on any annotations'() {
when:
def sources = provider.findPactSources([
'getTestClass': { Optional.of(TestClassWithPactSourceOnAnnotation) } ] as ExtensionContext
)
'getTestClass': { Optional.of(TestClassWithPactSourceOnAnnotation) },
'getRequiredTestClass': { TestClassWithPactSourceOnAnnotation },
'getTestInstance': { Optional.empty() }
] as ExtensionContext)
then:
sources.size() == 1
sources.first() instanceof PactFolderLoader
Expand All @@ -189,8 +199,10 @@ class PactVerificationInvocationContextProviderSpec extends Specification {
def 'returns a junit extension for each interaction in all the discovered pact files'() {
when:
def extensions = provider.provideTestTemplateInvocationContexts([
'getTestClass': { Optional.of(TestClassWithAnnotation) } ] as ExtensionContext
)
'getTestClass': { Optional.of(TestClassWithAnnotation) },
'getRequiredTestClass': { TestClassWithAnnotation },
'getTestInstance': { Optional.empty() }
] as ExtensionContext)

then:
extensions.count() == 3
Expand All @@ -199,8 +211,10 @@ class PactVerificationInvocationContextProviderSpec extends Specification {
def 'supports filtering the discovered pact files'() {
when:
def extensions = provider.provideTestTemplateInvocationContexts([
'getTestClass': { Optional.of(ChildClass) } ] as ExtensionContext
)
'getTestClass': { Optional.of(ChildClass) },
'getRequiredTestClass': { ChildClass },
'getTestInstance': { Optional.empty() }
] as ExtensionContext)

then:
extensions.count() == 1
Expand All @@ -214,8 +228,10 @@ class PactVerificationInvocationContextProviderSpec extends Specification {

when:
def extensions = provider.provideTestTemplateInvocationContexts([
'getTestClass': { Optional.of(TestClassWithAnnotation) } ] as ExtensionContext
)
'getTestClass': { Optional.of(TestClassWithAnnotation) },
'getRequiredTestClass': { TestClassWithAnnotation },
'getTestInstance': { Optional.empty() }
] as ExtensionContext)

then:
extensions.count() == 1
Expand All @@ -224,9 +240,11 @@ class PactVerificationInvocationContextProviderSpec extends Specification {
@Issue('#1007')
def 'provideTestTemplateInvocationContexts throws an exception if there are no pacts to verify'() {
when:
provider.provideTestTemplateInvocationContexts(['getTestClass': {
Optional.of(TestClassWithNoPacts)
} ] as ExtensionContext)
provider.provideTestTemplateInvocationContexts([
'getTestClass': { Optional.of(TestClassWithNoPacts) },
'getRequiredTestClass': { TestClassWithNoPacts },
'getTestInstance': { Optional.empty() }
] as ExtensionContext)

then:
def exp = thrown(NoPactsFoundException)
Expand All @@ -236,9 +254,11 @@ class PactVerificationInvocationContextProviderSpec extends Specification {
@Issue('#768')
def 'returns a dummy test if there are no pacts to verify and IgnoreNoPactsToVerify is present'() {
when:
def result = provider.provideTestTemplateInvocationContexts(['getTestClass': {
Optional.of(TestClassWithNoPactsWithIgnore)
} ] as ExtensionContext).iterator().toList()
def result = provider.provideTestTemplateInvocationContexts([
'getTestClass': { Optional.of(TestClassWithNoPactsWithIgnore) },
'getRequiredTestClass': { TestClassWithNoPactsWithIgnore },
'getTestInstance': { Optional.empty() }
] as ExtensionContext).iterator().toList()

then:
result.size() == 1
Expand Down Expand Up @@ -274,8 +294,10 @@ class PactVerificationInvocationContextProviderSpec extends Specification {

when:
def extensions = provider.provideTestTemplateInvocationContexts([
'getTestClass': { Optional.of(TestClassWithEmptyProvider) } ] as ExtensionContext
).collect(Collectors.toList())
'getTestClass': { Optional.of(TestClassWithEmptyProvider) },
'getRequiredTestClass': { TestClassWithEmptyProvider },
'getTestInstance': { Optional.empty() }
] as ExtensionContext).collect(Collectors.toList())

then:
!extensions.empty
Expand All @@ -285,9 +307,11 @@ class PactVerificationInvocationContextProviderSpec extends Specification {
@Issue('#1225')
def 'provideTestTemplateInvocationContexts throws an exception if load request fails with an exception'() {
when:
provider.provideTestTemplateInvocationContexts(['getTestClass': {
Optional.of(TestClassWithInvalidUrl)
} ] as ExtensionContext)
provider.provideTestTemplateInvocationContexts([
'getTestClass': { Optional.of(TestClassWithInvalidUrl) },
'getRequiredTestClass': { TestClassWithInvalidUrl },
'getTestInstance': { Optional.empty() }
] as ExtensionContext)

then:
thrown(UnknownHostException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ class LeinVerifierProxy {

List<VerificationResult.Failed> verifyProvider(ProviderInfo provider) {
verifier.verificationSource = 'lein'
verifier.projectHasProperty = { property ->
this.hasProperty.invoke(Clojure.read(":$property"), args)
verifier.projectHasProperty = { String property ->
def value = this.hasProperty.invoke(Clojure.read(":$property"), args)
value instanceof Boolean ? value : false
}
verifier.projectGetProperty = { property ->
this.getProperty.invoke(Clojure.read(":$property"), args)
verifier.projectGetProperty = { String property ->
this.getProperty.invoke(Clojure.read(":$property"), args)?.toString()
}
verifier.pactLoadFailureMessage = { ConsumerInfo consumer ->
"You must specify the pact file to execute for consumer '${consumer.name}' (use :pact-file or :pact-source)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ReadmeExamplePactJVMProviderJUnitTest {
consumer.setPactSource(new UrlSource(
ReadmeExamplePactJVMProviderJUnitTest.getResource('/pacts/zoo_app-animal_service.json').toString()))

testConsumerPact = DefaultPactReader.INSTANCE.loadPact(consumer.getPactSource()) as Pact<RequestResponseInteraction>
testConsumerPact = DefaultPactReader.INSTANCE.loadPact(consumer.getPactSource())
}

@Test
Expand Down

0 comments on commit 51c076f

Please sign in to comment.