Ulises Cervino
02/06/2023, 7:17 PMMarcin Grzejszczak
02/07/2023, 2:26 PMItzhak Eretz Kdosha
02/07/2023, 3:43 PMPactBuilder
(V4)?Himanshu Goyal
02/09/2023, 4:05 PM@PactBroker(scheme = "https", host = "<org-base-url>/pactbroker")
I get error as:
@PactBroker(scheme = "https", host = "<org-base-url>/pactbroker")
java.lang.IllegalArgumentException: Invalid pact broker host specified ('<http://<org-base-url>/pactbroker|<org-base-url>/pactbroker>'). Please provide a valid host or specify the system property 'pactbroker.host'.
At the same time I am using @PactUrl to specify the pact URL but due to that verification result is not getting published.
JDK version: 1.8
au.com.dius.pact.provider.junit5 : 4.1.11
Can someone help with this? Maybe I am missing something!! thinking2Werner Lauterfeld
02/13/2023, 11:47 AMIvan Mikhalka
02/13/2023, 2:37 PMpact-gradle-plugin
.
What I want to achieve - two separate gradle tasks for running provider test a) using contracts fetched from broker;
b) using contract file on local file system.
For now I have one for pact broker:
pact {
broker {
pactBrokerUrl = 'url'
pactBrokerToken = 'token'
}
serviceProviders {
MyProvider {
....
fromPactBroker {
withSelectors {
// Some selectors
}
}
}
}
}
I’ve tried:
1. Add another provider MyProviderLocal under serviceProviders
with specifying path to local pact file
2. Add new gradle task and put inside pact
dsl:
task pactLocal {
pact {
......
}
}
Both attempts not working, it recognise broker
block and always trying to get pacts from broker.Itzhak Eretz Kdosha
02/14/2023, 4:16 PMPactBuilder
and PactDslJsonBody
(V4)?GitHub
02/15/2023, 6:08 AMGitHub
02/15/2023, 6:45 AMItzhak Eretz Kdosha
02/15/2023, 4:20 PMpact-jvm-server
has an endpoint on /create
that starts a server on a random port.
Is there a way to make this port be predictable and not random?Ben Brugman
02/16/2023, 9:55 AMJames Fraser
02/16/2023, 4:33 PMDslPart
from an existing JSON file or object? Or is it only the PactDslJsonBody
and newJsonBody
approaches listed here?
We have existing JSON files used by our tests so it’d be nice to not have to rewrite all of them into this formatJacob Brauchler
02/16/2023, 10:34 PMpact.filter.pacturl
It finds contracts for other consumers but not the consumer the test I'm working on is for. Can anyone think of any reason for that?Çağın Uludamar
02/20/2023, 8:21 AMMevlüt Özdemir
02/21/2023, 2:53 PM@BeforeEach
void before(PactVerificationContext context, @LocalServerPort int port) {
context.setTarget(new HttpTestTarget("localhost", port));
}
@TestTemplate
@ExtendWith(PactVerificationSpringProvider.class)
void pactVerificationTestTemplate(PactVerificationContext context) {
context.verifyInteraction();
}
While I could implement a solution using this approach, I don't think it's the most optimal way to solve the problem.
@BeforeEach
void before(PactVerificationContext context, @LocalServerPort int port) {
context.setTarget(new HttpTestTarget("localhost", port));
Request request = ((RequestResponseInteraction) context.getInteraction()).getRequest();
request.setPath(request.getPath().replace("/api/v3", ""));
}
Diana Nguyen
02/21/2023, 9:15 PMAlan Boshier
02/22/2023, 12:00 PMANTLR Tool version 4.9.2 used for code generation does not match the current runtime version 4.10.1
ANTLR Runtime version 4.9.2 used for parser compilation does not match the current runtime version 4.10.1
...
Caused by: java.lang.ExceptionInInitializerError
at au.com.dius.pact.core.support.Version.parse(Version.java:79)
at au.com.dius.pact.core.model.DefaultPactReader.pactFromJson(PactReader.kt:219)
at au.com.dius.pact.core.model.DefaultPactReader.loadPact(PactReader.kt:214)
at au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.loadPactsForProvider(PactBrokerLoader.kt:251)
at au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.load(PactBrokerLoader.kt:120)
at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider$resolvePactSources$pactSources$1$pacts$1.invoke(PactJUnit5VerificationProvider.kt:83)
at au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:39)
... 60 more
Caused by: java.lang.UnsupportedOperationException: java.io.InvalidClassException: org.antlr.v4.runtime.atn.ATN; Could not deserialize ATN with version 3 (expected 4).
at org.antlr.v4.runtime.atn.ATNDeserializer.deserialize(ATNDeserializer.java:56)
at org.antlr.v4.runtime.atn.ATNDeserializer.deserialize(ATNDeserializer.java:48)
at au.com.dius.pact.core.support.VersionLexer.<clinit>(VersionLexer.java:115)
... 67 more
Caused by: java.io.InvalidClassException: org.antlr.v4.runtime.atn.ATN; Could not deserialize ATN with version 3 (expected 4).
... 70 more
I'm guessing that the problem is that an Antlr 4 runtime dependency has been introduced via an uprev from Hibernate 5 to 6 (itself triggered by the uprev from Spring Boot 2 to 3), but pact needs Antlr 3.
Is there any way around this? tiaJacob Brauchler
02/22/2023, 5:56 PMmainBranch: true
and deployedOrReleased: true
?Ashish Garg
02/23/2023, 9:54 AMGitHub
02/24/2023, 5:44 AMGitHub
02/24/2023, 6:29 AMTomer Ghelber
02/27/2023, 1:08 PMMiKey
02/27/2023, 8:56 PMUnexpected character 'EOI(null)' at position '3', expecting '[DOT]'
at app//com.github.zafarkhaja.semver.VersionParser.consumeNextCharacter(VersionParser.java:516)
at app//com.github.zafarkhaja.semver.VersionParser.parseVersionCore(VersionParser.java:288)
at app//com.github.zafarkhaja.semver.VersionParser.parseValidSemVer(VersionParser.java:255)
at app//com.github.zafarkhaja.semver.VersionParser.parseValidSemVer(VersionParser.java:195)
at app//com.github.zafarkhaja.semver.Version.valueOf(Version.java:265)
at app//au.com.dius.pact.core.model.DefaultPactReader.loadPact(PactReader.kt:203)
MiKey
02/27/2023, 8:57 PMsasank kumar
02/28/2023, 10:14 AMsasank kumar
02/28/2023, 10:14 AMOleksandr Yanov
02/28/2023, 11:20 AMJordan Brooks
03/01/2023, 1:25 PMGazal Gafoor
03/01/2023, 1:30 PMEric Deandrea
03/01/2023, 6:12 PM@Test
methods that use pact consumer contract tests as well as other @Test
methods that don’t? I don’t seem to be able to do that.
My usecase: I have my business logic tier (a bean) that has lots of business methods. I have a single test class that has lots of tests, some of those tests don’t belong in the Pact consumer contract (i.e. error handling/failure scenarios). Something like this:
@Pact(consumer = "rest-fights", provider = "rest-villains")
public V4Pact helloVillainsPact(PactDslWithProvider builder) {
return builder
.uponReceiving("A hello request")
.path(VILLAIN_HELLO_URI)
.method(HttpMethod.GET)
.headers(HttpHeaders.ACCEPT, MediaType.TEXT_PLAIN)
.willRespondWith()
.headers(Map.of(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN))
.status(Status.OK.getStatusCode())
.body(PactDslRootValue.stringMatcher(".+", DEFAULT_HELLO_VILLAIN_RESPONSE))
.toPact(V4Pact.class);
}
@Test
@PactTestFor(pactMethod = "helloVillainsPact", port = "8081")
public void helloVillainsSuccess() {
var message = this.fightService.helloVillains()
.subscribe().withSubscriber(UniAssertSubscriber.create())
.assertSubscribed()
.awaitItem(Duration.ofSeconds(5))
.getItem();
assertThat(message)
.isNotNull()
.isEqualTo(DEFAULT_HELLO_VILLAIN_RESPONSE);
}
@Test
public void helloVillainsFailure() {
doReturn(Uni.createFrom().item("fallback"))
.when(this.fightService)
.fallbackHelloVillains();
doReturn(Uni.createFrom().failure(InternalServerErrorException::new))
.when(this.villainClient)
.helloVillains();
var message = this.fightService.helloVillains()
.subscribe().withSubscriber(UniAssertSubscriber.create())
.assertSubscribed()
.awaitItem(Duration.ofSeconds(10))
.getItem();
assertThat(message)
.isNotNull()
.isEqualTo("fallback");
}
When I try to run this test class the helloVillainsFailure
method fails with
13:02:28 WARN [au.co.di.pa.co.ju.PactConsumerTestExt] (main) No @PactTestFor annotation found on test class, using defaults
java.lang.UnsupportedOperationException: No method annotated with @Pact was found on test class PactTests for provider ''
at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.lookupPact(PactConsumerTestExt.kt:336)
at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.setupMockServer(PactConsumerTestExt.kt:230)
at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.beforeTestExecution(PactConsumerTestExt.kt:215)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeTestExecutionCallbacks$5(TestMethodTestDescriptor.java:191)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeMethodsOrCallbacksUntilExceptionOccurs$6(TestMethodTestDescriptor.java:202)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:202)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeTestExecutionCallbacks(TestMethodTestDescriptor.java:190)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:136)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:68)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:55)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:102)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:54)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)