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

Error parsing simple root-level string as JSON #369

Closed
mouserd opened this issue Jan 19, 2017 · 3 comments
Closed

Error parsing simple root-level string as JSON #369

mouserd opened this issue Jan 19, 2017 · 3 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@mouserd
Copy link

mouserd commented Jan 19, 2017

I'm trying to create a PACT consumer test for a provider that returns a simple String as it's response body with a Content-Type of application/json. I am declaring my PACT fragment as follows:

        Map<String, String> headers = new HashMap<String, String>();
        headers.put("Content-Type", "application/json");

        builder
                .uponReceiving("a request for a simple string")
                    .path("/provider/uri")
                    .method("GET")
                .willRespondWith()
                    .status(STATUS_OK)
                    .headers(headers)
                    .body(PactDslJsonRootValue.stringType())
                .toFragment();

However, when I run this junit consumer test (as a consumer) I receive the following error:

groovy.json.JsonException: false not parsed properly

The current character read is 'f' with an int value of 102
false not parsed properly
line number 1
index number 1
fMqERmSJkswiAwHKYlbV
.^

If I change the Content-Type to text/plain the unit test will run and the PACT contract will be created, however it will obviously fail when run against our provider. I have also tried creating the fragment using a String literal as the body (rather than the type matcher) with the same result.

Is this a bug or is there another way to test this type of provider?

Thanks in advance!

Dave

@uglyog
Copy link
Member

uglyog commented Jan 19, 2017

Hi Dave, could you provide the stack trace or debug logs?

@uglyog uglyog added the bug Indicates an unexpected problem or unintended behavior label Jan 19, 2017
@uglyog
Copy link
Member

uglyog commented Jan 19, 2017

Don't worry, I have confirmed the behaviour and it is a defect.

@mouserd
Copy link
Author

mouserd commented Jan 19, 2017

OK - thanks @uglyog - I really appreciate you looking into this for me so quickly!!

Let me know if you do need anything else from me.

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
Projects
None yet
Development

No branches or pull requests

2 participants