Search in sources :

Example 1 with AdminCommandContextImpl

use of org.glassfish.api.admin.AdminCommandContextImpl in project Payara by payara.

the class ListJndiResourcesTest method testExecuteSuccessListNoResource.

/**
 * Test of execute method, of class ListJndiResource.
 * delete-jndi-resource resource
 * list-jndi-resources
 */
@Test
public void testExecuteSuccessListNoResource() {
    createJndiResource();
    parameters = new ParameterMap();
    org.glassfish.resources.admin.cli.ListJndiResources listCommand = habitat.getService(org.glassfish.resources.admin.cli.ListJndiResources.class);
    cr.getCommandInvocation("list-jndi-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;
    deleteJndiResource();
    ParameterMap parameters = new ParameterMap();
    listCommand = habitat.getService(org.glassfish.resources.admin.cli.ListJndiResources.class);
    context = new AdminCommandContextImpl(LogDomains.getLogger(ListJndiResourcesTest.class, LogDomains.ADMIN_LOGGER), new PropsFileActionReporter());
    cr.getCommandInvocation("list-jndi-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 (ActionReport.MessagePart mp : list) {
        listStr.add(mp.getMessage());
    }
    assertFalse(listStr.contains("resource"));
    assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
}
Also used : ArrayList(java.util.ArrayList) ParameterMap(org.glassfish.api.admin.ParameterMap) PropsFileActionReporter(com.sun.enterprise.v3.common.PropsFileActionReporter) ActionReport(org.glassfish.api.ActionReport) AdminCommandContextImpl(org.glassfish.api.admin.AdminCommandContextImpl) Test(org.junit.Test) ConfigApiTest(org.glassfish.tests.utils.ConfigApiTest)

Example 2 with AdminCommandContextImpl

use of org.glassfish.api.admin.AdminCommandContextImpl in project Payara by payara.

the class CreateJavaMailResourceTest method setUp.

@Before
public void setUp() {
    System.out.println("\n\n *** Entering setup method *** \n\n");
    System.out.println("Current dir: " + System.getProperty("user.dir") + "\n");
    AuthorizationService foo = new AuthorizationServiceImpl();
    System.out.println("Direct instantiation: " + foo);
    habitat = getHabitat();
    foo = habitat.getService(AuthorizationService.class);
    System.out.println("Lookup via habitat: " + foo + "\n");
    resources = habitat.<Domain>getService(Domain.class).getResources();
    assertTrue(resources != null);
    parameters = new ParameterMap();
    context = new AdminCommandContextImpl(getLogger(CreateJavaMailResourceTest.class, ADMIN_LOGGER), new PropsFileActionReporter());
    cr = habitat.getService(CommandRunner.class);
    assertTrue(cr != null);
}
Also used : AdminCommandContextImpl(org.glassfish.api.admin.AdminCommandContextImpl) AuthorizationService(org.glassfish.security.services.api.authorization.AuthorizationService) ParameterMap(org.glassfish.api.admin.ParameterMap) Domain(com.sun.enterprise.config.serverbeans.Domain) PropsFileActionReporter(com.sun.enterprise.v3.common.PropsFileActionReporter) CommandRunner(org.glassfish.api.admin.CommandRunner) AuthorizationServiceImpl(org.glassfish.security.services.impl.authorization.AuthorizationServiceImpl) Before(org.junit.Before)

Example 3 with AdminCommandContextImpl

use of org.glassfish.api.admin.AdminCommandContextImpl 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 AdminCommandContextImpl

use of org.glassfish.api.admin.AdminCommandContextImpl in project Payara by payara.

the class CreateJndiResourceTest method setUp.

@Before
public void setUp() {
    habitat = getHabitat();
    resources = habitat.<Domain>getService(Domain.class).getResources();
    server = habitat.getService(Server.class);
    parameters = new ParameterMap();
    context = new AdminCommandContextImpl(LogDomains.getLogger(CreateJndiResourceTest.class, LogDomains.ADMIN_LOGGER), new PropsFileActionReporter());
    cr = habitat.getService(CommandRunner.class);
}
Also used : AdminCommandContextImpl(org.glassfish.api.admin.AdminCommandContextImpl) ParameterMap(org.glassfish.api.admin.ParameterMap) PropsFileActionReporter(com.sun.enterprise.v3.common.PropsFileActionReporter) CommandRunner(org.glassfish.api.admin.CommandRunner) Before(org.junit.Before)

Example 5 with AdminCommandContextImpl

use of org.glassfish.api.admin.AdminCommandContextImpl in project Payara by payara.

the class DeleteJndiResourceTest method setUp.

@Before
public void setUp() {
    habitat = getHabitat();
    resources = habitat.<Domain>getService(Domain.class).getResources();
    parameters = new ParameterMap();
    cr = habitat.getService(CommandRunner.class);
    context = new AdminCommandContextImpl(LogDomains.getLogger(DeleteJndiResourceTest.class, LogDomains.ADMIN_LOGGER), new PropsFileActionReporter());
}
Also used : AdminCommandContextImpl(org.glassfish.api.admin.AdminCommandContextImpl) ParameterMap(org.glassfish.api.admin.ParameterMap) PropsFileActionReporter(com.sun.enterprise.v3.common.PropsFileActionReporter) CommandRunner(org.glassfish.api.admin.CommandRunner) Before(org.junit.Before)

Aggregations

AdminCommandContextImpl (org.glassfish.api.admin.AdminCommandContextImpl)26 PropsFileActionReporter (com.sun.enterprise.v3.common.PropsFileActionReporter)23 ParameterMap (org.glassfish.api.admin.ParameterMap)18 Before (org.junit.Before)15 CommandRunner (org.glassfish.api.admin.CommandRunner)13 Test (org.junit.Test)10 ConfigApiTest (org.glassfish.tests.utils.ConfigApiTest)9 MessagePart (org.glassfish.api.ActionReport.MessagePart)7 Domain (com.sun.enterprise.config.serverbeans.Domain)4 Resource (com.sun.enterprise.config.serverbeans.Resource)4 Resources (com.sun.enterprise.config.serverbeans.Resources)3 ActionReport (org.glassfish.api.ActionReport)3 AdminCommandContext (org.glassfish.api.admin.AdminCommandContext)3 IiopService (org.glassfish.orb.admin.config.IiopService)3 PlainTextActionReporter (com.sun.enterprise.v3.common.PlainTextActionReporter)2 ArrayList (java.util.ArrayList)2 Ignore (org.junit.Ignore)2 ModulesRegistry (com.sun.enterprise.module.ModulesRegistry)1 RestartDomainCommand (com.sun.enterprise.v3.admin.RestartDomainCommand)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1