@Resource(mappedName = "org.glassfish.embeddable.CommandRunner") CommandRunner commandRunner; public void configureLoginRealm() { CommandResult commandResult = commandRunner.run("create-auth-realm", "--classname=com.blah.blah.SecureJDBCRealm", "--property=jaas-context= secureJDBCRealm", "secure-JDBC-realm"); log.debug(commandResult.getExitStatus().toString() + " " + commandResult.getOutput()); Throwable throwable = commandResult.getFailureCause(); if (throwable != null) { log.error(throwable.getMessage(), throwable); } }
@Override public void execute(final TestContext ctx) throws Exception { log.info("delete auth realm"); CommandResult result = ctx.runCommand("delete-auth-realm", realmName); log.info("result={}", result.getExitStatus()); if (ExitStatus.FAILURE.equals(result.getExitStatus())) { log.error("command failed", result.getFailureCause()); fail(); } }
private String executeCommand(String command, String... parameterList) throws Throwable { CommandRunner runner = glassfish.getCommandRunner(); CommandResult result = runner.run(command, parameterList); String output = null; switch (result.getExitStatus()) { case FAILURE: case WARNING: throw result.getFailureCause(); case SUCCESS: output = result.getOutput(); log.info("command " + command + " parameters" + parameterList + " result: " + output); break; } return output; }
public void removeVirtualCluster(String virtualClusterName) { try { VirtualCluster virtualCluster = virtualClusters.byName(virtualClusterName); if (virtualCluster != null) { virtualClusters.remove(virtualCluster); // removes config. } } catch (Exception ex) { logger.log(Level.WARNING,localStrings.getString("exception.while.remove.cluster",ex.getLocalizedMessage()),ex); } /* stop-cluster is deliberately commented. invoking stop-cluster causes the re-deploy to fail next time (due to IMS layer fails to create virtual-machine config). But since all the instances in the cluster are already stopped we don't really need to call stop-cluster. CommandResult commandResult = commandRunner.run("stop-cluster", virtualClusterName); Throwable failureCause = commandResult.getFailureCause(); if (failureCause != null) { logger.log(Level.WARNING, failureCause.getLocalizedMessage(), failureCause); } */ CommandResult commandResult = commandRunner.run("delete-cluster", virtualClusterName); Object args[]=new Object[]{virtualClusterName,commandResult.getOutput()}; logger.log(Level.INFO,"delete.cluster.exec.output",args); Throwable failureCause = commandResult.getFailureCause(); if (failureCause != null) { args[0]= failureCause.getLocalizedMessage(); args[1]=failureCause; logger.log(Level.WARNING,localStrings.getString("failure.cause",args[0]),args[1]); } }
@Override public void execute(final TestContext ctx) throws Exception { log.info("Create auth realm"); CommandResult result = ctx .runCommand( "create-auth-realm", "--classname", realmClass.getName(), "--property", "jaas-context=" + jaasContext + ":datasource-jndi=jdbc/__default:user-table=users:group-table=groups:user-name-column=username:password-column=password:group-name-column=groupname", realmName); log.info("result={}", result.getExitStatus()); if (ExitStatus.FAILURE.equals(result.getExitStatus())) { log.error("command failed", result.getFailureCause()); fail(); } ctx.addTeardownCommand(new JDBCAuthRealmDelete(realmName)); }
System.out.println(result.getExitStatus()); System.out.println(result.getOutput()); if (result.getFailureCause() != null) { result.getFailureCause().printStackTrace();
System.out.println(result.getExitStatus()); System.out.println(result.getOutput()); if (result.getFailureCause() != null) { result.getFailureCause().printStackTrace();