Small fixes
Change-Id: I985d91d6d8ac2ff88760f5011e75711ad7c68649
This commit is contained in:
parent
d6b9abfe05
commit
159f0a4987
1 changed files with 9 additions and 15 deletions
|
@ -8,6 +8,7 @@ import org.apache.http.entity.StringEntity;
|
|||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.infra.BenchmarkParams;
|
||||
import org.openjdk.jmh.infra.Blackhole;
|
||||
import org.openjdk.jmh.infra.ThreadParams;
|
||||
import pl.touk.mockserver.api.request.AddMock;
|
||||
import pl.touk.mockserver.server.HttpMockServer;
|
||||
|
@ -22,19 +23,12 @@ public class MockserverTest {
|
|||
|
||||
@Setup
|
||||
public void prepareMockServer(BenchmarkParams params) {
|
||||
try {
|
||||
httpMockServer = new HttpMockServer(9999);
|
||||
} catch (Exception e) {
|
||||
//OK
|
||||
}
|
||||
}
|
||||
|
||||
@TearDown
|
||||
public void stopMockServer() {
|
||||
try {
|
||||
httpMockServer.stop();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
@State(Scope.Thread)
|
||||
|
@ -51,14 +45,13 @@ public class MockserverTest {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Benchmark
|
||||
@Measurement(iterations = 60)
|
||||
@Fork(warmups = 1, value = 1)
|
||||
@BenchmarkMode({Mode.AverageTime, Mode.Throughput})
|
||||
@Warmup(iterations = 10)
|
||||
@Measurement(iterations = 10)
|
||||
@Fork(value = 2)
|
||||
@BenchmarkMode({Mode.AverageTime, Mode.Throughput, Mode.SampleTime})
|
||||
@Warmup(iterations = 5)
|
||||
@Threads(4)
|
||||
public void shouldHandleManyRequestsSimultaneously(TestState testState) throws IOException {
|
||||
public void shouldHandleManyRequestsSimultaneously(TestState testState, Blackhole bh) throws IOException {
|
||||
int current = testState.current;
|
||||
int endpointNumber = current % 10;
|
||||
int port = 9000 + (current % 7);
|
||||
|
@ -75,6 +68,7 @@ public class MockserverTest {
|
|||
String stringResponse = Util.extractStringResponse(response);
|
||||
testState.remoteMockServer.removeMock("testRest" + current, true);
|
||||
assert stringResponse.equals("<goodResponse" + current + "/>");
|
||||
bh.consume(stringResponse);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue