Search in sources :

Example 1 with MockServer

use of org.folio.rest.impl.MockServer in project mod-invoice by folio-org.

the class ApiTestSuite method before.

@BeforeAll
public static void before() throws InterruptedException, ExecutionException, TimeoutException {
    if (vertx == null) {
        vertx = Vertx.vertx();
    }
    mockServer = new MockServer(mockPort);
    mockServer.start();
    RestAssured.baseURI = "http://localhost:" + okapiPort;
    RestAssured.port = okapiPort;
    RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
    kafkaCluster = EmbeddedKafkaCluster.provisionWith(useDefaults());
    kafkaCluster.start();
    String[] hostAndPort = kafkaCluster.getBrokerList().split(":");
    System.setProperty(KAFKA_HOST, hostAndPort[0]);
    System.setProperty(KAFKA_PORT, hostAndPort[1]);
    System.setProperty(KAFKA_ENV, KAFKA_ENV_VALUE);
    System.setProperty(OKAPI_URL_KEY, "http://localhost:" + mockPort);
    final JsonObject conf = new JsonObject();
    conf.put("http.port", okapiPort);
    final DeploymentOptions opt = new DeploymentOptions().setConfig(conf);
    CompletableFuture<String> deploymentComplete = new CompletableFuture<>();
    vertx.deployVerticle(RestVerticle.class.getName(), opt, res -> {
        if (res.succeeded()) {
            deploymentComplete.complete(res.result());
        } else {
            deploymentComplete.completeExceptionally(res.cause());
        }
    });
    deploymentComplete.get(60, TimeUnit.SECONDS);
    initialised = true;
}
Also used : RestVerticle(org.folio.rest.RestVerticle) CompletableFuture(java.util.concurrent.CompletableFuture) DeploymentOptions(io.vertx.core.DeploymentOptions) MockServer(org.folio.rest.impl.MockServer) JsonObject(io.vertx.core.json.JsonObject) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 2 with MockServer

use of org.folio.rest.impl.MockServer in project mod-orders by folio-org.

the class TestConfig method startMockServer.

public static void startMockServer() throws InterruptedException, ExecutionException, TimeoutException {
    mockServer = new MockServer(mockPort);
    mockServer.start();
}
Also used : MockServer(org.folio.rest.impl.MockServer)

Aggregations

MockServer (org.folio.rest.impl.MockServer)2 DeploymentOptions (io.vertx.core.DeploymentOptions)1 JsonObject (io.vertx.core.json.JsonObject)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 RestVerticle (org.folio.rest.RestVerticle)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1