Search in sources :

Example 1 with MessagePart

use of org.glassfish.api.ActionReport.MessagePart in project Payara by payara.

the class ListIiopListenersTest method testExecuteSuccessListNoListener.

/**
 * Test of execute method, of class ListIiopListener.
 * list-iiop-listeners
 */
@Test
public void testExecuteSuccessListNoListener() {
    parameters = new ParameterMap();
    ListIiopListeners listCommand = services.getService(ListIiopListeners.class);
    cr.getCommandInvocation("list-iiop-listeners", context.getActionReport(), adminSubject()).parameters(parameters).execute(listCommand);
    CreateIiopListenerTest.checkActionReport(context.getActionReport());
    List<MessagePart> list = context.getActionReport().getTopMessagePart().getChildren();
    assertEquals(origNum, list.size());
    List<String> listStr = new ArrayList<String>();
    for (MessagePart mp : list) {
        listStr.add(mp.getMessage());
    }
    assertFalse(listStr.contains("listener"));
}
Also used : MessagePart(org.glassfish.api.ActionReport.MessagePart) ArrayList(java.util.ArrayList) ParameterMap(org.glassfish.api.admin.ParameterMap) Test(org.junit.Test)

Example 2 with MessagePart

use of org.glassfish.api.ActionReport.MessagePart in project Payara by payara.

the class SetRestMonitoringConfigurationCommand method messageSecurityProviderExists.

private boolean messageSecurityProviderExists(ActionReport subActionReport, Subject subject) {
    boolean exists = false;
    CommandInvocation invocation = commandRunner.getCommandInvocation("list-message-security-providers", subActionReport, subject, false);
    ParameterMap parameters = new ParameterMap();
    parameters.add("layer", "HttpServlet");
    invocation.parameters(parameters).execute();
    for (MessagePart message : subActionReport.getTopMessagePart().getChildren()) {
        if (message.getMessage().equals(AUTH_MODULE_NAME)) {
            exists = true;
            break;
        }
    }
    return exists;
}
Also used : MessagePart(org.glassfish.api.ActionReport.MessagePart) ParameterMap(org.glassfish.api.admin.ParameterMap) CommandInvocation(org.glassfish.api.admin.CommandRunner.CommandInvocation)

Example 3 with MessagePart

use of org.glassfish.api.ActionReport.MessagePart in project Payara by payara.

the class ListJavaMailResourcesTest method testExecuteSuccessListNoMailResource.

/**
 * Test of execute method, of class ListJdbcResource.
 * delete-javamail-resource mailresource
 * list-javamail-resources
 */
@Test
public void testExecuteSuccessListNoMailResource() {
    createJavaMailResource();
    parameters = new ParameterMap();
    org.glassfish.resources.javamail.admin.cli.ListJavaMailResources listCommand = habitat.getService(org.glassfish.resources.javamail.admin.cli.ListJavaMailResources.class);
    cr.getCommandInvocation("list-javamail-resources", context.getActionReport(), adminSubject()).parameters(parameters).execute(listCommand);
    List<ActionReport.MessagePart> list = context.getActionReport().getTopMessagePart().getChildren();
    assertEquals(origNum + 1, list.size());
    // as we newly created a resource after test "setup".
    origNum = origNum + 1;
    deleteJavaMailResource();
    parameters = new ParameterMap();
    listCommand = habitat.getService(org.glassfish.resources.javamail.admin.cli.ListJavaMailResources.class);
    context = new AdminCommandContextImpl(LogDomains.getLogger(ListJavaMailResourcesTest.class, LogDomains.ADMIN_LOGGER), new PropsFileActionReporter());
    cr.getCommandInvocation("list-javamail-resources", context.getActionReport(), adminSubject()).parameters(parameters).execute(listCommand);
    list = context.getActionReport().getTopMessagePart().getChildren();
    if ((origNum - 1) == 0) {
    // Nothing to list.
    } else {
        assertEquals(origNum - 1, list.size());
    }
    List<String> listStr = new ArrayList<String>();
    for (MessagePart mp : list) {
        listStr.add(mp.getMessage());
    }
    assertFalse(listStr.contains("mailresource"));
    assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
}
Also used : MessagePart(org.glassfish.api.ActionReport.MessagePart) ArrayList(java.util.ArrayList) ParameterMap(org.glassfish.api.admin.ParameterMap) PropsFileActionReporter(com.sun.enterprise.v3.common.PropsFileActionReporter) AdminCommandContextImpl(org.glassfish.api.admin.AdminCommandContextImpl) Test(org.junit.Test) ConfigApiTest(org.glassfish.tests.utils.ConfigApiTest)

Example 4 with MessagePart

use of org.glassfish.api.ActionReport.MessagePart in project Payara by payara.

