Search in sources :

Example 31 with Deployer

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

the class BasicPaaSServiceMetadataTest method runTests.

private void runTests(GlassFish glassfish) throws Exception {
    // 2. Deploy the PaaS application.
    File archive = new File(System.getProperty("basedir") + // TODO :: use mvn apis to
    "/target/basic_paas_sample2.war");
    // get the archive
    // location.
    Assert.assertTrue(archive.exists());
    Deployer deployer = glassfish.getDeployer();
    String appName = deployer.deploy(archive);
    System.err.println("Deployed [" + appName + "]");
    Assert.assertNotNull(appName);
    CommandRunner commandRunner = glassfish.getCommandRunner();
    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 + "/basic_paas_sample2/BasicPaaSServlet", "Request headers from the request:");
    // 4. Undeploy the PaaS application . TODO :: use cloud-undeploy??
    deployer.undeploy(appName);
    System.err.println("Undeployed [" + appName + "]");
    try {
        boolean undeployClean = false;
        CommandResult commandResult = glassfish.getCommandRunner().run("list-services");
        if (commandResult.getOutput().contains("Nothing to list.")) {
            undeployClean = true;
        }
        Assert.assertTrue(undeployClean);
    } catch (Exception e) {
        System.err.println("Couldn't varify whether undeploy succeeded");
    }
}
Also used : File(java.io.File) CommandRunner(org.glassfish.embeddable.CommandRunner) Deployer(org.glassfish.embeddable.Deployer) CommandResult(org.glassfish.embeddable.CommandResult)

Example 32 with Deployer

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

the class Util method undeploy.

public static void undeploy(String appName, String serverId) throws Exception {
    GlassFish glassfish = gfMap.get(serverId);
    if (glassfish == null) {
        throw new Exception("Embedded GlassFish [" + serverId + "] not running");
    }
    if (appName == null) {
        throw new Exception("Application name can not be null");
    }
    Deployer deployer = glassfish.getDeployer();
    deployer.undeploy(appName);
    System.out.println("Undeployed [" + appName + "]");
}
Also used : GlassFish(org.glassfish.embeddable.GlassFish) GlassFishException(org.glassfish.embeddable.GlassFishException) Deployer(org.glassfish.embeddable.Deployer)

Example 33 with Deployer

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

the class Util method deploy.

public static void deploy(String app, String serverId, List<String> deployParams) throws Exception {
    GlassFish glassfish = gfMap.get(serverId);
    if (glassfish == null) {
        throw new Exception("Embedded GlassFish [" + serverId + "] not running");
    }
    if (app == null) {
        throw new Exception("Application can not be null");
    }
    Deployer deployer = glassfish.getDeployer();
    final int len = deployParams.size();
    if (len > 0) {
        deployer.deploy(new File(app).toURI(), deployParams.toArray(new String[len]));
        System.out.println("Deployed [" + app + "] with parameters " + deployParams);
    } else {
        deployer.deploy(new File(app).toURI());
        System.out.println("Deployed [" + app + "]");
    }
}
Also used : GlassFish(org.glassfish.embeddable.GlassFish) File(java.io.File) GlassFishException(org.glassfish.embeddable.GlassFishException) Deployer(org.glassfish.embeddable.Deployer)

Aggregations

Deployer (org.glassfish.embeddable.Deployer)33 File (java.io.File)32 GlassFish (org.glassfish.embeddable.GlassFish)24 Test (org.junit.Test)24 CommandRunner (org.glassfish.embeddable.CommandRunner)22 CommandResult (org.glassfish.embeddable.CommandResult)21 GlassFishProperties (org.glassfish.embeddable.GlassFishProperties)21 PrintStream (java.io.PrintStream)16 JarFile (java.util.jar.JarFile)13 URI (java.net.URI)6 IOException (java.io.IOException)4 InitialContext (javax.naming.InitialContext)4 GlassFishException (org.glassfish.embeddable.GlassFishException)4 URL (java.net.URL)3 ScatteredArchive (org.glassfish.embeddable.archive.ScatteredArchive)3 HttpListener (org.glassfish.embeddable.web.HttpListener)3 WebContainer (org.glassfish.embeddable.web.WebContainer)3 NamingException (javax.naming.NamingException)2 SampleEjb (org.glassfish.distributions.test.ejb.SampleEjb)2 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)2