use of org.glassfish.api.admin.AdminCommandContextImpl in project Payara by payara.
the class ListJdbcResourcesTest method testExecuteSuccessValidTargetOperand.
/**
* Test of execute method, of class ListJdbcResource.
* list-jdbc-resources server
*/
@Test
public void testExecuteSuccessValidTargetOperand() {
// List the original set of JDBC Resources
// Get an instance of the ListJdbcResources command
listCommand = habitat.getService(ListJdbcResources.class);
parameters.add("DEFAULT", "server");
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, list.size());
// Check the exit code is Success
assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
}
use of org.glassfish.api.admin.AdminCommandContextImpl in project Payara by payara.
the class ListJdbcResourcesTest method testExecuteSuccessListNoBob.
/**
* Test of execute method, of class ListJdbcResource.
* delete-jdbc-resource bob
* list-jdbc-resources
*/
@Test
public void testExecuteSuccessListNoBob() {
// 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", "DerbyPool");
parameters.add("DEFAULT", "bob2");
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());
// Delete JDBC Resource bob
// assertTrue(resources!=null);
// Get an instance of the CreateJdbcResource command
deleteCommand = habitat.getService(DeleteJdbcResource.class);
assertTrue(deleteCommand != null);
parameters = new ParameterMap();
parameters.add("DEFAULT", "bob2");
cr.getCommandInvocation("delete-jdbc-resource", context.getActionReport(), adminSubject()).parameters(parameters).execute(deleteCommand);
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();
int numResources = 0;
for (Resource resource : resources.getResources()) {
if (resource instanceof JdbcResource) {
numResources = numResources + 1;
}
}
assertEquals(numResources, list.size());
List<String> listStr = new java.util.ArrayList();
for (MessagePart mp : list) {
listStr.add(mp.getMessage());
}
assertFalse(listStr.contains("bob2"));
// Check the exit code is SUCCESS
assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
}
use of org.glassfish.api.admin.AdminCommandContextImpl in project Payara by payara.
the class ListJdbcResourcesTest method testExecuteFailInvalidTargetOperand.
/**
* Test of execute method, of class ListJdbcResource.
* list-jdbc-resources invalid
*/
@Ignore
@Test
public void testExecuteFailInvalidTargetOperand() {
// List the original set of JDBC Resources
// Get an instance of the ListJdbcResources command
listCommand = habitat.getService(ListJdbcResources.class);
parameters.add("DEFAULT", "invalid");
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);
// Need bug fix before uncommenting assertion
// List<MessagePart> list = context.getActionReport().getTopMessagePart().getChildren();
// assertEquals(0, list.size());
// Check the exit code is FAILURE
// Need bug fix before uncommenting assertion
// assertEquals(ActionReport.ExitCode.FAILURE, context.getActionReport().getActionExitCode());
// Check error msg 'Invalid target: invalid'
}
use of org.glassfish.api.admin.AdminCommandContextImpl in project Payara by payara.
the class RuntimeRootImpl method restartDomain.
public void restartDomain() {
final ModulesRegistry registry = InjectedValues.getInstance().getModulesRegistry();
final AdminCommandContext ctx = new AdminCommandContextImpl(AMXLoggerInfo.getLogger(), new PlainTextActionReporter());
final AdminCommand cmd = new RestartDomainCommand(registry);
cmd.execute(ctx);
}
use of org.glassfish.api.admin.AdminCommandContextImpl in project Payara by payara.
the class DeleteJdbcResourceTest method setUp.
@Before
public void setUp() {
assertTrue(resources != null);
// Create a JDBC Resource jdbc/foo for each test
CreateJdbcResource createCommand = habitat.getService(CreateJdbcResource.class);
assertTrue(createCommand != null);
parameters.add("connectionpoolid", "DerbyPool");
parameters.add("DEFAULT", "jdbc/foo");
context = new AdminCommandContextImpl(LogDomains.getLogger(DeleteJdbcResourceTest.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());
// Setup for delete-jdbc-resource
parameters = new ParameterMap();
deleteCommand = habitat.getService(DeleteJdbcResource.class);
assertTrue(deleteCommand != null);
}
Aggregations