use of fish.payara.micro.boot.PayaraMicroBoot in project Payara by payara.
the class PayaraMicroCommandsTest method bootCommandtest.
@Test
public void bootCommandtest() throws Exception {
PayaraMicroBoot microBoot = PayaraMicroLauncher.getBootClass();
microBoot.setNoCluster(true);
microBoot.setPreBootHandler((t) -> {
ClusterCommandResult result = t.run("set", "configs.config.server-config.health-check-service-configuration.enabled=true");
Assert.assertEquals(ClusterCommandResult.ExitStatus.SUCCESS, result.getExitStatus());
Assert.assertNull(result.getFailureCause());
System.out.println(result.getOutput());
});
microBoot.setPostBootHandler((t) -> {
ClusterCommandResult result = t.run("get-healthcheck-configuration");
Assert.assertEquals(ClusterCommandResult.ExitStatus.SUCCESS, result.getExitStatus());
Assert.assertNull(result.getFailureCause());
Assert.assertTrue(result.getOutput().contains("Health Check Service Configuration is enabled?: true"));
});
System.out.println("Starting Payara Micro");
microBoot.setHttpAutoBind(true);
microBoot.bootStrap();
try {
microBoot.setPreBootHandler((t) -> {
t.run("set-healthcheck-configuration", "--enabled", "false");
});
Assert.fail("Should not be able to add preboot comand postboot");
} catch (IllegalStateException ex) {
// Expected
}
try {
microBoot.setPostBootHandler((t) -> {
t.run("set-healthcheck-configuration", "--enabled", "false");
});
Assert.fail("Should not be able to add preboot comand postboot");
} catch (IllegalStateException ex) {
// Expected
}
System.out.println("Shutting down Payara Micro");
microBoot.shutdown();
}
Aggregations