@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(); } }
@Override public void configure(Properties props) throws GlassFishException { CommandRunner commandRunner = null; for (Object obj : props.keySet()) { String key = (String) obj; if (key.startsWith(CONFIG_PROP_PREFIX)) { if (commandRunner == null) { // only create the CommandRunner if needed commandRunner = habitat.getService(CommandRunner.class); } CommandResult result = commandRunner.run("set", key.substring(CONFIG_PROP_PREFIX.length()) + "=" + props.getProperty(key)); if (result.getExitStatus() != CommandResult.ExitStatus.SUCCESS) { throw new GlassFishException(result.getOutput()); } } } } }
@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 configure(Properties props) throws GlassFishException { CommandRunner commandRunner = null; for (Object obj : props.keySet()) { String key = (String) obj; if (key.startsWith(CONFIG_PROP_PREFIX)) { if (commandRunner == null) { // only create the CommandRunner if needed commandRunner = habitat.getService(CommandRunner.class); } CommandResult result = commandRunner.run("set", key.substring(CONFIG_PROP_PREFIX.length()) + "=" + props.getProperty(key)); if (result.getExitStatus() != CommandResult.ExitStatus.SUCCESS) { throw new GlassFishException(result.getOutput()); } } } } }
@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)); }
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; }
String[] tokens = command.split("\\s"); CommandResult result = cmdRunner.run(tokens[0], Arrays.copyOfRange(tokens, 1, tokens.length)); System.out.println(result.getExitStatus()); System.out.println(result.getOutput()); if (result.getFailureCause() != null) {
String[] tokens = command.split("\\s"); CommandResult result = cmdRunner.run(tokens[0], Arrays.copyOfRange(tokens, 1, tokens.length)); System.out.println(result.getExitStatus()); System.out.println(result.getOutput()); if (result.getFailureCause() != null) {
Object args[]=new Object[]{virtualClusterName,result.getOutput()}; logger.log(Level.INFO,"create.cluster.exec.output",args); if (result.getExitStatus().equals(CommandResult.ExitStatus.FAILURE)) { throw new RuntimeException("Failure while provisioning services, " + "Unable to create cluster [" + virtualClusterName + "]");
logger.log(Level.FINEST,localStrings.getString("delete.cluster.exec.output",args)); if (result.getExitStatus().equals(CommandResult.ExitStatus.FAILURE)) { throw new RuntimeException("Failure while deleting virtual-cluster, " + "Unable to delete virtual-cluster [" + virtualClusterName + "]");