Search in sources :

Example 6 with ParameterMap

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

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

the class ListJndiResourcesTest method createJndiResource.

private void createJndiResource() {
    parameters = new ParameterMap();
    parameters.set("restype", "topic");
    parameters.set("jndilookupname", "sample_jndi");
    parameters.set("factoryclass", "javax.naming.spi.ObjectFactory");
    parameters.set("jndi_name", "resource");
    org.glassfish.resources.admin.cli.CreateJndiResource createCommand = habitat.getService(org.glassfish.resources.admin.cli.CreateJndiResource.class);
    cr.getCommandInvocation("create-jndi-resource", context.getActionReport(), adminSubject()).parameters(parameters).execute(createCommand);
    assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
}
Also used : ParameterMap(org.glassfish.api.admin.ParameterMap)

Example 8 with ParameterMap

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

the class ListJndiResourcesTest method deleteJndiResource.

private void deleteJndiResource() {
    parameters = new ParameterMap();
    parameters.set("jndi_name", "resource");
    org.glassfish.resources.admin.cli.DeleteJndiResource deleteCommand = habitat.getService(org.glassfish.resources.admin.cli.DeleteJndiResource.class);
    cr.getCommandInvocation("delete-jndi-resource", context.getActionReport(), adminSubject()).parameters(parameters).execute(deleteCommand);
    assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
}
Also used : ParameterMap(org.glassfish.api.admin.ParameterMap)

Example 9 with ParameterMap

use of org.glassfish.api.admin.ParameterMap 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 10 with ParameterMap

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

the class CreateJavaMailResourceTest method tearDown.

@After
public void tearDown() throws TransactionFailure {
    org.glassfish.resources.javamail.admin.cli.DeleteJavaMailResource deleteCommand = habitat.getService(org.glassfish.resources.javamail.admin.cli.DeleteJavaMailResource.class);
    parameters = new ParameterMap();
    parameters.set("jndi_name", "mail/MyMailSession");
    cr.getCommandInvocation("delete-javamail-resource", context.getActionReport(), adminSubject()).parameters(parameters).execute(deleteCommand);
    parameters = new ParameterMap();
    parameters.set("jndi_name", "dupRes");
    cr.getCommandInvocation("delete-javamail-resource", context.getActionReport(), adminSubject()).parameters(parameters).execute(deleteCommand);
}
Also used : ParameterMap(org.glassfish.api.admin.ParameterMap) After(org.junit.After)

Aggregations

ParameterMap (org.glassfish.api.admin.ParameterMap)149 ActionReport (org.glassfish.api.ActionReport)68 CommandRunner (org.glassfish.api.admin.CommandRunner)37 Test (org.junit.Test)25 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)24 Map (java.util.Map)20 PropsFileActionReporter (com.sun.enterprise.v3.common.PropsFileActionReporter)19 AdminCommandContextImpl (org.glassfish.api.admin.AdminCommandContextImpl)18 List (java.util.List)16 ArrayList (java.util.ArrayList)15 CommandRunner (org.glassfish.embeddable.CommandRunner)15 IOException (java.io.IOException)14 ConfigApiTest (org.glassfish.tests.utils.ConfigApiTest)13 Before (org.junit.Before)13 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)13 CommandException (org.glassfish.api.admin.CommandException)12 File (java.io.File)11 MessagePart (org.glassfish.api.ActionReport.MessagePart)11 Resource (com.sun.enterprise.config.serverbeans.Resource)10 Logger (java.util.logging.Logger)9