use of org.folio.rest.client.AdminClient in project raml-module-builder by folio-org.
the class DemoRamlRestTest method checkClientCode.
/**
* @param context
*/
private void checkClientCode(TestContext context) {
Async async = context.async(1);
log.info("checkClientCode test");
try {
MimeMultipart mmp = new MimeMultipart();
BodyPart bp = new MimeBodyPart(new InternetHeaders(), IOUtils.toByteArray(getClass().getClassLoader().getResourceAsStream("job.json")));
bp.setDisposition("form-data");
bp.setFileName("abc.raml");
BodyPart bp2 = new MimeBodyPart(new InternetHeaders(), IOUtils.toByteArray(getClass().getClassLoader().getResourceAsStream("job.json")));
bp2.setDisposition("form-data");
bp2.setFileName("abcd.raml");
log.debug("--- bp content --- " + bp.getContent());
mmp.addBodyPart(bp);
mmp.addBodyPart(bp2);
AdminClient aClient = new AdminClient("localhost", port, "abc", "abc", false);
aClient.postUploadmultipart(PersistMethod.SAVE, null, "abc", mmp, reply -> {
if (reply.statusCode() != 200) {
context.fail();
}
log.debug("checkClientCode statusCode 1 " + reply.statusCode());
String key;
try {
SecretKey sk = AES.generateSecretKey();
key = AES.convertSecretKeyToString(sk);
final String expected = AES.encryptPasswordAsBase64("abc", sk);
aClient.postGetPassword(key, reply2 -> {
reply2.bodyHandler(bodyHandler -> {
if (!expected.equals(bodyHandler.toString())) {
context.fail("expected : " + expected + " got " + bodyHandler.toString());
} else {
log.info("received expected password: " + expected);
aClient.getModuleStats(r -> {
r.bodyHandler(br -> {
log.info("received: " + br.toString());
});
async.countDown();
});
}
});
});
} catch (Exception e) {
log.error(e.getMessage(), e);
}
});
} catch (Exception e) {
log.error(e.getMessage(), e);
context.fail();
}
}
use of org.folio.rest.client.AdminClient 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"));
});
});
}
Aggregations