Search in sources :

Example 41 with CommandResult

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

the class SetHealthCheckNotifierConfigurationTest method incorrectNotifierNamesAreNotAccepted.

@Test
public void incorrectNotifierNamesAreNotAccepted() {
    CommandResult result = asadmin("set-healthcheck-configuration", "--enableNotifiers", "log-notifier,bad-notifier", "--enabled", "true");
    assertFailure(result);
}
Also used : CommandResult(org.glassfish.embeddable.CommandResult) Test(org.junit.Test)

Example 42 with CommandResult

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

the class EmbeddedTest method commandTest.

@Test
public void commandTest() throws GlassFishException {
    CommandRunner commandRunner = glassfish.getCommandRunner();
    CommandResult commandResult = commandRunner.run("list-modules");
    System.out.println("list-modules command result :\n" + commandResult.getOutput());
// Unknown commands throw NPE, uncomment once the issue is fixed.
// commandResult = commandRunner.run("list-contracts");
// System.out.println("list-contracts command result :\n" + commandResult.getOutput());
}
Also used : CommandRunner(org.glassfish.embeddable.CommandRunner) CommandResult(org.glassfish.embeddable.CommandResult) Test(org.junit.Test)

Example 43 with CommandResult

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

the class AsAdminCommandTestCase method shouldBeAbleToIssueAsAdminCommand.

@Test
public void shouldBeAbleToIssueAsAdminCommand() throws Exception {
    assertNotNull("Verify that the asadmin CommandRunner resource is available", commandRunner);
    CommandResult result = commandRunner.run("create-jdbc-connection-pool", "--datasourceclassname=org.apache.derby.jdbc.EmbeddedXADataSource", "--restype=javax.sql.XADataSource", "--property=portNumber=1527:password=APP:user=APP" + ":serverName=localhost:databaseName=my_database" + ":connectionAttributes=create\\=true", "my_derby_pool");
    assertEquals("Verify 'create-jdbc-connection-pool' asadmin command", SUCCESS, result.getExitStatus());
    result = commandRunner.run("create-jdbc-resource", "--connectionpoolid", "my_derby_pool", "jdbc/my_database");
    assertEquals("Verify 'create-jdbc-resource' asadmin command", SUCCESS, result.getExitStatus());
    result = commandRunner.run("ping-connection-pool", "my_derby_pool");
    assertEquals("Verify asadmin command 'ping-connection-pool'", SUCCESS, result.getExitStatus());
    assertNotNull(new InitialContext().lookup("jdbc/my_database"));
}
Also used : InitialContext(javax.naming.InitialContext) CommandResult(org.glassfish.embeddable.CommandResult) Test(org.junit.Test)

Example 44 with CommandResult

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

the class BootCommand method execute.

public boolean execute(CommandRunner runner) {
    boolean result = true;
    CommandResult asadminResult = runner.run(command, arguments);
    if (asadminResult.getExitStatus().equals(ExitStatus.FAILURE)) {
        Logger.getLogger(BootCommand.class).log(Level.WARNING, "Boot Command " + command + " failed " + asadminResult.getOutput());
        result = false;
    }
    return result;
}
Also used : CommandResult(org.glassfish.embeddable.CommandResult)

Example 45 with CommandResult

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

the class CoffeeTest method test.

@Test
public void test() throws Exception {
    // 1. Bootstrap GlassFish DAS in embedded mode.
    GlassFishProperties glassFishProperties = new GlassFishProperties();
    glassFishProperties.setInstanceRoot(System.getenv("S1AS_HOME") + "/domains/domain1");
    glassFishProperties.setConfigFileReadOnly(false);
    GlassFish glassfish = GlassFishRuntime.bootstrap().newGlassFish(glassFishProperties);
    PrintStream sysout = System.out;
    glassfish.start();
    System.setOut(sysout);
    // 2. Deploy the PaaS application.
    File archive = new File(System.getProperty("basedir") + "/target/appscoped_db_with_resources_xml.war");
    // TODO :: use mvn apis to get the archive location.
    Assert.assertTrue(archive.exists());
    Deployer deployer = null;
    String appName = null;
    CommandRunner commandRunner = glassfish.getCommandRunner();
    try {
        deployer = glassfish.getDeployer();
        appName = deployer.deploy(archive);
        System.err.println("Deployed [" + appName + "]");
        Assert.assertNotNull(appName);
        CommandResult result = commandRunner.run("list-services");
        System.out.println("\nlist-services command output [ " + result.getOutput() + "]");
        // 3. Access the app to make sure PaaS app is correctly provisioned.
        String HTTP_PORT = (System.getProperty("http.port") != null) ? System.getProperty("http.port") : "28080";
        String instanceIP = getLBIPAddress(glassfish);
        get("http://" + instanceIP + ":" + HTTP_PORT + "/appscoped_db_with_resources_xml/CoffeeServlet", "Coffee ID");
    // 4. Undeploy the PaaS application .
    } finally {
        if (appName != null) {
            deployer.undeploy(appName);
            System.err.println("Undeployed [" + appName + "]");
            System.out.println("Destroying the resources created");
        }
    }
}
Also used : PrintStream(java.io.PrintStream) GlassFish(org.glassfish.embeddable.GlassFish) JarFile(java.util.jar.JarFile) File(java.io.File) CommandRunner(org.glassfish.embeddable.CommandRunner) GlassFishProperties(org.glassfish.embeddable.GlassFishProperties) Deployer(org.glassfish.embeddable.Deployer) 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