https://pact.io logo
Join Slack
Powered by
# pact-jvm
  • e

    Eric Deandrea

    03/01/2023, 7:42 PM
    Anyone know how to statically set multiple provider mock server ports? See https://stackoverflow.com/questions/74942016/setting-mock-ports-for-multiple-providers-in-pact-jvm & https://github.com/pact-foundation/pact-jvm/issues/1675
  • g

    GitHub

    03/02/2023, 4:31 AM
    Release - 4.5.1 New release published by rholshausen Fix Maven plugin • bf08170 - fix: task to generate Maven plugin descriptor was accidentally commented out #1672 pact-foundation/pact-jvm
  • s

    Syam K

    03/03/2023, 1:15 PM
    @All, Good Afternoon. Dear Team, I am new to PACT and trying to setup Pact-jvm. I am successfully able to generate pact contracts & publish to pactflow from consumer. But when I am trying to publish the verification results from provider getting the below exception. Could anyone please let me know where I am missing it.
    Copy code
    Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal au.com.dius.pact.provider:maven:4.1.11:verify failed: lateinit property serviceProviders has not been initialized
    	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:148)
    	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
    u
    • 2
    • 3
  • f

    Facu Conejero

    03/06/2023, 12:21 PM
    Hey there, good morning 🌞 I’m new to Pact, been trying to set up a contract but I can’t find enough info online and idk if I’m missing something I’ve got two services (frontend with React + back with Java), trying to set up a contract test between them (is it possible between different technologies? I imagine so, but every tutorial I’ve found is between the same technologies) I set up a test in the consumer (React), copy pasted the test to the provider (java) and set up a test. The test is testing something that goes green for a unit test. After passing it a string it should return a succesful 204 message. However, I’m seeing it return 502 🤔 It’s driving me insane cause the unit test runs well, so I imagine it’s not the logic. The provider name matches, the url matches (if it doesn’t it just returns 404, so I know I’m pointing to the right one). The only thing that occurs to me is that it may have to be with the metadata since it’s between two different technologies and I haven’t specified that anywhere? Could someone give me a hand?
    t
    • 2
    • 11
  • g

    GitHub

    03/07/2023, 1:02 AM
    Release - 4.4.8 New release published by rholshausen Bugfix Release • 8ab6b7a - feat: Update readme with support mixing pact and non-pact test methods with @PactIgnore annotation #1674 • 3bb4a08 - feat: Support mixing pact and non-pact test methods with @PactIgnore annotation #1674 • 92018c0 - fix: InteractionFilter ByRequestPath was using concrete class and did not work with V4 interactions #1673 • 67a6670 - feat(JUnit5): Support multiple @MockServerConfig annotations on a provider test #1675 • 0da32ec - fix merging message pacts - old messages taking precedence (ilya.aliaksandrovich) pact-foundation/pact-jvm
  • g

    GitHub

    03/07/2023, 1:36 AM
    Release - 4.5.2 New release published by rholshausen Bugfix Release • 8ab6b7a - feat: Update readme with support mixing pact and non-pact test methods with @PactIgnore annotation #1674 • 3bb4a08 - feat: Support mixing pact and non-pact test methods with @PactIgnore annotation #1674 • 92018c0 - fix: InteractionFilter ByRequestPath was using concrete class and did not work with V4 interactions #1673 • 67a6670 - feat(JUnit5): Support multiple @MockServerConfig annotations on a provider test #1675 • 0da32ec - fix merging message pacts - old messages taking precedence (ilya.aliaksandrovich) pact-foundation/pact-jvm
  • j

    James Fraser

    03/07/2023, 1:50 PM
    Hey folks 👋 if I’m loading existing JSON into a
    MessagePactBuilder
    or
    ConsumerPactBuilder
    is there any way to apply matching rules to them afterwards so this basic type match is added to the contract?
    Copy code
    "matchingRules": {
        "$.body": {
            "match": "type"
        }
    },
    u
    • 2
    • 3
  • s

    Syam K

    03/07/2023, 3:19 PM
    Hey guys, can anyone faced the below issue. If yes, could you please help me.
    Copy code
    au.com.dius.pact.core.pactbroker.NotFoundHalResponse: No HAL document found at path '<https://xxx.pactflow.io/pacts/provider/packflow/for-verification>'
    h
    m
    s
    • 4
    • 4
  • x

    xin chen

    03/08/2023, 3:36 PM
    Hi All. I wonder how do you spin up the provider service before you kick off its verification test? If I treat this provider side test as a kind of unit test, CI pipeline won't start the real provider application when running unit tests. I'm very confused. Please help. Thank you.
    u
    • 2
    • 5
  • i

    Itzhak Eretz Kdosha

    03/09/2023, 1:57 PM
    Hi 🙂 Is it possible to define a response with array of objects where the order is not important using
    PactBuilder
    (V4)?
    u
    • 2
    • 1
  • v

    Venkat Konda

    03/09/2023, 3:43 PM
    Hi All, I am unable to verify with the provider as the PactFlow is deployed with HTTPS protocol. Itseems the @PactBroker annotation only supports host and port. protocol is deprecated. so when building it is trying to connect http://<pacthostname> and getting denied. Also what is the variable to be refferred for the apitoken. Can I use path.auth.token as a property.
    u
    • 2
    • 2
  • v

    Venkat Konda

    03/09/2023, 3:44 PM
    In my application properties, it contains pact.host pact.port pact.auth.token
  • s

    sasank kumar

    03/10/2023, 11:36 AM
    Any example handling null values in build and generate pact file? I mean attribute value always null
    j
    • 2
    • 1
  • m

    Michael Branders

    03/13/2023, 12:35 PM
    My OAS is inside my code so i dont have a yaml file to upload bi directional contracts. How do i then upload the OAS from a CI perspective?
    y
    • 2
    • 1
  • s

    sasank kumar

    03/13/2023, 1:15 PM
    I have 2 pojo classes to generate into 1 pact file any help on this?
  • g

    GitHub

    03/16/2023, 6:04 AM
    Release - 4.5.3 New release published by rholshausen Bugfix Release • e2905ae - fix(JUnit5): Initialise any plugins before running the provider verification • f4c1862 - chore: correct the project dependency versions • 83a17c9 - feat: update the general verifier to support verification via plugins pact-foundation/pact-jvm
  • s

    Shirley

    03/16/2023, 9:03 AM
    Hello,
  • s

    Shirley

    03/16/2023, 9:06 AM
    I'm using pact-jvm version 3.5.x (an old version due to legacy system), and want to do a Message test that verifies the metadata that my consumer publishes. According to https://docs.pact.io/implementation_guides/jvm/provider/junit#example-of-message-test-that-verifies-metadata, I should be using MessageAndMetadata however it's not available in the library, presumably because it's an older version. What other ways can I use to verify the metadata?
    m
    • 2
    • 2
  • k

    Kripa Kurian

    03/16/2023, 7:31 PM
    @Kripa Kurian has left the channel
  • p

    Pascal LIBENZI

    03/17/2023, 7:00 AM
    Hello guys! I have an issue using branch fallback feature with pact-broker and pact-jvm by PactBrokerConsumerVersionSelectors (I think I am missing something that’s why I didn’t create an issue for now). Here is my configuration: • Java version: 17 • pact jvm dependency:
    Copy code
    <dependency>
        <groupId>au.com.dius.pact.provider</groupId>
        <artifactId>junit5spring</artifactId>
        <version>4.5.2</version>
    </dependency>
    • PactBrokerConsumerVersionSelectors:
    Copy code
    @PactBrokerConsumerVersionSelectors
    public static SelectorBuilder consumerVersionSelectors() {
        return new SelectorBuilder()
                .branch(System.getProperty("branch"), null, System.getProperty("fallback"));
    }
    • Link to the project sources if needed: https://gitlab.com/pascal.libenzi/pact-jvm-provider/-/tree/feature/new-field-publication-date My consumers have a trunk branch. If I put it as a System property “branch” the test pass. If I pass “nonexistingbranch” in branch and trunk in fallback I have:
    Copy code
    au.com.dius.pact.provider.junitsupport.loader.NoPactsFoundException: 
    No Pact files were found to verify
    Provider: BookStore
    Source: Pact Broker <http://localhost:80> consumerVersionSelectors=[Branch(name=test, consumer=null, fallback=trunk)]
    Does somebody have any idea about what I am missing? Thanks!
  • s

    Simon Raess

    03/17/2023, 9:24 AM
    I have strange issues with au.com.dius.pact.providerspring64.5.3 (and older versions as well). When I add the dependency to a plain Gradle build file and run "gradle dependencies" the dependencies are not resolved: \-- au.com.dius.pact.providerspring64.5.3 FAILED the reason I think is the missing version on the dependency to org.apache.groovy:groovy If I include the dependency in our own build, I get NullPointerExceptions or other strange errors. see https://github.com/pact-foundation/pact-jvm/blob/v4.5.x/provider/spring6/build.gradle#L33
    u
    • 2
    • 1
  • s

    sasank kumar

    03/17/2023, 3:41 PM
    Can we use java8 and junit5 for pact test?
    u
    • 2
    • 1
  • a

    Anji

    03/19/2023, 11:07 PM
    Copy code
    Hi, I have a question about BiDirection Contract Testing. Steps I followed
    1. I created OAS swagger.json file and published as provider contract with version 1.0.0
    2. Ran can-i-deploy tool and recorded the deployment for the version 1.0.0
    3. Generated the consumer contract which is compatible with provider contract
    4.Published this consumer contract with version 2.0.0
    5. Ran can-deploy-tool and it says consumer version 2.0.0 is compatible with provider version 1.0.0
    6.Hence proceeded with deployment and recorded the deployment with consumer version 2.0.0
    7.Now, I made a breaking change in provider contract (in OAS) and published to pact as version 1.0.1
    8.Ran can-i-deploy and it says NO as provider contract 1.0.1 is not compatible with consumer version 2.0.0
    9.I updated consumer executions to be inline with new provider change and published the consumer contract with version 2.0.1
    <http://10.In|10.In> pact flow UI, I see that consumer version 2.0.1 is compatible with producer version 1.0.1 which is good
    11.But when I run "can-i-deploy" it says NO as consumer version 2.0.1 is compared with producer version 1.0.0 instead 1.0.1
    How can I proceed with deployment??
    m
    • 2
    • 2
  • g

    GitHub

    03/21/2023, 7:40 AM
    Release - 4.5.4 New release published by rholshausen Bugfix Release • be98ba2 - fix: verifyMessage must pass through any plugin config to the content matcher pact-foundation/pact-jvm
  • r

    Rafał Maciak

    03/22/2023, 8:07 AM
    Hello! I'm looking for a way to test message based communication (with Kafka) using Pact and groovy/spock. I already defined the consumer's test using this example (https://docs.pact.io/implementation_guides/jvm/consumer/groovy#consumer-test-for-a-message-consumer). Now I'm struggling how to test provider with groovy/spock. I couldn't find a doc/sample/tutorial. Is there a way to test message communication with groovy?
    t
    u
    • 3
    • 6
  • s

    Slackbot

    03/24/2023, 1:39 PM
    This message was deleted.
    u
    • 2
    • 1
  • u

    郭佳佳

    03/27/2023, 9:40 AM
    Hey,guys!I'm using pact framwork(version num:4.1.28) to verify a multipart/form-data interface. This interface will receive a excel and parse to a Workbook. Here is the interface:
    Copy code
    @PostMapping("/pact-test-form-data")
        public SimpleResultVo<Object> pactTest(SecurityUploadHttpServletRequest request) {
            List<String> result = new ArrayList<>();
            CommonsMultipartFile[] mfs = request.getMultipartFiles();
            try(InputStream is = mfs[0].getInputStream(); Workbook workbook = new XSSFWorkbook(is)) {
                workbook.getSheetAt(0);
            } catch (IOException e) {
                e.printStackTrace();
            }
            result.add(request.getParameter("userName"));
            result.add(request.getParameter("password"));
            return ResultVoUtil.success(result);
        }
    Here is the pact I created:
    Copy code
    @Pact(consumer = "FBB")
        public RequestResponsePact formDataReqTest(PactDslWithProvider builder) throws IOException {
            File file = new File("C:\\Users\\g00574640\\Desktop\\importProjectList.xlsx");
            MultipartEntityBuilder entityBuilder =
                MultipartEntityBuilder.create()
                    .addTextBody("userName", "guojiahui")
                    .addTextBody("password", "123456")
                    .addBinaryBody("file", file,
                        ContentType.create("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"),
                        "importProjectList.xlsx");
            
            String expectStr =
                TestingFileUtils.loadFileAsString("business/service/ResourceServiceTest/expect/formData.json");
    
            Map<String, String> map = new HashMap<>();
            map.put("Content-Type", "application/json");
            return builder.uponReceiving("query a server info success.")
                .path("/cloud-platform-service/v1/resource/pact-test-form-data")
                .method("POST")
                .body(entityBuilder)
                .willRespondWith()
                .status(200)
                .body(expectStr)
                .toPact();
        }
        
        @Test
        @PactTestFor(providerName = "FormDataAPI", port = "8500", pactMethod = "formDataReqTest")
        public void runTestformDataReq() throws IOException {
            File file = new File("C:\\Users\\g00574640\\Desktop\\importProjectList.xlsx");
            MultipartEntityBuilder entityBuilder =
                MultipartEntityBuilder.create()
                    .addTextBody("userName", "guojiahui").addTextBody("password", "123456")
                    .addBinaryBody("file", file,
                        ContentType.create("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"),
                        "importProjectList.xlsx");
    
            HttpEntity httpEntity = entityBuilder.build();
    
            CloseableHttpClient httpclient = HttpClients.createDefault();
            RequestBuilder request =
                <http://RequestBuilder.post|RequestBuilder.post>("<http://localhost:8500/cloud-platform-service/v1/resource/pact-test-form-data>")
                    .setEntity(httpEntity);
            HttpUriRequest httpUriRequest = request.build();
            httpclient.execute(httpUriRequest);
        }
    But when i verified this interface and executed
    Workbook workbook = new XSSFWorkbook(is)
    , I received an exception like this:`java.util.zip.DataFormatException: invalid block type` . Did I write the wrong pact? I loaded this file and found that this file is broken. What shoud I do?❤️
    👀 1
    u
    • 2
    • 2
  • j

    James Fraser

    03/28/2023, 8:09 AM
    Hey there 👋 I’m having a bit of trouble getting the
    pactVerify
    Gradle command to run for my message provider - it doesn’t seem to be able to find the methods I’ve annotated even though it should be on the test classpath I’ve commented out the
    packagesToScan
    section in my Gradle and it still can’t find it, it just gives me an error:
    Copy code
    No annotated methods were found for interaction 'message.interaction.name'. You need to provide a method annotated with @PactVerifyProvider("message.interaction.name") on the classpath that returns the message contents.
    I have a method annotated correctly in my test directory (the test runs and passes if I run it using JUnit):
    Copy code
    @PactVerifyProvider("message.interaction.name")
    public String verifyInteraction() {
        ...
    }
    My build.gradle currently looks like this:
    Copy code
    pact {
        broker {
            pactBrokerUrl = "$System.env.PACT_BROKER_BASE_URL"
            pactBrokerToken = "$System.env.PACT_BROKER_TOKEN"
        }
    
        serviceProviders {
            providerName {
                verificationType = 'ANNOTATED_METHOD'
                //  packagesToScan = ['*']
                hasPactsFromPactBroker("$System.env.PACT_BROKER_BASE_URL", authentication: ['Bearer', "$System.env.PACT_BROKER_TOKEN"])
            }
        }
    }
    If you’ve any suggestions on what I could try in order to sort this I’d really appreciate it - thanks 😄
    t
    u
    • 3
    • 13
  • g

    GitHub

    03/30/2023, 3:28 AM
    Release - 4.4.9 New release published by rholshausen Support verification tests for sync request/response messages with MessageTestTarget • b1e5c48 - feat(JUnit5): Add example to Junit 5 readme #1681 • c07f707 - feat(JUnit5): Support verification tests for sync request/response messages with MessageTestTarget #1681 • 1721cb0 - feat(DSL): check varargs for NULL values #1679 • 0a06556 - chore: Upgrade plugin driver to 0.3.2 pact-foundation/pact-jvm
  • g

    GitHub

    03/30/2023, 4:53 AM
    Release - 4.5.5 New release published by rholshausen Support verification tests for sync request/response messages with MessageTestTarget • b1e5c48 - feat(JUnit5): Add example to Junit 5 readme #1681 • c07f707 - feat(JUnit5): Support verification tests for sync request/response messages with MessageTestTarget #1681 • 1721cb0 - feat(DSL): check varargs for NULL values #1679 • 0a06556 - chore: Upgrade plugin driver to 0.3.2 pact-foundation/pact-jvm
    🎉 1
1...1011121314Latest