Search in sources :

Example 96 with ParameterMap

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

the class CreateIiopListenerTest method testExecuteFailForSamePortAndListenerAddress.

/**
 * Test of execute method, of class CreateIiopListener with same iiop port number
 * and listener address.
 * asadmin create-iiop-listener --listeneraddress localhost
 * --iiopport 4440 iiop_1
 * asadmin create-iiop-listener --listeneraddress localhost
 * --iiopport 4440 iiop_2
 */
@Test
public void testExecuteFailForSamePortAndListenerAddress() {
    parameters.set("listeneraddress", "localhost");
    parameters.set("iiopport", "4440");
    parameters.set("listener_id", "iiop_1");
    CreateIiopListener command = services.getService(CreateIiopListener.class);
    cr.getCommandInvocation("create-iiop-listener", context.getActionReport(), adminSubject()).parameters(parameters).execute(command);
    checkActionReport(context.getActionReport());
    boolean isCreated = false;
    List<IiopListener> listenerList = iiopService.getIiopListener();
    for (IiopListener listener : listenerList) {
        if (listener.getId().equals("iiop_1")) {
            assertEquals("localhost", listener.getAddress());
            assertEquals("4440", listener.getPort());
            isCreated = true;
            logger.fine("IIOPListener name iiop_1 is created.");
            break;
        }
    }
    assertTrue(isCreated);
    logger.fine("msg: " + context.getActionReport().getMessage());
    parameters = new ParameterMap();
    parameters.set("listener_id", "iiop_2");
    parameters.set("iiopport", "4440");
    parameters.set("listeneraddress", "localhost");
    cr.getCommandInvocation("create-iiop-listener", context.getActionReport(), adminSubject()).parameters(parameters).execute(command);
    assertEquals(ActionReport.ExitCode.FAILURE, context.getActionReport().getActionExitCode());
    logger.fine("msg: " + context.getActionReport().getMessage());
}
Also used : IiopListener(org.glassfish.orb.admin.config.IiopListener) ParameterMap(org.glassfish.api.admin.ParameterMap) Test(org.junit.Test)

Example 97 with ParameterMap

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

the class CreateIiopListenerTest method setUp.

@Before
public void setUp() {
    services = getHabitat();
    iiopService = services.getService(IiopService.class);
    parameters = new ParameterMap();
    context = new AdminCommandContextImpl(LogDomains.getLogger(CreateIiopListenerTest.class, LogDomains.ADMIN_LOGGER), new PropsFileActionReporter());
    cr = services.getService(CommandRunner.class);
}
Also used : AdminCommandContextImpl(org.glassfish.api.admin.AdminCommandContextImpl) IiopService(org.glassfish.orb.admin.config.IiopService) ParameterMap(org.glassfish.api.admin.ParameterMap) PropsFileActionReporter(com.sun.enterprise.v3.common.PropsFileActionReporter) CommandRunner(org.glassfish.api.admin.CommandRunner) Before(org.junit.Before)

Example 98 with ParameterMap

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

the class DeleteIiopListenerTest method testExecuteSuccessDefaultTarget.

/**
 * Test of execute method, of class DeleteIiopListener.
 * delete-iiop-listener iiop_1
 */
@Test
public void testExecuteSuccessDefaultTarget() {
    parameters.set("listeneraddress", "localhost");
    parameters.set("iiopport", "4440");
    parameters.set("listener_id", "iiop_1");
    CreateIiopListener createCommand = services.getService(CreateIiopListener.class);
    cr.getCommandInvocation("create-iiop-listener", context.getActionReport(), adminSubject()).parameters(parameters).execute(createCommand);
    CreateIiopListenerTest.checkActionReport(context.getActionReport());
    parameters = new ParameterMap();
    parameters.set("listener_id", "iiop_1");
    DeleteIiopListener deleteCommand = services.getService(DeleteIiopListener.class);
    cr.getCommandInvocation("delete-iiop-listener", context.getActionReport(), adminSubject()).parameters(parameters).execute(deleteCommand);
    CreateIiopListenerTest.checkActionReport(context.getActionReport());
    boolean isDeleted = true;
    List<IiopListener> listenerList = iiopService.getIiopListener();
    for (IiopListener listener : listenerList) {
        if (listener.getId().equals("iiop_1")) {
            isDeleted = false;
            logger.fine("IIOPListener name iiop_1 is not deleted.");
            break;
        }
    }
    assertTrue(isDeleted);
    logger.fine("msg: " + context.getActionReport().getMessage());
}
Also used : IiopListener(org.glassfish.orb.admin.config.IiopListener) ParameterMap(org.glassfish.api.admin.ParameterMap) Test(org.junit.Test)

Example 99 with ParameterMap

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

the class DeleteIiopListenerTest method setUp.

@Before
public void setUp() {
    services = getHabitat();
    iiopService = services.getService(IiopService.class);
    parameters = new ParameterMap();
    cr = services.getService(CommandRunner.class);
    context = new AdminCommandContextImpl(LogDomains.getLogger(DeleteIiopListenerTest.class, LogDomains.ADMIN_LOGGER), new PropsFileActionReporter());
}
Also used : AdminCommandContextImpl(org.glassfish.api.admin.AdminCommandContextImpl) IiopService(org.glassfish.orb.admin.config.IiopService) ParameterMap(org.glassfish.api.admin.ParameterMap) PropsFileActionReporter(com.sun.enterprise.v3.common.PropsFileActionReporter) CommandRunner(org.glassfish.api.admin.CommandRunner) Before(org.junit.Before)

Example 100 with ParameterMap

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

the class ListIiopListenersTest method testExecuteSuccessListListener.

/**
 * Test of execute method, of class ListIiopListeners.
 * asadmin create-iiop-listener --listeneraddress localhost
 * --iiopport 4440 listener
 * list-iiop-listeners
 * delete-iiop-listener listener
 */
@Test
public void testExecuteSuccessListListener() {
    parameters.set("listeneraddress", "localhost");
    parameters.set("iiopport", "4440");
    parameters.set("listener_id", "listener");
    CreateIiopListener createCommand = services.getService(CreateIiopListener.class);
    cr.getCommandInvocation("create-iiop-listener", context.getActionReport(), adminSubject()).parameters(parameters).execute(createCommand);
    CreateIiopListenerTest.checkActionReport(context.getActionReport());
    parameters = new ParameterMap();
    ListIiopListeners listCommand = services.getService(ListIiopListeners.class);
    cr.getCommandInvocation("list-iiop-listeners", 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("listener"));
    CreateIiopListenerTest.checkActionReport(context.getActionReport());
    parameters = new ParameterMap();
    parameters.set("listener_id", "listener");
    DeleteIiopListener deleteCommand = services.getService(DeleteIiopListener.class);
    cr.getCommandInvocation("delete-iiop-listener", context.getActionReport(), adminSubject()).parameters(parameters).execute(deleteCommand);
    CreateIiopListenerTest.checkActionReport(context.getActionReport());
}
Also used : MessagePart(org.glassfish.api.ActionReport.MessagePart) ArrayList(java.util.ArrayList) ParameterMap(org.glassfish.api.admin.ParameterMap) Test(org.junit.Test)

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