Search in sources :

Example 1 with PayaraMicroBoot

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();
}
Also used : ClusterCommandResult(fish.payara.micro.ClusterCommandResult) PayaraMicroBoot(fish.payara.micro.boot.PayaraMicroBoot) Test(org.junit.Test)

Aggregations

ClusterCommandResult (fish.payara.micro.ClusterCommandResult)1 PayaraMicroBoot (fish.payara.micro.boot.PayaraMicroBoot)1 Test (org.junit.Test)1