the class ListCustomResourcesTest method testExecuteSuccessListResource.

/**
 * Test of execute method, of class ListCustomResources.
 * create-custom-resource ---restype=topic --factoryclass=javax.naming.spi.ObjectFactory
 * Resource1
 * list-custom-resources
 */
@Test
public void testExecuteSuccessListResource() {
    createCustomResource();
    ParameterMap parameters = new ParameterMap();
    org.glassfish.resources.admin.cli.ListCustomResources listCommand = habitat.getService(org.glassfish.resources.admin.cli.ListCustomResources.class);
    cr.getCommandInvocation("list-custom-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<String>();
    for (MessagePart mp : list) {
        listStr.add(mp.getMessage());
    }
    assertTrue(listStr.contains("custom_resource1"));
    assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
    deleteCustomResource();
}
Also used : MessagePart(org.glassfish.api.ActionReport.MessagePart) ParameterMap(org.glassfish.api.admin.ParameterMap) Test(org.junit.Test) ConfigApiTest(org.glassfish.tests.utils.ConfigApiTest)

Example 5 with MessagePart

use of org.glassfish.api.ActionReport.MessagePart in project Payara by payara.

the class ListCustomResourcesTest method testExecuteSuccessListNoResource.

/**
 * Test of execute method, of class ListCustomResources.
 * delete-custom-resource Resource1
 * list-Custom-resources
 */
@Test
public void testExecuteSuccessListNoResource() {
    createCustomResource();
    org.glassfish.resources.admin.cli.ListCustomResources listCommand = habitat.getService(org.glassfish.resources.admin.cli.ListCustomResources.class);
    cr.getCommandInvocation("list-custom-resources", context.getActionReport(), adminSubject()).parameters(parameters).execute(listCommand);
    List<MessagePart> list = context.getActionReport().getTopMessagePart().getChildren();
    assertEquals(origNum + 1, list.size());
    // as we newly created a resource after test "setup".
    origNum = origNum + 1;
    deleteCustomResource();
    ParameterMap parameters = new ParameterMap();
    listCommand = habitat.getService(org.glassfish.resources.admin.cli.ListCustomResources.class);
    context = new AdminCommandContextImpl(LogDomains.getLogger(ListCustomResourcesTest.class, LogDomains.ADMIN_LOGGER), new PropsFileActionReporter());
    cr.getCommandInvocation("list-custom-resources", context.getActionReport(), adminSubject()).parameters(parameters).execute(listCommand);
    list = context.getActionReport().getTopMessagePart().getChildren();
    if ((origNum - 1) == 0) {
    // Nothing to list.
    } else {
        assertEquals(origNum - 1, list.size());
    }
    List<String> listStr = new java.util.ArrayList<String>();
    for (MessagePart mp : list) {
        listStr.add(mp.getMessage());
    }
    assertFalse(listStr.contains("custom_resource1"));
    assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
}
Also used : MessagePart(org.glassfish.api.ActionReport.MessagePart) ParameterMap(org.glassfish.api.admin.ParameterMap) PropsFileActionReporter(com.sun.enterprise.v3.common.PropsFileActionReporter) AdminCommandContextImpl(org.glassfish.api.admin.AdminCommandContextImpl) Test(org.junit.Test) ConfigApiTest(org.glassfish.tests.utils.ConfigApiTest)

Aggregations

MessagePart (org.glassfish.api.ActionReport.MessagePart)25 ParameterMap (org.glassfish.api.admin.ParameterMap)11 Test (org.junit.Test)11 ConfigApiTest (org.glassfish.tests.utils.ConfigApiTest)9 PropsFileActionReporter (com.sun.enterprise.v3.common.PropsFileActionReporter)7 AdminCommandContextImpl (org.glassfish.api.admin.AdminCommandContextImpl)7 ArrayList (java.util.ArrayList)5 RestActionReporter (org.glassfish.admin.rest.utils.xml.RestActionReporter)5 Properties (java.util.Properties)4 ActionReport (org.glassfish.api.ActionReport)4 HashMap (java.util.HashMap)3 ActionReporter (com.sun.enterprise.v3.common.ActionReporter)2 Map (java.util.Map)2 JsonObject (javax.json.JsonObject)2 JsonObjectBuilder (javax.json.JsonObjectBuilder)2 XmlMap (org.glassfish.admin.rest.utils.xml.XmlMap)2 CommandInvocation (org.glassfish.api.admin.CommandRunner.CommandInvocation)2 RemoteCLICommand (com.sun.enterprise.admin.cli.remote.RemoteCLICommand)1 Resource (com.sun.enterprise.config.serverbeans.Resource)1 IOException (java.io.IOException)1