Search in sources :

Example 11 with CommandResult

use of org.glassfish.embeddable.CommandResult in project Payara by payara.

the class UberMain method run.

public void run() throws Exception {
    // handle Ctrt-C.
    addShutdownHook();
    GlassFishProperties gfProps = new GlassFishProperties();
    gfProps.setProperty("org.glassfish.embeddable.autoDelete", System.getProperty("org.glassfish.embeddable.autoDelete", "true"));
    gf = GlassFishRuntime.bootstrap().newGlassFish(gfProps);
    gf.start();
    CommandRunner cr = gf.getCommandRunner();
    while (true) {
        System.out.print("\n\nGlassFish $ ");
        String str = null;
        try {
            str = new BufferedReader(new InputStreamReader(System.in)).readLine();
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (str != null && str.trim().length() != 0) {
            if ("exit".equalsIgnoreCase(str) || "quit".equalsIgnoreCase(str)) {
                break;
            }
            String[] split = str.split(" ");
            String command = split[0].trim();
            String[] commandParams = null;
            if (split.length > 1) {
                commandParams = new String[split.length - 1];
                for (int i = 1; i < split.length; i++) {
                    commandParams[i - 1] = split[i].trim();
                }
            }
            try {
                CommandResult result = commandParams == null ? cr.run(command) : cr.run(command, commandParams);
                System.out.println("\n" + result.getOutput());
            } catch (Exception ex) {
                System.out.println(ex.getMessage());
            }
        }
    }
    try {
        gf.stop();
        gf.dispose();
    } catch (Exception ex) {
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) CommandRunner(org.glassfish.embeddable.CommandRunner) GlassFishProperties(org.glassfish.embeddable.GlassFishProperties) CommandResult(org.glassfish.embeddable.CommandResult)

Example 12 with CommandResult

use of org.glassfish.embeddable.CommandResult in project Payara by payara.

the class CreateJavaMailResourceTest method testJavaMailDeploymentGroupRef.

@Test
public void testJavaMailDeploymentGroupRef() {
    try {
        deleteOldResources();
        CommandResult result = asadmin("create-deployment-group", "create-javamail-resource-test-dg");
        assertSuccess(result);
        result = asadmin("create-javamail-resource", "--debug=false", "--storeProtocol=imap", "--auth=false", "--transportProtocol=smtp", "--host=localhost", "--storeProtocolClass=com.sun.mail.imap.IMAPStore", "--from=ratatosk@payara.fish", "--transportProtocolClass=com.sun.mail.smtp.SMTPTransport", "--enabled=true", "--target=domain", "--mailhost=localhost", "--mailuser=ratatosk", "mail/create-javamail-resource-test");
        assertSuccess(result);
        result = asadmin("create-resource-ref", "--enabled=true", "--target=create-javamail-resource-test-dg", "mail/create-javamail-resource-test");
        assertSuccess(result);
    } finally {
        deleteOldResources();
    }
}
Also used : CommandResult(org.glassfish.embeddable.CommandResult) Test(org.junit.Test)

Example 13 with CommandResult

use of org.glassfish.embeddable.CommandResult in project Payara by payara.

the class AutoNameInstancesTest method testGenerateInstanceName.

@Test
public void testGenerateInstanceName() {
    String domainName = ServerOperations.getDomainName();
    CommandResult result = asadmin("create-instance", "-a", "--node", "localhost-" + domainName, "--extraTerse", "true");
    try {
        assertSuccess(result);
    } finally {
        // Cleanup
        String generatedInstanceName = result.getOutput();
        asadmin("delete-instance", generatedInstanceName);
    }
}
Also used : CommandResult(org.glassfish.embeddable.CommandResult) Test(org.junit.Test)

Example 14 with CommandResult

use of org.glassfish.embeddable.CommandResult in project Payara by payara.

the class ListHealthCheckServicesTest method listHealthCheckServices.

@Test
public void listHealthCheckServices() {
    CommandResult result = asadmin("list-healthcheck-services");
    assertSuccess(result);
    String description = result.getOutput();
    assertContains("Available Health Check Services:", description);
    assertContains("healthcheck-mp", description);
    assertContains("healthcheck-cpu", description);
    assertContains("healthcheck-gc", description);
    assertContains("healthcheck-heap", description);
    assertContains("healthcheck-threads", description);
    assertContains("healthcheck-machinemem", description);
    assertContains("healthcheck-cpool", description);
    assertContains("healthcheck-stuck", description);
}
Also used : CommandResult(org.glassfish.embeddable.CommandResult) Test(org.junit.Test)

Example 15 with CommandResult

use of org.glassfish.embeddable.CommandResult in project Payara by payara.

the class SetHealthCheckConfigurationTest method historicalTraceEnabledAffectsConfigButNotService.

@Test
public void historicalTraceEnabledAffectsConfigButNotService() {
    boolean historicalTraceEnabled = service.isHistoricalTraceEnabled();
    CommandResult result = asadmin("set-healthcheck-configuration", "--enabled", "true", "--historical-trace-enabled", "false");
    assertSuccess(result);
    assertUnchanged(historicalTraceEnabled, service.isHistoricalTraceEnabled());
    assertFalse(config.getHistoricalTraceEnabled());
    result = asadmin("set-healthcheck-configuration", "--enabled", "true", "--historical-trace-enabled", "true");
    assertSuccess(result);
    assertTrue(config.getHistoricalTraceEnabled());
    assertUnchanged(historicalTraceEnabled, service.isHistoricalTraceEnabled());
}
Also used : CommandResult(org.glassfish.embeddable.CommandResult) Test(org.junit.Test)

Aggregations

CommandResult (org.glassfish.embeddable.CommandResult)85 Test (org.junit.Test)72 CommandRunner (org.glassfish.embeddable.CommandRunner)26 File (java.io.File)21 Deployer (org.glassfish.embeddable.Deployer)21 GlassFish (org.glassfish.embeddable.GlassFish)17 GlassFishProperties (org.glassfish.embeddable.GlassFishProperties)17 PrintStream (java.io.PrintStream)16 GarbageCollectorChecker (fish.payara.nucleus.healthcheck.configuration.GarbageCollectorChecker)12 HoggingThreadsChecker (fish.payara.nucleus.healthcheck.configuration.HoggingThreadsChecker)10 StuckThreadsChecker (fish.payara.nucleus.healthcheck.configuration.StuckThreadsChecker)10 JarFile (java.util.jar.JarFile)9 Checker (fish.payara.nucleus.healthcheck.configuration.Checker)6 GarbageCollectorHealthCheck (fish.payara.nucleus.healthcheck.preliminary.GarbageCollectorHealthCheck)6 HoggingThreadsHealthCheck (fish.payara.nucleus.healthcheck.preliminary.HoggingThreadsHealthCheck)4 StuckThreadsHealthCheck (fish.payara.nucleus.healthcheck.stuck.StuckThreadsHealthCheck)4 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)2 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)2 ExecException (com.sun.enterprise.util.ExecException)1