Created
November 21, 2017 08:08
-
-
Save mbjelac/2d39cd916dae5a08836f67df4ff172be to your computer and use it in GitHub Desktop.
MockServer reset lag: multiple tests including NettyClient
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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