[jboss-cvs] JBossAS SVN: r68021 - trunk/testsuite/src/main/org/jboss/test/profileservice/test.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Dec 7 05:19:33 EST 2007
Author: alex.loubyansky at jboss.com
Date: 2007-12-07 05:19:33 -0500 (Fri, 07 Dec 2007)
New Revision: 68021
Modified:
trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
Log:
JBAS-4671 added a test for XADataSource
Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java 2007-12-07 10:11:05 UTC (rev 68020)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java 2007-12-07 10:19:33 UTC (rev 68021)
@@ -25,6 +25,7 @@
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import java.util.ArrayList;
import javax.naming.InitialContext;
import junit.framework.Test;
@@ -46,6 +47,7 @@
import org.jboss.profileservice.spi.ProfileService;
import org.jboss.test.JBossTestCase;
import org.jboss.virtual.VFS;
+import org.jboss.resource.metadata.mcf.XAConnectionPropertyMetaData;
/** Test of using ProfileService
@@ -78,6 +80,8 @@
suite.addTest(new ProfileServiceUnitTestCase("testDefaultDSOps"));
suite.addTest(new ProfileServiceUnitTestCase("testAddDataSource"));
suite.addTest(new ProfileServiceUnitTestCase("testRemoveDataSource"));
+ suite.addTest(new ProfileServiceUnitTestCase("testAddXADataSource"));
+ suite.addTest(new ProfileServiceUnitTestCase("testRemoveXADataSource"));
return suite;
}
@@ -357,17 +361,16 @@
}
/**
- * Test adding a new hsql DataSource deployment
- * TODO: JBAS-4671
+ * Test adding a new hsql DataSource deployment (JBAS-4671)
* @throws Exception
*/
public void testAddDataSource() throws Exception
{
ManagementView mgtView = getManagementView();
- log.info("Templates: "+mgtView.getTemplateNames());
+ log.trace("Templates: "+mgtView.getTemplateNames());
DeploymentTemplateInfo dsInfo = mgtView.getTemplate("DsDataSourceTemplate");
Map<String, ManagedProperty> props = dsInfo.getProperties();
- log.info("ManagedPropertys: "+props);
+ log.trace("ManagedPropertys: "+props);
ManagedProperty jndiName = props.get("jndi-name");
jndiName.setValue("TestHqldbDS");
@@ -387,12 +390,65 @@
public void testRemoveDataSource()
throws Exception
{
+ removeDeployment("testHqldbDS-ds.xml");
+ }
+
+ /**
+ * Test adding a new hsql DataSource deployment
+ * @throws Exception
+ */
+ public void testAddXADataSource() throws Exception
+ {
ManagementView mgtView = getManagementView();
- Set<String> names = mgtView.getMatchingDeploymentName("testHqldbDS-ds.xml");
+ DeploymentTemplateInfo dsInfo = mgtView.getTemplate("DsDataSourceTemplate");
+ Map<String, ManagedProperty> props = dsInfo.getProperties();
+
+ ManagedProperty jndiName = props.get("jndi-name");
+ jndiName.setValue("TestHqldbXADS");
+ ManagedProperty dsType = props.get("datasource-type");
+ dsType.setValue("xa-datasource");
+
+ ManagedProperty driverClass = props.get("xa-datasource-class");
+ driverClass.setValue("org.hsqldb.jdbcDriver");
+
+ ManagedProperty xaDsProps = props.get("xa-datasource-properties");
+ ArrayList<XAConnectionPropertyMetaData> xaPropsValue = new ArrayList<XAConnectionPropertyMetaData>();
+ XAConnectionPropertyMetaData xaPropMD = new XAConnectionPropertyMetaData();
+ xaPropMD.setName("URL");
+ xaPropMD.setValue("jdbc:hsqldb:.");
+ xaPropsValue.add(xaPropMD);
+ xaPropMD = new XAConnectionPropertyMetaData();
+ xaPropMD.setName("User");
+ xaPropMD.setValue("sa");
+ xaPropsValue.add(xaPropMD);
+ xaPropMD = new XAConnectionPropertyMetaData();
+ xaPropMD.setName("Password");
+ xaPropMD.setValue("");
+ xaPropsValue.add(xaPropMD);
+ xaDsProps.setValue(xaPropsValue);
+
+ mgtView.applyTemplate(DeploymentPhase.APPLICATION, "testHqldbXADS", dsInfo);
+ mgtView.process();
+ }
+
+ /**
+ * removes the XADataSource created in the testAddXADataSource
+ * @throws Exception
+ */
+ public void testRemoveXADataSource()
+ throws Exception
+ {
+ removeDeployment("testHqldbXADS-ds.xml");
+ }
+
+ protected void removeDeployment(String deployment)
+ throws Exception
+ {
+ ManagementView mgtView = getManagementView();
+ Set<String> names = mgtView.getMatchingDeploymentName(deployment);
assertEquals("1 matching name", 1, names.size());
String deploymentName = names.iterator().next();
- mgtView.removeDeployment(deploymentName,
- DeploymentPhase.APPLICATION);
+ mgtView.removeDeployment(deploymentName, DeploymentPhase.APPLICATION);
mgtView.process();
}
More information about the jboss-cvs-commits
mailing list