use of guru.nidi.ramltester.restassured3.RestAssuredClient in project okapi by folio-org.
the class ModuleTest method testDeployment2.
private void testDeployment2(Async async, TestContext context) {
logger.info("testDeployment2");
Response r;
RestAssuredClient c;
c = api.createRestAssured3();
c.given().delete(locationSampleDeployment).then().statusCode(204);
Assert.assertTrue("raml: " + c.getLastReport().toString(), c.getLastReport().isEmpty());
c = api.createRestAssured3();
c.given().delete(locationSampleDeployment).then().statusCode(404);
Assert.assertTrue("raml: " + c.getLastReport().toString(), c.getLastReport().isEmpty());
locationSampleDeployment = null;
// Verify that the list works also after delete
c = api.createRestAssured3();
c.given().get("/_/deployment/modules").then().statusCode(200).body(equalTo("[ ]"));
Assert.assertTrue("raml: " + c.getLastReport().toString(), c.getLastReport().isEmpty());
// verify that module5 is no longer there
c = api.createRestAssured3();
c.given().get("/_/discovery/modules/sample-module5").then().statusCode(404);
Assert.assertTrue("raml: " + c.getLastReport().toString(), c.getLastReport().isEmpty());
// verify that a never-seen module returns the same
c = api.createRestAssured3();
c.given().get("/_/discovery/modules/UNKNOWN-MODULE").then().statusCode(404);
Assert.assertTrue("raml: " + c.getLastReport().toString(), c.getLastReport().isEmpty());
// Deploy a module via its own LaunchDescriptor
final String docSampleModule = "{" + LS + " \"id\" : \"sample-module-depl-1\"," + LS + " \"name\" : \"sample module for deployment test\"," + LS + " \"provides\" : [ {" + LS + " \"id\" : \"sample\"," + LS + " \"version\" : \"1.0\"," + LS + " \"handlers\" : [ {" + LS + " \"methods\" : [ \"GET\", \"POST\" ]," + LS + " \"path\" : \"/testb\"," + LS + " \"level\" : \"30\"," + LS + " \"type\" : \"request-response\"" + LS + " } ]" + LS + " }, {" + LS + " \"id\" : \"_tenant\"," + LS + " \"version\" : \"1.0\"" + LS + " } ]," + LS + " \"launchDescriptor\" : {" + LS + " \"exec\" : \"java -Dport=%p -jar ../okapi-test-module/target/okapi-test-module-fat.jar\"" + LS + " }" + LS + "}";
c = api.createRestAssured3();
r = c.given().header("Content-Type", "application/json").body(docSampleModule).post("/_/proxy/modules").then().statusCode(201).extract().response();
Assert.assertTrue("raml: " + c.getLastReport().toString(), c.getLastReport().isEmpty());
final String locationSampleModule = r.getHeader("Location");
// Specify the node via url, to test that too
final String docDeploy = "{" + LS + " \"instId\" : \"localhost-9231\"," + LS + " \"srvcId\" : \"sample-module-depl-1\"," + LS + " \"nodeId\" : \"http://localhost:9230\"" + LS + "}";
final String DeployResp = "{" + LS + " \"instId\" : \"localhost-9231\"," + LS + " \"srvcId\" : \"sample-module-depl-1\"," + LS + " \"nodeId\" : \"http://localhost:9230\"," + LS + " \"url\" : \"http://localhost:9231\"," + LS + " \"descriptor\" : {" + LS + " \"exec\" : \"java -Dport=%p -jar ../okapi-test-module/target/okapi-test-module-fat.jar\"" + LS + " }" + LS + "}";
c = api.createRestAssured3();
r = c.given().header("Content-Type", "application/json").body(docDeploy).post("/_/discovery/modules").then().statusCode(201).body(equalTo(DeployResp)).extract().response();
Assert.assertTrue("raml: " + c.getLastReport().toString(), c.getLastReport().isEmpty());
locationSampleDeployment = r.getHeader("Location");
// Would be nice to verify that the module works, but too much hassle with
// tenants etc.
// Undeploy.
c = api.createRestAssured3();
c.given().delete(locationSampleDeployment).then().statusCode(204);
Assert.assertTrue("raml: " + c.getLastReport().toString(), c.getLastReport().isEmpty());
// Undeploy again, to see it is gone
c = api.createRestAssured3();
c.given().delete(locationSampleDeployment).then().statusCode(404);
Assert.assertTrue("raml: " + c.getLastReport().toString(), c.getLastReport().isEmpty());
locationSampleDeployment = null;
// and delete from the proxy
c = api.createRestAssured3();
c.given().delete(locationSampleModule).then().statusCode(204);
Assert.assertTrue("raml: " + c.getLastReport().toString(), c.getLastReport().isEmpty());
checkDbIsEmpty("testDeployment done", context);
async.complete();
}
use of guru.nidi.ramltester.restassured3.RestAssuredClient in project okapi by folio-org.
the class ModuleTest method testManyModules.
@Test
public void testManyModules(TestContext context) {
async = context.async();
RestAssuredClient c;
Response r;
int i;
for (i = 0; i < 10; i++) {
String docSampleModule = "{" + LS + " \"id\" : \"sample-1.2." + Integer.toString(i) + "\"," + LS + " \"name\" : \"sample module " + Integer.toString(i) + "\"," + LS + " \"requires\" : [ ]" + LS + "}";
c = api.createRestAssured3();
c.given().header("Content-Type", "application/json").body(docSampleModule).post("/_/proxy/modules").then().statusCode(201).log().ifValidationFails();
Assert.assertTrue("raml: " + c.getLastReport().toString(), c.getLastReport().isEmpty());
}
c = api.createRestAssured3();
r = c.given().get("/_/proxy/modules").then().statusCode(200).log().ifValidationFails().extract().response();
Assert.assertTrue(c.getLastReport().isEmpty());
async.complete();
}
use of guru.nidi.ramltester.restassured3.RestAssuredClient in project okapi by folio-org.
the class ModuleTest method testInternalModule2.
private void testInternalModule2() {
logger.info("testInternalModule 3");
undeployFirst(x -> {
conf.put("okapiVersion", "3.0.0");
DeploymentOptions opt = new DeploymentOptions().setConfig(conf);
vertx.deployVerticle(MainVerticle.class.getName(), opt, res -> {
logger.info("testInternalModule 4");
RestAssuredClient c;
c = api.createRestAssured3();
c.given().get("/_/proxy/tenants").then().statusCode(200).log().ifValidationFails().body(equalTo(superTenantDoc));
Assert.assertTrue(c.getLastReport().isEmpty());
conf.remove("okapiVersion");
async.complete();
});
});
}
use of guru.nidi.ramltester.restassured3.RestAssuredClient in project okapi by folio-org.
the class MainDeployTest method testClusterMode.
@Test
public void testClusterMode(TestContext context) {
async = context.async();
String[] args = { "cluster" };
MainDeploy d = new MainDeploy();
d.init(args, res -> {
vertx = res.succeeded() ? res.result() : null;
Assert.assertTrue("main1 " + res.cause(), res.succeeded());
RestAssuredClient c;
Response r;
c = api.createRestAssured3();
r = c.given().get("/_/proxy/modules").then().statusCode(200).log().ifValidationFails().extract().response();
Assert.assertTrue("raml: " + c.getLastReport().toString(), c.getLastReport().isEmpty());
async.complete();
});
}
use of guru.nidi.ramltester.restassured3.RestAssuredClient in project okapi by folio-org.
the class MainDeployTest method testDevMode.
@Test
public void testDevMode(TestContext context) {
async = context.async();
String[] args = { "dev" };
MainDeploy d = new MainDeploy();
d.init(args, res -> {
vertx = res.succeeded() ? res.result() : null;
Assert.assertTrue("main1 " + res.cause(), res.succeeded());
RestAssuredClient c;
Response r;
c = api.createRestAssured3();
r = c.given().get("/_/version").then().statusCode(200).log().ifValidationFails().extract().response();
Assert.assertTrue("raml: " + c.getLastReport().toString(), c.getLastReport().isEmpty());
async.complete();
});
}
Aggregations