Search in sources :

Example 16 with PropsFileActionReporter

use of com.sun.enterprise.admin.report.PropsFileActionReporter in project Payara by payara.

the class DeleteCustomResourceTest 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(DeleteCustomResourceTest.class, LogDomains.ADMIN_LOGGER), new PropsFileActionReporter());
}
Also used : AdminCommandContextImpl(org.glassfish.api.admin.AdminCommandContextImpl) ParameterMap(org.glassfish.api.admin.ParameterMap) PropsFileActionReporter(com.sun.enterprise.admin.report.PropsFileActionReporter) CommandRunner(org.glassfish.api.admin.CommandRunner) Before(org.junit.Before)

Example 17 with PropsFileActionReporter

use of com.sun.enterprise.admin.report.PropsFileActionReporter in project Payara by payara.

the class CreateCustomResourceTest method setUp.

@Before
public void setUp() {
    parameters = new ParameterMap();
    resources = habitat.<Domain>getService(Domain.class).getResources();
    assertTrue(resources != null);
    command = habitat.getService(org.glassfish.resources.admin.cli.CreateCustomResource.class);
    assertTrue(command != null);
    context = new AdminCommandContextImpl(LogDomains.getLogger(CreateCustomResourceTest.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.admin.report.PropsFileActionReporter) CommandRunner(org.glassfish.api.admin.CommandRunner) Before(org.junit.Before)

Example 18 with PropsFileActionReporter

use of com.sun.enterprise.admin.report.PropsFileActionReporter 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", "H2Pool");
    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.admin.report.PropsFileActionReporter) CommandRunner(org.glassfish.api.admin.CommandRunner) Before(org.junit.Before)

Example 19 with PropsFileActionReporter

use of com.sun.enterprise.admin.report.PropsFileActionReporter 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.admin.report.PropsFileActionReporter) Ignore(org.junit.Ignore) Test(org.junit.Test) ConfigApiTest(org.glassfish.tests.utils.ConfigApiTest)

Example 20 with PropsFileActionReporter

use of com.sun.enterprise.admin.report.PropsFileActionReporter in project Payara by payara.

the class ListJdbcResourcesTest method testExecuteSuccessListBob.

/**
 * Test of execute method, of class ListJdbcResource.
 * create-jdbc-resource --connectionpoolid H2Pool 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", "H2Pool");
    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.admin.report.PropsFileActionReporter) Test(org.junit.Test) ConfigApiTest(org.glassfish.tests.utils.ConfigApiTest)

Aggregations

PropsFileActionReporter (com.sun.enterprise.admin.report.PropsFileActionReporter)30 AdminCommandContextImpl (org.glassfish.api.admin.AdminCommandContextImpl)23 ParameterMap (org.glassfish.api.admin.ParameterMap)19 Before (org.junit.Before)14 CommandRunner (org.glassfish.api.admin.CommandRunner)13 ConfigApiTest (org.glassfish.tests.utils.ConfigApiTest)9 Test (org.junit.Test)9 MessagePart (org.glassfish.api.ActionReport.MessagePart)7 ActionReport (org.glassfish.api.ActionReport)5 Domain (com.sun.enterprise.config.serverbeans.Domain)4 Resource (com.sun.enterprise.config.serverbeans.Resource)4 Resources (com.sun.enterprise.config.serverbeans.Resources)3 IiopService (org.glassfish.orb.admin.config.IiopService)3 RestPayloadImpl (com.sun.enterprise.admin.remote.RestPayloadImpl)2 CachedCommandModel (com.sun.enterprise.admin.util.CachedCommandModel)2 ArrayList (java.util.ArrayList)2 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)2 Ignore (org.junit.Ignore)2 ParamsWithPayload (com.sun.enterprise.admin.remote.ParamsWithPayload)1 ActionReporter (com.sun.enterprise.admin.report.ActionReporter)1