Search in sources :

Example 1 with TenantClient

use of org.folio.rest.client.TenantClient 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 2 with TenantClient

use of org.folio.rest.client.TenantClient in project raml-module-builder by folio-org.

the class TenantInitTest method testBadPortGet.

@Test
public void testBadPortGet(TestContext context) {
    TenantClient client2 = new TenantClient("http://localhost:" + NetworkUtils.nextFreePort(), "library", null);
    Future.<Void>future(promise -> TenantInit.execGet(client2, "1", 1, promise)).onComplete(context.asyncAssertFailure(cause -> {
        assertThat(cause, isA(ConnectException.class));
    }));
}
Also used : TestContext(io.vertx.ext.unit.TestContext) AfterClass(org.junit.AfterClass) Matchers.isA(org.hamcrest.Matchers.isA) BeforeClass(org.junit.BeforeClass) Vertx(io.vertx.core.Vertx) RunWith(org.junit.runner.RunWith) Router(io.vertx.ext.web.Router) Test(org.junit.Test) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) RoutingContext(io.vertx.ext.web.RoutingContext) BodyHandler(io.vertx.ext.web.handler.BodyHandler) Future(io.vertx.core.Future) TenantClient(org.folio.rest.client.TenantClient) Buffer(io.vertx.core.buffer.Buffer) UtilityClassTester(org.folio.okapi.testing.UtilityClassTester) TenantAttributes(org.folio.rest.jaxrs.model.TenantAttributes) HttpServerOptions(io.vertx.core.http.HttpServerOptions) ConnectException(java.net.ConnectException) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) TenantClient(org.folio.rest.client.TenantClient) Test(org.junit.Test)

Example 3 with TenantClient

use of org.folio.rest.client.TenantClient in project raml-module-builder by folio-org.

the class Test method main.

/**
 * @param args
 */
public static void main(String[] args) throws Exception {
    // TODO Auto-generated method stub
    MimeMultipart mmp = new MimeMultipart();
    BodyPart bp = new MimeBodyPart(new FileInputStream("C:\\Git\\mod-files\\ramls\\mod-files\\files.raml"));
    bp.setDisposition("form-data");
    bp.setFileName("abc.raml");
    BodyPart bp2 = new MimeBodyPart(new FileInputStream("C:\\Git\\mod-files\\ramls\\mod-files\\files.raml"));
    bp2.setDisposition("form-data");
    bp2.setFileName("abcd.raml");
    mmp.addBodyPart(bp);
    mmp.addBodyPart(bp2);
    AdminClient aClient = new AdminClient("localhost", 8888, null, null, false);
    aClient.postUploadmultipart(PersistMethod.SAVE, null, "abc", mmp, reply -> {
        reply.statusCode();
    });
    /*    aClient.postImportSQL(
      Test.class.getClassLoader().getResourceAsStream("create_config.sql"), reply -> {
      reply.statusCode();
    });*/
    aClient.getJstack(trace -> {
        trace.bodyHandler(content -> {
            System.out.println(content);
        });
    });
    TenantClient tc = new TenantClient("localhost", 8888, "harvard", "harvard");
    tc.post(null, response -> {
        response.bodyHandler(body -> {
            System.out.println(body.toString());
            tc.delete(reply -> {
                reply.bodyHandler(body2 -> {
                    System.out.println(body2.toString());
                });
            });
        });
    });
    aClient.getPostgresActiveSessions("postgres", reply -> {
        reply.bodyHandler(body -> {
            System.out.println(body.toString("UTF8"));
        });
    });
    aClient.getPostgresLoad("postgres", reply -> {
        reply.bodyHandler(body -> {
            System.out.println(body.toString("UTF8"));
        });
    });
    aClient.getPostgresTableAccessStats(reply -> {
        reply.bodyHandler(body -> {
            System.out.println(body.toString("UTF8"));
        });
    });
    aClient.getPostgresTableSize("postgres", reply -> {
        reply.bodyHandler(body -> {
            System.out.println(body.toString("UTF8"));
        });
    });
}
Also used : MimeBodyPart(javax.mail.internet.MimeBodyPart) BodyPart(javax.mail.BodyPart) MimeMultipart(javax.mail.internet.MimeMultipart) TenantClient(org.folio.rest.client.TenantClient) MimeBodyPart(javax.mail.internet.MimeBodyPart) FileInputStream(java.io.FileInputStream) AdminClient(org.folio.rest.client.AdminClient)

