Coder Social home page Coder Social logo

Empty Request Body about wiremock HOT 7 CLOSED

wiremock avatar wiremock commented on May 22, 2024
Empty Request Body

from wiremock.

Comments (7)

tomakehurst avatar tomakehurst commented on May 22, 2024

Hi,

Would you mind sending me the version of WireMock you're using, whether you're using the standalone JAR and the version of the Apache HTTP client you're using?

Also does your bigLumpOfJson have any unusual characters in it? And is it very large?

Many thanks,
Tom

from wiremock.

 avatar commented on May 22, 2024

No worries

HttpClient is 4.2.3 GA
WireMock is 1.28 - I was not using the standalone JAR, I was driving it around with JUnit

the bigLumpOfJson is only a few hundred bytes in the test case:

{"serviceName":"AttributionEngine","hostName":"localhost","version":"1.0",
"startTime":"20130221T133518Z","status":"ACTIVE","intervals":60,"intervalSize":"minutes",
"serverTime":"20130221T133732Z","javaVersion":"1.7.0_10","counters":[]}

from wiremock.

tomakehurst avatar tomakehurst commented on May 22, 2024

I've tried to replicate this issue as closely as possible based on the info and code you've given me and everything seems to be working normally. Here's the full test case I used. Perhaps you can spot a crucial difference from what you've done:

package wiremock.test;


import com.github.tomakehurst.wiremock.junit.WireMockRule;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.junit.Rule;
import org.junit.Test;

import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static junit.framework.Assert.assertFalse;

public class AppTest {

    @Rule
    public WireMockRule wireMockRule = new WireMockRule();

    @Test
    public void test() throws Exception {
        String bigLumpOfJSON = "{\"serviceName\":\"AttributionEngine\",\"hostName\":\"localhost\",\"version\":\"1.0\",\n" +
                "\"startTime\":\"20130221T133518Z\",\"status\":\"ACTIVE\",\"intervals\":60,\"intervalSize\":\"minutes\",\n" +
                "\"serverTime\":\"20130221T133732Z\",\"javaVersion\":\"1.7.0_10\",\"counters\":[]}";

        stubFor(get(urlEqualTo("/some/thing"))
                .willReturn(aResponse()
                        .withHeader("Content-Type", "application/json")
                        .withBody(bigLumpOfJSON)));


        final HttpGet request = new HttpGet("http://localhost:8080/some/thing");
        final HttpResponse httpResponse = new DefaultHttpClient().execute(request);
        final int statusCode = httpResponse.getStatusLine().getStatusCode();

        if (HttpStatus.SC_OK == statusCode) {
            final HttpEntity entity = httpResponse.getEntity();

            if (entity == null) {
                throw new RuntimeException("No content in the response");
            } else {
                final String body = EntityUtils.toString(entity, "UTF-8");

                System.out.println(body);
                assertFalse(body.isEmpty());
            }

        } else {
            throw new RuntimeException("Server Returned " + statusCode);
        }
    }
}

from wiremock.

 avatar commented on May 22, 2024

This is profoundly weird. I'm starting to think that the problem is on the HttpClient end, and there is some weird emergent behaviour arising out of the intersection of Ubuntu, 1.7.0_10 and a slightly wonky network configuration. I will keep banging on this to see if I can get any further.

from wiremock.

tomakehurst avatar tomakehurst commented on May 22, 2024

Right, I'm on a Mac so unfortunately I can't replicate that part. Please
let me know if it does turn out to be a bug or some kind of OS interaction

  • trying to make it as robust as possible!

Thanks,
Tom

On 27 February 2013 09:41, Robert Hook [email protected] wrote:

This is profoundly weird. I'm starting to think that the problem is on the
HttpClient end, and there is some weird emergent behaviour arising out of
the intersection of Ubuntu, 1.7.0_10 and a slightly wonky network
configuration. I will keep banging on this to see if I can get any further.


Reply to this email directly or view it on GitHubhttps://github.com/tomakehurst/wiremock/issues/14#issuecomment-14164874
.

from wiremock.

 avatar commented on May 22, 2024

Will do. I will work with the test case you've built above on several different platforms and see what comes out.

ADDENDUM: the plot thickens - the test case above is now working on the combination of Ubuntu and 1.7.0_10, strongly suggesting some wonkiness in the network configuration has become involved.

ADDENDUM 2: I loathe Heisenbugs (http://www.catb.org/jargon/html/H/heisenbug.html). I cannot reproduce this fault at all now. There are two things that have changed: Commons IO was bumped from 2.3 to 2.4, and our network is not as flaky as it was on Thursday when the problem manifested. I will continue to monitor the behaviour in our environment, but at this stage think that the issue can be closed off as "problem exists between keyboard and chair".

I have moved our testing fully to WireMock, and directed my team to run forward with it - it's exactly right solution for our requirements.

from wiremock.

tomakehurst avatar tomakehurst commented on May 22, 2024

Thanks for the feedback. Good to hear its proving to be useful!

HTTPS support to be released shortly if that's of any interest.

from wiremock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.