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) {
}
}
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();
}
}
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);
}
}
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);
}
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());
}
Aggregations