Search in sources :

Example 61 with CommandResult

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

the class AutoNameInstancesTest method testInstanceNameConflict.

@Test
public void testInstanceNameConflict() {
    String domainName = ServerOperations.getDomainName();
    String conflictInstanceName = "Scrumptious-Swordfish";
    // Create expected conflict if it doesn't already exist.
    CommandResult result = asadmin("list-instances", "-t", "--nostatus");
    if (!result.getOutput().contains(conflictInstanceName)) {
        asadmin("create-instance", "--node", "localhost-" + domainName, conflictInstanceName);
    }
    result = asadmin("create-instance", "--autoname", "true", "--node", "localhost-" + domainName, "-T", conflictInstanceName);
    try {
        assertSuccess(result);
    } finally {
        // Cleanup
        String generatedInstanceName = result.getOutput();
        asadmin("delete-instance", conflictInstanceName);
        asadmin("delete-instance", generatedInstanceName);
    }
}
Also used : CommandResult(org.glassfish.embeddable.CommandResult) Test(org.junit.Test)

Example 62 with CommandResult

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

the class RegisterLoginModuleTest method successfulRegistrationUpdatesLoginConf.

@Test
public void successfulRegistrationUpdatesLoginConf() throws IOException {
    asadmin("delete-auth-realm", "test1");
    CommandResult result = asadmin("create-auth-realm", "--classname", "com.sun.enterprise.security.auth.realm.file.FileRealm", "--login-module", "com.sun.enterprise.security.auth.login.FileLoginModule", "--property", "jaas-context=test1:file=test1", "test1");
    System.out.println(result.getOutput());
    assertSuccess(result);
    String contents = loginConf();
    assertContains("test1 {", contents);
    result = asadmin("delete-auth-realm", "test1");
    System.out.println(result.getOutput());
    assertSuccess(result);
    // Removes JAAS context test1 from the login.conf file on the domain
    // It's expected that this will be the last entry in the login.conf file
    // and so we just grab everything up to this final entry as the new file
    // contents
    String newFileContents = contents.substring(0, contents.indexOf("test1"));
    System.out.print(newFileContents);
    try (BufferedWriter writer = new BufferedWriter(new FileWriter(System.getProperty("java.security.auth.login.config")))) {
        writer.write(newFileContents);
    } catch (IOException e) {
        System.out.print(e.getMessage());
        e.printStackTrace();
    }
    assertFalse(loginConf().contains("test1 {"));
}
Also used : FileWriter(java.io.FileWriter) IOException(java.io.IOException) CommandResult(org.glassfish.embeddable.CommandResult) BufferedWriter(java.io.BufferedWriter) Test(org.junit.Test)

Example 63 with CommandResult

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

the class RegisterLoginModuleTest method undefinedJaasContextGivesWarning.

@Test
public void undefinedJaasContextGivesWarning() {
    asadmin("delete-auth-realm", "test3");
    CommandResult result = asadmin("create-auth-realm", "--classname", "com.sun.enterprise.security.auth.realm.certificate.CertificateRealm", "--login-module", "com.sun.enterprise.security.auth.login.FileLoginModule", "--property", "file=test3", "test3");
    System.out.println(result.getOutput());
    assertEquals(CommandResult.ExitStatus.WARNING, result.getExitStatus());
    assertContains("No JAAS context is defined", result.getOutput());
    result = asadmin("delete-auth-realm", "test3");
    System.out.println(result.getOutput());
    assertSuccess(result);
}
Also used : CommandResult(org.glassfish.embeddable.CommandResult) Test(org.junit.Test)

Example 64 with CommandResult

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

the class RegisterLoginModuleTest method existingJaasContextGivesWarning.

@Test
public void existingJaasContextGivesWarning() {
    asadmin("delete-auth-realm", "test2");
    CommandResult result = asadmin("create-auth-realm", "--classname", "com.sun.enterprise.security.auth.realm.file.FileRealm", "--login-module", "com.sun.enterprise.security.auth.login.FileLoginModule", "--property", "jaas-context=fileRealm:file=test2", "test2");
    System.out.println(result.getOutput());
    assertEquals(CommandResult.ExitStatus.WARNING, result.getExitStatus());
    assertContains("fileRealm is already configured", result.getOutput());
    result = asadmin("delete-auth-realm", "test2");
    System.out.println(result.getOutput());
    assertSuccess(result);
}
Also used : CommandResult(org.glassfish.embeddable.CommandResult) Test(org.junit.Test)

Example 65 with CommandResult

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

the class SetHealthCheckConfigurationTest method historicalTraceStoreTimeoutAffectsConfigButNotService.

@Test
public void historicalTraceStoreTimeoutAffectsConfigButNotService() {
    Long historicalTraceStoreTimeout = getHistoricalTraceStoreTimeout();
    CommandResult result = asadmin("set-healthcheck-configuration", "--enabled", "true", "--historical-trace-store-timeout", "42");
    assertSuccess(result);
    assertEquals(42, Integer.parseInt(config.getHistoricalTraceStoreTimeout()));
    assertEquals(historicalTraceStoreTimeout, getHistoricalTraceStoreTimeout());
}
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