Search in sources :

Example 1 with PostgresTesterContainer

use of org.folio.postgres.testing.PostgresTesterContainer in project raml-module-builder by folio-org.

the class PostgresClientIT method setUpClass.

@BeforeClass
public static void setUpClass(TestContext context) throws Exception {
    vertx = VertxUtils.getVertxWithExceptionHandler();
    PostgresClient.setPostgresTester(new PostgresTesterContainer());
    PostgresClient.setExplainQueryThreshold(0);
    // fail the complete test class if the connection to postgres doesn't work
    PostgresClient.getInstance(vertx).execute("SELECT 1", context.asyncAssertSuccess());
}
Also used : PostgresTesterContainer(org.folio.postgres.testing.PostgresTesterContainer) BeforeClass(org.junit.BeforeClass)

Example 2 with PostgresTesterContainer

use of org.folio.postgres.testing.PostgresTesterContainer in project raml-module-builder by folio-org.

the class DemoRamlRestTest method setUp.

/**
 * @param context  the test context.
 */
@BeforeClass
public static void setUp(TestContext context) {
    PostgresClient.setPostgresTester(new PostgresTesterContainer());
    vertx = VertxUtils.getVertxWithExceptionHandler();
    port = NetworkUtils.nextFreePort();
    RestAssured.port = port;
    RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
    tenant = new RequestSpecBuilder().addHeader("x-okapi-tenant", TENANT).build();
    try {
        deployRestVerticle(context);
        client = new TenantClient("http://localhost:" + port, TENANT, null);
        TenantAttributes ta = new TenantAttributes().withModuleTo("raml-module-builder-1.0.0");
        TenantInit.exec(client, ta, 60000).onComplete(context.asyncAssertSuccess());
    } catch (Exception e) {
        context.fail(e);
    }
}
Also used : TenantAttributes(org.folio.rest.jaxrs.model.TenantAttributes) TenantClient(org.folio.rest.client.TenantClient) PostgresTesterContainer(org.folio.postgres.testing.PostgresTesterContainer) RequestSpecBuilder(io.restassured.builder.RequestSpecBuilder) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) BeforeClass(org.junit.BeforeClass)

Example 3 with PostgresTesterContainer

use of org.folio.postgres.testing.PostgresTesterContainer in project raml-module-builder by folio-org.

the class AdminAPIIT method setUpClass.

@BeforeClass
public static void setUpClass() {
    vertx = VertxUtils.getVertxWithExceptionHandler();
    PostgresClient.setPostgresTester(new PostgresTesterContainer());
}
Also used : PostgresTesterContainer(org.folio.postgres.testing.PostgresTesterContainer) BeforeClass(org.junit.BeforeClass)

Example 4 with PostgresTesterContainer

use of org.folio.postgres.testing.PostgresTesterContainer in project raml-module-builder by folio-org.

the class TenantAPIIT method setUpClass.

@BeforeClass
public static void setUpClass() {
    vertx = VertxUtils.getVertxWithExceptionHandler();
    PostgresClient.setPostgresTester(new PostgresTesterContainer());
}
Also used : PostgresTesterContainer(org.folio.postgres.testing.PostgresTesterContainer)

Example 5 with PostgresTesterContainer

use of org.folio.postgres.testing.PostgresTesterContainer in project raml-module-builder by folio-org.

the class ApiTestBase method beforeAll.

@BeforeAll
static void beforeAll() {
    RestAssured.port = 9230;
    RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
    vertx = VertxUtils.getVertxWithExceptionHandler();
    // once for all test classes: starting and tenant initialization
    if (deploymentFuture.isDone()) {
        return;
    }
    PostgresClient.setPostgresTester(new PostgresTesterContainer());
    DeploymentOptions deploymentOptions = new DeploymentOptions().setConfig(new JsonObject().put("http.port", RestAssured.port));
    vertx.deployVerticle(RestVerticle.class, deploymentOptions, deploy -> {
        if (deploy.failed()) {
            deploymentFuture.completeExceptionally(deploy.cause());
            return;
        }
        deploymentFuture.complete(deploy.result());
    });
    try {
        deploymentFuture.get(10, TimeUnit.SECONDS);
    } catch (InterruptedException | ExecutionException | TimeoutException e) {
        throw new RuntimeException(e);
    }
    r = given().filter(new ErrorLoggingFilter()).header("x-okapi-tenant", "testlib").contentType(ContentType.JSON);
    // delete tenant (schema, tables, ...) if it exists from previous tests
    TenantAttributes ta = new TenantAttributes().withPurge(true);
    given(r).header("x-okapi-url-to", "http://localhost:" + port).contentType(ContentType.JSON).body(Json.encode(ta)).when().post("/_/tenant").then().statusCode(204);
    List<Parameter> list = new LinkedList<>();
    list.add(new Parameter().withKey("loadReference").withValue("true"));
    ta = new TenantAttributes().withModuleTo("mod-api-1.0.0").withParameters(list);
    // create tenant (schema, tables, ...)
    String location = given(r).header("x-okapi-url-to", "http://localhost:" + port).contentType(ContentType.JSON).body(Json.encode(ta)).when().post("/_/tenant").then().statusCode(201).extract().header("Location");
    given(r).header("x-okapi-url-to", "http://localhost:" + port).when().get(location + "?wait=5000").then().statusCode(200).body("error", is(nullValue()));
}
Also used : JsonObject(io.vertx.core.json.JsonObject) LinkedList(java.util.LinkedList) DeploymentOptions(io.vertx.core.DeploymentOptions) TenantAttributes(org.folio.rest.jaxrs.model.TenantAttributes) Parameter(org.folio.rest.jaxrs.model.Parameter) PostgresTesterContainer(org.folio.postgres.testing.PostgresTesterContainer) ExecutionException(java.util.concurrent.ExecutionException) ErrorLoggingFilter(io.restassured.filter.log.ErrorLoggingFilter) TimeoutException(java.util.concurrent.TimeoutException) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

PostgresTesterContainer (org.folio.postgres.testing.PostgresTesterContainer)9 BeforeClass (org.junit.BeforeClass)5 JsonObject (io.vertx.core.json.JsonObject)2 TenantAttributes (org.folio.rest.jaxrs.model.TenantAttributes)2 BeforeAll (org.junit.jupiter.api.BeforeAll)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 RequestSpecBuilder (io.restassured.builder.RequestSpecBuilder)1 ErrorLoggingFilter (io.restassured.filter.log.ErrorLoggingFilter)1 AsyncResult (io.vertx.core.AsyncResult)1 DeploymentOptions (io.vertx.core.DeploymentOptions)1 Future (io.vertx.core.Future)1 Handler (io.vertx.core.Handler)1 Vertx (io.vertx.core.Vertx)1 JsonArray (io.vertx.core.json.JsonArray)1 Timeout (io.vertx.junit5.Timeout)1 VertxExtension (io.vertx.junit5.VertxExtension)1 VertxTestContext (io.vertx.junit5.VertxTestContext)1 PgConnection (io.vertx.pgclient.PgConnection)1 Collections (java.util.Collections)1 LinkedList (java.util.LinkedList)1