Search in sources :

Example 16 with ParameterMap

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

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

the class CreateJndiResourceTest method tearDown.

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

Example 18 with ParameterMap

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

the class DeleteJndiResourceTest method testExecuteSuccessDefaultTarget.

/**
 * Test of execute method, of class DeleteJndiResource.
 * asadmin create-jndi-resource --restype=queue --factoryclass=sampleClass --jndilookupname=sample_jndi
 * sample_jndi_resource
 * delete-jndi-resource sample_jndi_resource
 */
@Test
public void testExecuteSuccessDefaultTarget() {
    parameters.set("restype", "topic");
    parameters.set("jndilookupname", "sample_jndi");
    parameters.set("factoryclass", "javax.naming.spi.ObjectFactory");
    parameters.set("jndi_name", "sample_jndi_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());
    parameters = new ParameterMap();
    parameters.set("jndi_name", "sample_jndi_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());
    boolean isDeleted = true;
    for (Resource resource : resources.getResources()) {
        if (resource instanceof BindableResource) {
            BindableResource jr = (BindableResource) resource;
            if (jr.getJndiName().equals("sample_jndi_resource")) {
                isDeleted = false;
                logger.fine("Jndi Resource config bean sample_jndi_resource is created.");
                break;
            }
        }
    }
    assertTrue(isDeleted);
    logger.fine("msg: " + context.getActionReport().getMessage());
    Servers servers = habitat.getService(Servers.class);
    boolean isRefDeleted = true;
    for (Server server : servers.getServer()) {
        if (server.getName().equals(SystemPropertyConstants.DEFAULT_SERVER_INSTANCE_NAME)) {
            for (ResourceRef ref : server.getResourceRef()) {
                if (ref.getRef().equals("sample_jndi_resource")) {
                    isRefDeleted = false;
                    break;
                }
            }
        }
    }
    assertTrue(isRefDeleted);
}
Also used : BindableResource(com.sun.enterprise.config.serverbeans.BindableResource) BindableResource(com.sun.enterprise.config.serverbeans.BindableResource) Resource(com.sun.enterprise.config.serverbeans.Resource) ParameterMap(org.glassfish.api.admin.ParameterMap) ResourceRef(com.sun.enterprise.config.serverbeans.ResourceRef) Test(org.junit.Test) ConfigApiTest(org.glassfish.tests.utils.ConfigApiTest)

Example 19 with ParameterMap

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

Example 20 with ParameterMap

use of org.glassfish.api.admin.ParameterMap 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.v3.common.PropsFileActionReporter) CommandRunner(org.glassfish.api.admin.CommandRunner) Before(org.junit.Before)

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