question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AmqpTarget missing on pact-jvm-provider-junit 3.5.0-beta.2

See original GitHub issue

I’m trying to get a simple test for consumer & producer up and running in a Messaging Queue scenario with pact-jvm-provider-junit and pact-jvm-consumer-junit. I tried running 3.3.4 where AmqpTarget exists, but the consumer part seems to generate a message format which doesn’t play nicely with JSON data comparisons. This code:

PactDslJsonBody body = new PactDslJsonBody()
        .stringValue("name", "value1")
        .numberValue("value", 1);

    Map<String, String> metadata = new HashMap<String, String>();
    metadata.put("contentType", "application/json");

    return builder.given("SomeProviderState")
        .expectsToReceive("a test message")
        .withMetadata(metadata)
        .withContent(body)
        .toPact();

Produces a pact-file like:

{
    "description": "a test message",
    "metaData": {
        "contentType": "application/json",
        "Content-Type": "application/json; charset=UTF-8"
    },
    "contents": "{name=value1, value=1}",
    "providerState": "SomeProviderState"
}

The contents then fail my provider tests, as it’s doing the comparison wrong. This very simple test:

@PactVerifyProvider("a test message")
  public String verifySimpleMessage() throws Exception {
    ExampleThing thing = new ExampleThing();
    thing.name = "value1";
    thing.value = 1;

    return DummyEventHandler.exampleThingToJson(thing);
  }

fails with

java.lang.AssertionError: 
0 - $.body -> Expected '{name=value1, value=1}' but received Map(name -> value1, value -> 1)

Upgrading to 3.5.0-beta.2 I get much better pact-file output from my consumer, but the AmqpTarget class doesn’t exist so I can’t test my producer. The 3.5.0-beta.2 pact-file for the same code as above is:

{
    "description": "a test message",
    "contents": {
        "name": "value1",
        "value": 1
    },
    "providerState": "SomeProviderState"
}

Should AmqpTarget exist in the 3.5-branches, or is there another way of doing these tests in 3.5 that I’m missing?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
uglyogcommented, Jan 18, 2017

Yes it was a regression, possibly introduced in version 3.3.0, but the AmqpTarget was introduced in 3.3.2.

I should be able to get a new 3.3.x version out soon, the 3.5.x will take a little longer.

0reactions
uglyogcommented, Sep 9, 2017

Closing this as v3.5.x has been released.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AmqpTarget missing on pact-jvm-provider-junit 3.5.0-beta.2
I'm trying to get a simple test for consumer & producer up and running in a Messaging Queue scenario with pact-jvm-provider-junit and ...
Read more >
pact-jvm
So I I can see that pact-jvm-server can be used to record pacts from real ... artifact id `pact-jvm-consumer-junit_2.12` version `3.5.16` is not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found