use of org.glassfish.api.admin.ParameterMap in project Payara by payara.
the class ListCustomResourcesTest method createCustomResource.
private void createCustomResource() {
org.glassfish.resources.admin.cli.CreateCustomResource createCommand = habitat.getService(org.glassfish.resources.admin.cli.CreateCustomResource.class);
assertTrue(createCommand != null);
ParameterMap parameters = new ParameterMap();
parameters.set("restype", "topic");
parameters.set("factoryclass", "javax.naming.spi.ObjectFactory");
parameters.set("jndi_name", "custom_resource1");
cr.getCommandInvocation("create-custom-resource", context.getActionReport(), adminSubject()).parameters(parameters).execute(createCommand);
assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
}
use of org.glassfish.api.admin.ParameterMap 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);
}
use of org.glassfish.api.admin.ParameterMap in project Payara by payara.
the class CreateJdbcResourceTest method testExecuteSuccessDefaultValues.
/**
* Test of execute method, of class CreateJdbcResource.
* asadmin create-jdbc-resource --connectionpoolid DerbyPool jdbc/alldefaults
*/
@Test
public void testExecuteSuccessDefaultValues() {
// Only pass the required option and operand
parameters = new ParameterMap();
parameters.set("connectionpoolid", "DerbyPool");
parameters.set("DEFAULT", "jdbc/alldefaults");
// Call CommandRunnerImpl.doCommand(..) to execute the command
cr.getCommandInvocation("create-jdbc-resource", context.getActionReport(), adminSubject()).parameters(parameters).execute(command);
// Check the exit code is SUCCESS
assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
// Check that the resource was created
boolean isCreated = false;
for (Resource resource : resources.getResources()) {
if (resource instanceof JdbcResource) {
JdbcResource jr = (JdbcResource) resource;
if (jr.getJndiName().equals("jdbc/alldefaults")) {
assertEquals("DerbyPool", jr.getPoolName());
assertEquals("true", jr.getEnabled());
assertNull(jr.getDescription());
isCreated = true;
logger.fine("JdbcResource config bean jdbc/alldefaults is created.");
continue;
}
}
}
assertTrue(isCreated);
logger.fine("msg: " + context.getActionReport().getMessage());
}
use of org.glassfish.api.admin.ParameterMap in project Payara by payara.
the class ListJdbcResourcesTest method testExecuteSuccessListBob.
/**
* Test of execute method, of class ListJdbcResource.
* create-jdbc-resource --connectionpoolid DerbyPool bob
* list-jdbc-resources
*/
@Test
public void testExecuteSuccessListBob() {
// 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", "bob");
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());
// 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();
assertEquals(origNum + 1, list.size());
List<String> listStr = new java.util.ArrayList();
for (MessagePart mp : list) {
listStr.add(mp.getMessage());
}
assertTrue(listStr.contains("bob"));
// Check the exit code is SUCCESS
assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
}
use of org.glassfish.api.admin.ParameterMap in project Payara by payara.
the class ListJndiResourcesTest method testExecuteSuccessListResource.
/**
* Test of execute method, of class ListJndiResources.
* create-jndi-resource ---restype=topic --factoryclass=javax.naming.spi.ObjectFactory --jndilookupname=sample_jndi
* resource
* list-jndi-resources
*/
@Test
public void testExecuteSuccessListResource() {
createJndiResource();
parameters = new ParameterMap();
org.glassfish.resources.admin.cli.ListJndiResources listCommand = habitat.getService(org.glassfish.resources.admin.cli.ListJndiResources.class);
cr.getCommandInvocation("list-jndi-resources", context.getActionReport(), adminSubject()).parameters(parameters).execute(listCommand);
List<ActionReport.MessagePart> list = context.getActionReport().getTopMessagePart().getChildren();
assertEquals(origNum + 1, list.size());
List<String> listStr = new ArrayList<String>();
for (ActionReport.MessagePart mp : list) {
listStr.add(mp.getMessage());
}
assertTrue(listStr.contains("resource"));
assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
deleteJndiResource();
}
Aggregations