Example 4 with TenantClient

use of org.folio.rest.client.TenantClient in project raml-module-builder by folio-org.

the class TenantInitTest method testBadPortPost.

@Test
public void testBadPortPost(TestContext context) {
    TenantClient client2 = new TenantClient("http://localhost:" + NetworkUtils.nextFreePort(), "library", null);
    TenantAttributes ta = new TenantAttributes().withModuleTo("module-1.0.0");
    TenantInit.exec(client2, ta, 1).onComplete(context.asyncAssertFailure(cause -> assertThat(cause, isA(ConnectException.class))));
}
Also used : TestContext(io.vertx.ext.unit.TestContext) AfterClass(org.junit.AfterClass) Matchers.isA(org.hamcrest.Matchers.isA) BeforeClass(org.junit.BeforeClass) Vertx(io.vertx.core.Vertx) RunWith(org.junit.runner.RunWith) Router(io.vertx.ext.web.Router) Test(org.junit.Test) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) RoutingContext(io.vertx.ext.web.RoutingContext) BodyHandler(io.vertx.ext.web.handler.BodyHandler) Future(io.vertx.core.Future) TenantClient(org.folio.rest.client.TenantClient) Buffer(io.vertx.core.buffer.Buffer) UtilityClassTester(org.folio.okapi.testing.UtilityClassTester) TenantAttributes(org.folio.rest.jaxrs.model.TenantAttributes) HttpServerOptions(io.vertx.core.http.HttpServerOptions) ConnectException(java.net.ConnectException) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) TenantAttributes(org.folio.rest.jaxrs.model.TenantAttributes) TenantClient(org.folio.rest.client.TenantClient) ConnectException(java.net.ConnectException) Test(org.junit.Test)

Example 5 with TenantClient

use of org.folio.rest.client.TenantClient in project raml-module-builder by folio-org.

the class TenantInitTest method beforeClass.

@BeforeClass
public static void beforeClass(TestContext context) {
    vertx = Vertx.vertx();
    port = NetworkUtils.nextFreePort();
    Router router = Router.router(vertx);
    router.post("/_/tenant").handler(BodyHandler.create());
    router.post("/_/tenant").handler(TenantInitTest::postHandler);
    router.getWithRegex("/_/tenant/.*").handler(TenantInitTest::getHandler);
    router.deleteWithRegex("/_/tenant/.*").handler(TenantInitTest::deleteHandler);
    client = new TenantClient("http://localhost:" + port, "testlib", null);
    HttpServerOptions so = new HttpServerOptions().setHandle100ContinueAutomatically(true);
    vertx.createHttpServer(so).requestHandler(router).listen(port).onComplete(context.asyncAssertSuccess());
}
Also used : TenantClient(org.folio.rest.client.TenantClient) HttpServerOptions(io.vertx.core.http.HttpServerOptions) Router(io.vertx.ext.web.Router) BeforeClass(org.junit.BeforeClass)

Aggregations

TenantClient (org.folio.rest.client.TenantClient)5 BeforeClass (org.junit.BeforeClass)4 HttpServerOptions (io.vertx.core.http.HttpServerOptions)3 Router (io.vertx.ext.web.Router)3 TenantAttributes (org.folio.rest.jaxrs.model.TenantAttributes)3 Future (io.vertx.core.Future)2 Vertx (io.vertx.core.Vertx)2 Buffer (io.vertx.core.buffer.Buffer)2 TestContext (io.vertx.ext.unit.TestContext)2 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)2 RoutingContext (io.vertx.ext.web.RoutingContext)2 BodyHandler (io.vertx.ext.web.handler.BodyHandler)2 ConnectException (java.net.ConnectException)2 UtilityClassTester (org.folio.okapi.testing.UtilityClassTester)2 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)2 Matchers.isA (org.hamcrest.Matchers.isA)2 AfterClass (org.junit.AfterClass)2 Test (org.junit.Test)2 RunWith (org.junit.runner.RunWith)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1