private void createDatasource(String dsName, String min, String max)
throws Exception
{
LOG.info("######################## Running testCreateService()");
PluginContainer pc = PluginContainer.getInstance();
ResourceFactoryAgentService resourceFactoryAgentService = pc.getResourceFactoryAgentService();
Resource platform = discoverPlatform();
// There should only be one server.
Resource as5Server = findServer(SERVER_NAME, platform);
ResourceType dsType =
pc.getPluginManager().getMetadataManager().getType("Local Transaction", ResourceCategory.SERVICE);
//Puts a String, Long String, Integer, Boolean, and Map into the DS config
Configuration config = new Configuration();
config.put(new PropertySimple("jndi-name", dsName));
config.put(new PropertySimple("connection-url", "jdbc:hsqldb:."));
config.put(new PropertySimple("user-name", "userJoe"));
config.put(new PropertySimple("password", "password"));
// Min and Max are not being put into the xml file.
config.put(new PropertySimple("min-pool-size", min));
config.put(new PropertySimple("max-pool-size", max));
config.put(new PropertySimple("driver-class", "org.hsqldb.jdbcDriver"));
config.put(new PropertySimple("share-prepared-statements", false));
config.put(new PropertySimple("prepared-statement-cache-size", max));
config.put(new PropertySimple("new-connection-sql", "Select count(*) from dual;"));
PropertyMap connectionProperies = new PropertyMap("connectionProperties");
PropertySimple simple1 = new PropertySimple("ConnProp1", "FirstValue");
PropertySimple simple2 = new PropertySimple("ConnProp2", "SecondValue");
connectionProperies.put(simple1);
connectionProperies.put(simple2);
config.put(connectionProperies);
CreateResourceRequest request = new CreateResourceRequest(1, as5Server.getId(), "newResource", dsType.getName(), dsType.getPlugin(), null, config);
resourceFactoryAgentService.executeCreateResourceImmediately(request);
platform = discoverPlatform();
Resource testDs = findService(dsName, SERVER_NAME, platform);
pc = PluginContainer.getInstance();
ConfigurationAgentService configService = pc.getConfigurationAgentService();
Configuration configuration = configService.loadResourceConfiguration(testDs.getId());
assert configuration.getSimple("jndi-name").getStringValue().equals(dsName) : "Property jndi-name was incorrect";
assert configuration.getSimple("connection-url").getStringValue().equals("jdbc:hsqldb:hsql://${jboss.bind.address}:1701")