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

Created new constructor in MockSerializationResult and implemented getStatus in MockHttpServletResponse #549

Merged
merged 2 commits into from
Jul 9, 2013

Conversation

FelipeThi
Copy link

When you're using MockSerializationResult and you have to change response status code, you can't test it, because MockSerializationResult already instantiates MockHttpServletResponse.

@@ -75,6 +75,11 @@ public MockSerializationResult() {
this(new JavassistProxifier(new ObjenesisInstanceCreator()), new NullProxyInitializer());
}

public MockSerializationResult(MockHttpServletResponse response) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to use MockHttpServletResponse instead of HttpServletResponse?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. because MockSerializationResult uses MockHttpServletResponse internal methods that don't come from the inferface (HttpServletResponse), like that:

public String serializedResult() throws Exception {

    if("application/xml".equals(response.getContentType())){
        return response.getContentAsString();
    }

    if("application/json".equals(response.getContentType())){
        return response.getContentAsString();
    }

    return null;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok then =)

lucascs added a commit that referenced this pull request Jul 9, 2013
Created new constructor in MockSerializationResult and implemented getStatus in MockHttpServletResponse
@lucascs lucascs merged commit fa44207 into caelum:master Jul 9, 2013
@lucascs
Copy link
Member

lucascs commented Jul 9, 2013

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants