use of org.glassfish.api.ActionReport.MessagePart in project Payara by payara.
the class ListJdbcResourcesTest method testExecuteSuccessListBob.
/**
* Test of execute method, of class ListJdbcResource.
* create-jdbc-resource --connectionpoolid DerbyPool bob
* list-jdbc-resources
*/
@Test
public void testExecuteSuccessListBob() {
// Create JDBC Resource bob
assertTrue(resources != null);
// Get an instance of the CreateJdbcResource command
createCommand = habitat.getService(CreateJdbcResource.class);
assertTrue(createCommand != null);
parameters.add("connectionpoolid", "DerbyPool");
parameters.add("DEFAULT", "bob");
context = new AdminCommandContextImpl(LogDomains.getLogger(ListJdbcResourcesTest.class, LogDomains.ADMIN_LOGGER), new PropsFileActionReporter());
cr.getCommandInvocation("create-jdbc-resource", context.getActionReport(), adminSubject()).parameters(parameters).execute(createCommand);
assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
// List JDBC Resources and check if bob is in the list
// Get an instance of the ListJdbcResources command
listCommand = habitat.getService(ListJdbcResources.class);
parameters = new ParameterMap();
context = new AdminCommandContextImpl(LogDomains.getLogger(ListJdbcResourcesTest.class, LogDomains.ADMIN_LOGGER), new PropsFileActionReporter());
// Call CommandRunnerImpl.doCommand(..) to execute the command
cr.getCommandInvocation("list-jdbc-resources", context.getActionReport(), adminSubject()).parameters(parameters).execute(listCommand);
List<MessagePart> list = context.getActionReport().getTopMessagePart().getChildren();
assertEquals(origNum + 1, list.size());
List<String> listStr = new java.util.ArrayList();
for (MessagePart mp : list) {
listStr.add(mp.getMessage());
}
assertTrue(listStr.contains("bob"));
// Check the exit code is SUCCESS
assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
}
use of org.glassfish.api.ActionReport.MessagePart in project Payara by payara.
the class ListJavaMailResourcesTest method testExecuteSuccessListMailResource.
/**
* Test of execute method, of class ListJavaMailResource.
* create-javamail-resource --mailuser=test --mailhost=localhost
* --fromaddress=test@sun.com mailresource
* list-javamail-resources
*/
@Test
public void testExecuteSuccessListMailResource() {
createJavaMailResource();
parameters = new ParameterMap();
org.glassfish.resources.javamail.admin.cli.ListJavaMailResources listCommand = habitat.getService(org.glassfish.resources.javamail.admin.cli.ListJavaMailResources.class);
assertTrue(listCommand != null);
cr.getCommandInvocation("list-javamail-resources", context.getActionReport(), adminSubject()).parameters(parameters).execute(listCommand);
List<MessagePart> list = context.getActionReport().getTopMessagePart().getChildren();
assertEquals(origNum + 1, list.size());
List<String> listStr = new ArrayList<String>();
for (MessagePart mp : list) {
listStr.add(mp.getMessage());
}
assertTrue(listStr.contains("mailresource"));
assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
deleteJavaMailResource();
}
use of org.glassfish.api.ActionReport.MessagePart in project Payara by payara.
the class ListIiopListenersTest method testExecuteSuccessListListener.
/**
* Test of execute method, of class ListIiopListeners.
* asadmin create-iiop-listener --listeneraddress localhost
* --iiopport 4440 listener
* list-iiop-listeners
* delete-iiop-listener listener
*/
@Test
public void testExecuteSuccessListListener() {
parameters.set("listeneraddress", "localhost");
parameters.set("iiopport", "4440");
parameters.set("listener_id", "listener");
CreateIiopListener createCommand = services.getService(CreateIiopListener.class);
cr.getCommandInvocation("create-iiop-listener", context.getActionReport(), adminSubject()).parameters(parameters).execute(createCommand);
CreateIiopListenerTest.checkActionReport(context.getActionReport());
parameters = new ParameterMap();
ListIiopListeners listCommand = services.getService(ListIiopListeners.class);
cr.getCommandInvocation("list-iiop-listeners", context.getActionReport(), adminSubject()).parameters(parameters).execute(listCommand);
List<MessagePart> list = context.getActionReport().getTopMessagePart().getChildren();
assertEquals(origNum + 1, list.size());
List<String> listStr = new ArrayList<String>();
for (MessagePart mp : list) {
listStr.add(mp.getMessage());
}
assertTrue(listStr.contains("listener"));
CreateIiopListenerTest.checkActionReport(context.getActionReport());
parameters = new ParameterMap();
parameters.set("listener_id", "listener");
DeleteIiopListener deleteCommand = services.getService(DeleteIiopListener.class);
cr.getCommandInvocation("delete-iiop-listener", context.getActionReport(), adminSubject()).parameters(parameters).execute(deleteCommand);
CreateIiopListenerTest.checkActionReport(context.getActionReport());
}
use of org.glassfish.api.ActionReport.MessagePart in project Payara by payara.
the class SetRestMonitoringConfigurationCommand method defaultRestMonitoringUserExists.
private boolean defaultRestMonitoringUserExists(ActionReport subActionReport, Subject subject) {
boolean exists = false;
CommandInvocation invocation = commandRunner.getCommandInvocation("list-file-users", subActionReport, subject, false);
ParameterMap parameters = new ParameterMap();
parameters.add("authrealmname", "file");
invocation.parameters(parameters).execute();
for (MessagePart message : subActionReport.getTopMessagePart().getChildren()) {
if (message.getMessage().equals(DEFAULT_USER_NAME)) {
exists = true;
break;
}
}
return exists;
}
use of org.glassfish.api.ActionReport.MessagePart in project Payara by payara.
the class Util method getCurrentValues.
public static Map<String, String> getCurrentValues(String basePath, ServiceLocator habitat, Subject subject) {
Map<String, String> values = new HashMap<String, String>();
final String path = (basePath.endsWith(".")) ? basePath.substring(0, basePath.length() - 1) : basePath;
RestActionReporter gr = ResourceUtil.runCommand("get", new ParameterMap() {
{
add("DEFAULT", path);
}
}, subject);
MessagePart top = gr.getTopMessagePart();
for (MessagePart child : top.getChildren()) {
String message = child.getMessage();
if (message.contains("=")) {
String[] parts = message.split("=");
values.put(parts[0], (parts.length > 1) ? parts[1] : "");
}
}
return values;
}
Aggregations