Search in sources :

Example 16 with AdminCommandContextImpl

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

the class CreateJdbcResourceTest method setUp.

@Before
public void setUp() {
    assertTrue(resources != null);
    // Get an instance of the CreateJdbcResource command
    command = habitat.getService(CreateJdbcResource.class);
    assertTrue(command != null);
    // Set the options and operand to pass to the command
    parameters.set("connectionpoolid", "DerbyPool");
    parameters.set("enabled", "true");
    parameters.set("description", "my resource");
    parameters.set("DEFAULT", "jdbc/foo");
    context = new AdminCommandContextImpl(LogDomains.getLogger(CreateJdbcResourceTest.class, LogDomains.ADMIN_LOGGER), new PropsFileActionReporter());
    cr = habitat.getService(CommandRunner.class);
}
Also used : AdminCommandContextImpl(org.glassfish.api.admin.AdminCommandContextImpl) PropsFileActionReporter(com.sun.enterprise.v3.common.PropsFileActionReporter) CommandRunner(org.glassfish.api.admin.CommandRunner) Before(org.junit.Before)

Example 17 with AdminCommandContextImpl

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

the class ListJdbcResourcesTest method testExecuteFailInvalidOption.

/**
 * Test of execute method, of class ListJdbcResource.
 * list-jdbc-resources --invalid invalid
 */
@Ignore
@Test
public void testExecuteFailInvalidOption() {
    listCommand = habitat.getService(ListJdbcResources.class);
    parameters.add("invalid", "invalid");
    context = new AdminCommandContextImpl(LogDomains.getLogger(ListJdbcResourcesTest.class, LogDomains.ADMIN_LOGGER), new PropsFileActionReporter());
    cr.getCommandInvocation("list-jdbc-resources", context.getActionReport(), adminSubject()).parameters(parameters).execute(listCommand);
    List<MessagePart> list = context.getActionReport().getTopMessagePart().getChildren();
    assertEquals(1, list.size());
    for (MessagePart mp : list) {
        assertEquals("Usage: list-jdbc-resources ", mp.getMessage());
    }
    // Check the exit code is FAILURE
    assertEquals(ActionReport.ExitCode.FAILURE, context.getActionReport().getActionExitCode());
}
Also used : AdminCommandContextImpl(org.glassfish.api.admin.AdminCommandContextImpl) MessagePart(org.glassfish.api.ActionReport.MessagePart) PropsFileActionReporter(com.sun.enterprise.v3.common.PropsFileActionReporter) Ignore(org.junit.Ignore) Test(org.junit.Test) ConfigApiTest(org.glassfish.tests.utils.ConfigApiTest)

Example 18 with AdminCommandContextImpl

use of org.glassfish.api.admin.AdminCommandContextImpl 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());
}
Also used : AdminCommandContextImpl(org.glassfish.api.admin.AdminCommandContextImpl) MessagePart(org.glassfish.api.ActionReport.MessagePart) ParameterMap(org.glassfish.api.admin.ParameterMap) PropsFileActionReporter(com.sun.enterprise.v3.common.PropsFileActionReporter) Test(org.junit.Test) ConfigApiTest(org.glassfish.tests.utils.ConfigApiTest)

Example 19 with AdminCommandContextImpl

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

the class ListJndiResourcesTest method setUp.

@Before
public void setUp() {
    habitat = getHabitat();
    cr = habitat.getService(CommandRunner.class);
    context = new AdminCommandContextImpl(LogDomains.getLogger(ListJndiResourcesTest.class, LogDomains.ADMIN_LOGGER), new PropsFileActionReporter());
    parameters = new ParameterMap();
    Resources resources = habitat.<Domain>getService(Domain.class).getResources();
    for (Resource resource : resources.getResources()) {
        if (resource instanceof org.glassfish.resources.config.ExternalJndiResource) {
            origNum = origNum + 1;
        }
    }
}
Also used : AdminCommandContextImpl(org.glassfish.api.admin.AdminCommandContextImpl) Resource(com.sun.enterprise.config.serverbeans.Resource) ParameterMap(org.glassfish.api.admin.ParameterMap) Resources(com.sun.enterprise.config.serverbeans.Resources) PropsFileActionReporter(com.sun.enterprise.v3.common.PropsFileActionReporter) Domain(com.sun.enterprise.config.serverbeans.Domain) CommandRunner(org.glassfish.api.admin.CommandRunner) Before(org.junit.Before)

Example 20 with AdminCommandContextImpl

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

the class DeleteJavaMailResourceTest method setUp.

@Before
public void setUp() {
    habitat = getHabitat();
    parameters = new ParameterMap();
    cr = habitat.getService(CommandRunner.class);
    resources = habitat.<Domain>getService(Domain.class).getResources();
    context = new AdminCommandContextImpl(LogDomains.getLogger(DeleteJavaMailResourceTest.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