Search in sources :

Example 76 with ParameterMap

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

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

Example 78 with ParameterMap

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

the class ListJavaMailResourcesTest method setUp.

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

Example 79 with ParameterMap

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

the class ListJavaMailResourcesTest method testExecuteSuccessListMailResource.

/**
 * Test of execute method, of class ListJavaMailResource.
 * create-javamail-resource --mailuser=test --mailhost=localhost
 * --fromaddress=test@sun.com mailresource
 * list-javamail-resources
 */
@Test
public void testExecuteSuccessListMailResource() {
    createJavaMailResource();
    parameters = new ParameterMap();
    org.glassfish.resources.javamail.admin.cli.ListJavaMailResources listCommand = habitat.getService(org.glassfish.resources.javamail.admin.cli.ListJavaMailResources.class);
    assertTrue(listCommand != null);
    cr.getCommandInvocation("list-javamail-resources", context.getActionReport(), adminSubject()).parameters(parameters).execute(listCommand);
    List<MessagePart> list = context.getActionReport().getTopMessagePart().getChildren();
    assertEquals(origNum + 1, list.size());
    List<String> listStr = new ArrayList<String>();
    for (MessagePart mp : list) {
        listStr.add(mp.getMessage());
    }
    assertTrue(listStr.contains("mailresource"));
    assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
    deleteJavaMailResource();
}
Also used : MessagePart(org.glassfish.api.ActionReport.MessagePart) ArrayList(java.util.ArrayList) ParameterMap(org.glassfish.api.admin.ParameterMap) Test(org.junit.Test) ConfigApiTest(org.glassfish.tests.utils.ConfigApiTest)

Example 80 with ParameterMap

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

the class DeleteJndiResourceTest method tearDown.

@After
public void tearDown() throws TransactionFailure {
    parameters = new ParameterMap();
    ConfigSupport.apply(new SingleConfigCode<Resources>() {

        public Object run(Resources param) throws PropertyVetoException, TransactionFailure {
            Resource target = null;
            for (Resource resource : param.getResources()) {
                if (resource instanceof BindableResource) {
                    BindableResource r = (BindableResource) resource;
                    if (r.getJndiName().equals("sample_jndi_resource") || r.getJndiName().equals("dupRes")) {
                        target = resource;
                        break;
                    }
                }
            }
            if (target != null) {
                param.getResources().remove(target);
            }
            return null;
        }
    }, resources);
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) 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) 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