Skip to content

Instantly share code, notes, and snippets.

@mbjelac
Created November 21, 2017 08:08
Show Gist options
  • Save mbjelac/8deaf995394a73101ea71941672af363 to your computer and use it in GitHub Desktop.
Save mbjelac/8deaf995394a73101ea71941672af363 to your computer and use it in GitHub Desktop.
MockServer reset lag: multiple tests including NettyClient
import org.apache.http.client.fluent.Request;
import org.junit.Before;
import org.junit.Test;
import org.mockserver.client.netty.NettyHttpClient;
import org.mockserver.client.server.MockServerClient;
import org.mockserver.model.HttpRequest;
import org.mockserver.model.OutboundHttpRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
public class MockServerTroubleshootingTest {
private static final String HOST = "192.168.0.196";
private static final int PORT = 1080;
private static final MockServerClient mockServerClient = new MockServerClient(HOST, PORT);
private static final NettyHttpClient nettyClient = new NettyHttpClient();
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Before
public void setUp() {
logger.info("dummy log");
}
@Test
public void reset_with_apache_1() throws IOException {
resetWithApache();
}
@Test
public void reset_with_apache_2() throws IOException {
resetWithApache();
}
@Test
public void reset_with_apache_3() throws IOException {
resetWithApache();
}
private void resetWithApache() throws IOException {
Request.Put("http://" + HOST + ":" + PORT + "/reset")
.addHeader("Host", HOST + ":" + PORT)
.addHeader("Accept-Encoding", "gzip,deflate")
.addHeader("Connection", "keep-alive")
.execute();
}
@Test
public void reset_with_MockServerClient_1() {
mockServerClient.reset();
}
@Test
public void reset_with_MockServerClient_2() {
mockServerClient.reset();
}
@Test
public void reset_with_MockServerClient_3() {
mockServerClient.reset();
}
@Test
public void reset_with_netty_1() {
resetWithNetty();
}
@Test
public void reset_with_netty_2() {
resetWithNetty();
}
@Test
public void reset_with_netty_3() {
resetWithNetty();
}
private void resetWithNetty() {
nettyClient.sendRequest(
new OutboundHttpRequest(
HOST,
PORT,
"/reset",
new HttpRequest().withMethod("PUT")));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment