use of org.glassfish.api.admin.ParameterMap in project Payara by payara.
the class DeleteCustomResourceTest method testExecuteSuccessDefaultTarget.
/**
* Test of execute method, of class DeleteCustomResource.
* delete-custom-resource sample_custom_resource
*/
@Test
public void testExecuteSuccessDefaultTarget() {
org.glassfish.resources.admin.cli.CreateCustomResource createCommand = habitat.getService(org.glassfish.resources.admin.cli.CreateCustomResource.class);
assertTrue(createCommand != null);
parameters.set("restype", "topic");
parameters.set("factoryclass", "javax.naming.spi.ObjectFactory");
parameters.set("jndi_name", "sample_custom_resource");
cr.getCommandInvocation("create-custom-resource", context.getActionReport(), adminSubject()).parameters(parameters).execute(createCommand);
assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
parameters = new ParameterMap();
org.glassfish.resources.admin.cli.DeleteCustomResource deleteCommand = habitat.getService(org.glassfish.resources.admin.cli.DeleteCustomResource.class);
assertTrue(deleteCommand != null);
parameters.set("jndi_name", "sample_custom_resource");
cr.getCommandInvocation("delete-custom-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 CustomResource) {
CustomResource jr = (CustomResource) resource;
if (jr.getJndiName().equals("sample_custom_resource")) {
isDeleted = false;
logger.fine("CustomResource config bean sample_custom_resource is deleted.");
break;
}
}
}
assertTrue(isDeleted);
logger.fine("msg: " + context.getActionReport().getMessage());
assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
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_custom_resource")) {
isRefDeleted = false;
break;
}
}
}
}
assertTrue(isRefDeleted);
}
use of org.glassfish.api.admin.ParameterMap in project Payara by payara.
the class CreateCustomResourceTest method setUp.
@Before
public void setUp() {
parameters = new ParameterMap();
resources = habitat.<Domain>getService(Domain.class).getResources();
assertTrue(resources != null);
command = habitat.getService(org.glassfish.resources.admin.cli.CreateCustomResource.class);
assertTrue(command != null);
context = new AdminCommandContextImpl(LogDomains.getLogger(CreateCustomResourceTest.class, LogDomains.ADMIN_LOGGER), new PropsFileActionReporter());
cr = habitat.getService(CommandRunner.class);
}
use of org.glassfish.api.admin.ParameterMap in project Payara by payara.
the class CreateCustomResourceTest method tearDown.
@After
public void tearDown() throws TransactionFailure {
org.glassfish.resources.admin.cli.DeleteCustomResource deleteCommand = habitat.getService(org.glassfish.resources.admin.cli.DeleteCustomResource.class);
parameters = new ParameterMap();
parameters.set("jndi_name", "sample_custom_resource");
cr.getCommandInvocation("delete-custom-resource", context.getActionReport(), adminSubject()).parameters(parameters).execute(deleteCommand);
parameters = new ParameterMap();
parameters.set("jndi_name", "dupRes");
cr.getCommandInvocation("delete-custom-resource", context.getActionReport(), adminSubject()).parameters(parameters).execute(deleteCommand);
}
use of org.glassfish.api.admin.ParameterMap in project Payara by payara.
the class ListCustomResourcesTest method testExecuteSuccessListResource.
/**
* Test of execute method, of class ListCustomResources.
* create-custom-resource ---restype=topic --factoryclass=javax.naming.spi.ObjectFactory
* Resource1
* list-custom-resources
*/
@Test
public void testExecuteSuccessListResource() {
createCustomResource();
ParameterMap parameters = new ParameterMap();
org.glassfish.resources.admin.cli.ListCustomResources listCommand = habitat.getService(org.glassfish.resources.admin.cli.ListCustomResources.class);
cr.getCommandInvocation("list-custom-resources", context.getActionReport(), adminSubject()).parameters(parameters).execute(listCommand);
List<MessagePart> list = context.getActionReport().getTopMessagePart().getChildren();
assertEquals(origNum + 1, list.size());
List<String> listStr = new java.util.ArrayList<String>();
for (MessagePart mp : list) {
listStr.add(mp.getMessage());
}
assertTrue(listStr.contains("custom_resource1"));
assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
deleteCustomResource();
}
use of org.glassfish.api.admin.ParameterMap in project Payara by payara.
the class ListCustomResourcesTest method setUp.
@Before
public void setUp() {
parameters = new ParameterMap();
cr = habitat.getService(CommandRunner.class);
context = new AdminCommandContextImpl(LogDomains.getLogger(ListCustomResourcesTest.class, LogDomains.ADMIN_LOGGER), new PropsFileActionReporter());
Resources resources = habitat.<Domain>getService(Domain.class).getResources();
assertTrue(resources != null);
for (Resource resource : resources.getResources()) {
if (resource instanceof org.glassfish.resources.config.CustomResource) {
origNum = origNum + 1;
}
}
}
Aggregations