[jboss-cvs] JBossAS SVN: r59761 - trunk/testsuite/src/main/org/jboss/test/profileservice/test.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jan 18 07:04:46 EST 2007
Author: scott.stark at jboss.org
Date: 2007-01-18 07:04:46 -0500 (Thu, 18 Jan 2007)
New Revision: 59761
Modified:
trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
Log:
Update the add data source usecase
Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java 2007-01-18 12:04:09 UTC (rev 59760)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java 2007-01-18 12:04:46 UTC (rev 59761)
@@ -22,6 +22,7 @@
package org.jboss.test.profileservice.test;
import java.util.Collection;
+import java.util.Map;
import java.util.Set;
import javax.naming.InitialContext;
@@ -29,6 +30,7 @@
import org.jboss.deployers.spi.management.DeploymentTemplateInfo;
import org.jboss.deployers.spi.management.ManagementView;
import org.jboss.managed.api.ManagedProperty;
+import org.jboss.profileservice.spi.NoSuchProfileException;
import org.jboss.profileservice.spi.Profile;
import org.jboss.profileservice.spi.ProfileKey;
import org.jboss.profileservice.spi.ProfileService;
@@ -62,16 +64,34 @@
}
/**
+ * Basic test to validate NoSuchProfileException is thrown for
+ * a ProfileKey that does not map to a profile.
+ *
+ */
+ public void testNoSuchProfileException()
+ throws Exception
+ {
+ ManagementView mgtView = getManagementView();
+ ProfileKey badKey = new ProfileKey("no-such-profile");
+ try
+ {
+ mgtView.getDeploymentNames(badKey);
+ }
+ catch(NoSuchProfileException e)
+ {
+ assertTrue("NoSuchProfileException", e.getMessage().contains("no-such-profile"));
+ }
+ }
+
+ /**
* Test that one can query for deployments of type jca-ds to
* obtain data source deployments.
*/
public void testDataSourceType()
throws Exception
{
- InitialContext ctx = super.getInitialContext();
- ProfileService ps = (ProfileService) ctx.lookup("ProfileService");
+ ManagementView mgtView = getManagementView();
ProfileKey key = new ProfileKey("default");
- ManagementView mgtView = ps.getViewManager();
Set<String> names = mgtView.getDeploymentNamesForType(key, "jca-ds");
log.info("jca-ds names: "+names);
assertTrue("names.size > 0 ", names.size() > 0);
@@ -83,16 +103,37 @@
*/
public void testAddDataSource() throws Exception
{
- InitialContext ctx = super.getInitialContext();
- ProfileService ps = (ProfileService) ctx.lookup("ProfileService");
+ ManagementView mgtView = getManagementView();
ProfileKey defaultKey = new ProfileKey("default");
- ManagementView mgtView = ps.getViewManager();
log.info("Templates: "+mgtView.getTemplateNames());
DeploymentTemplateInfo dsInfo = mgtView.getTemplate("DsXmlDataSourceTemplate");
- Set<ManagedProperty> props = dsInfo.getProperties();
+ Map<String, ManagedProperty> props = dsInfo.getProperties();
log.info("ManagedPropertys: "+props);
+ ManagedProperty jndiName = props.get("jndi-name");
+ jndiName.setValue("TestDS");
+ ManagedProperty connURL = props.get("connection-url");
+ connURL.setValue("jdbc:hsqldb:.");
+ ManagedProperty username = props.get("user-name");
+ username.setValue("sa");
+ ManagedProperty password = props.get("password");
+ password.setValue("");
+
mgtView.applyTemplate(defaultKey, DeploymentPhase.APPLICATION,
"testAddDataSource", dsInfo);
}
+
+ /**
+ * Obtain the ProfileService.ManagementView
+ * @return
+ * @throws Exception
+ */
+ protected ManagementView getManagementView()
+ throws Exception
+ {
+ InitialContext ctx = super.getInitialContext();
+ ProfileService ps = (ProfileService) ctx.lookup("ProfileService");
+ ManagementView mgtView = ps.getViewManager();
+ return mgtView;
+ }
}
More information about the jboss-cvs-commits
mailing list