Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pact content-type override for text/plain to xml is not picked up #1812

Closed
peterhagens-coder opened this issue Jul 3, 2024 · 8 comments
Closed
Labels
bug Indicates an unexpected problem or unintended behavior smartbear-supported SmartBear engineering team will support this issue. See https://docs.pact.io/help/smartbear

Comments

@peterhagens-coder
Copy link

I'm using the pact.content_type.override system property to override the matchers for text/plain to be xml.
System.setProperty("pact.content_type.override.text/plain", "xml"); However, this is not working.

I verified the system property is being picked up (e.g. by testing overriding bla/bla to json and verify this works). However, it's not possible for me to override text/plain to use xml. (The reason I need to do this is that the provider I'm testing actually expects xml content but puts a content-type of text/plain).

In the debug logs of my test, I see the PlainText matchers is still used.
DEBUG a.c.dius.pact.core.matchers.Matching.matchBody - Found a matcher for text/plain -> au.com.dius.pact.core.matchers.PlainTextContentMatcher@d6c9b3c

(Note: I will also need this later in the pact-stub-server)

Version used:

<dependency>
  <groupId>au.com.dius.pact.consumer</groupId>
  <artifactId>junit5</artifactId>
  <version>4.6.7</version>
   <scope>test</scope>
</dependency>
@rholshausen rholshausen added bug Indicates an unexpected problem or unintended behavior smartbear-supported SmartBear engineering team will support this issue. See https://docs.pact.io/help/smartbear labels Jul 4, 2024
Copy link

github-actions bot commented Jul 4, 2024

🤖 Great news! We've labeled this issue as smartbear-supported and created a tracking ticket in PactFlow's Jira (PACT-2136). We'll keep work public and post updates here. Meanwhile, feel free to check out our docs. Thanks for your patience!

@rholshausen
Copy link
Contributor

With this change, you will need to use the full content type, i.e., System.setProperty("pact.content_type.override.text/plain", "application/xml");

@peterhagens-coder
Copy link
Author

Thx. I tried your suggestion, but it still matches as plain text:
04-07-2024 08:10:03.554 [HTTP-Dispatcher] DEBUG a.c.dius.pact.core.matchers.Matching.matchBody - Found a matcher for text/plain -> au.com.dius.pact.core.matchers.PlainTextContentMatcher@6e8b3523

@rholshausen
Copy link
Contributor

Did you use the latest version, or build Pact-JVM yourself? This hasn't been released yet.

@peterhagens-coder
Copy link
Author

Sorry, misread your message. Will wait until released and try again.

@rholshausen
Copy link
Contributor

4.6.11 has been released

@YOU54F
Copy link
Member

YOU54F commented Jul 24, 2024

are you able to retry @peterhagens-coder and if complete we can close this issue. thanks!

@peterhagens-coder
Copy link
Author

Retried and confirmed the solution works. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior smartbear-supported SmartBear engineering team will support this issue. See https://docs.pact.io/help/smartbear
Projects
None yet
Development

No branches or pull requests

3 participants