[jboss-cvs] system2/src/tests/org/jboss/test/profileservice/test ...
Scott Stark
scott.stark at jboss.com
Fri Jul 14 00:27:25 EDT 2006
User: starksm
Date: 06/07/14 00:27:25
Added: src/tests/org/jboss/test/profileservice/test
DataSourceTestCase.properties SimplePSTestCase.java
DataSourceTestCase.java SimplePSTestCase.properties
Log:
Move profileservice tests to the server module
Revision Changes Path
1.1 date: 2006/07/14 04:27:25; author: starksm; state: Exp;system2/src/tests/org/jboss/test/profileservice/test/DataSourceTestCase.properties
Index: DataSourceTestCase.properties
===================================================================
test.Permission.0=java.util.PropertyPermission, jbosstest.deploy.dir, read
1.1 date: 2006/07/14 04:27:25; author: starksm; state: Exp;system2/src/tests/org/jboss/test/profileservice/test/SimplePSTestCase.java
Index: SimplePSTestCase.java
===================================================================
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.test.profileservice.test;
import java.util.Set;
import org.jboss.test.kernel.AbstractKernelTest;
import org.jboss.test.profileservice.support.Simple1PSBootstrap;
import org.jboss.dependency.spi.DependencyInfo;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.registry.KernelRegistry;
import org.jboss.kernel.spi.registry.KernelRegistryEntry;
/**
* Test of bootstrapping the kernel using a profile service
*
* @author Scott.Stark at jboss.org
* @version $Revision$
*/
public class SimplePSTestCase extends AbstractKernelTest
{
public SimplePSTestCase(String name)
{
super(name);
}
protected Kernel bootstrap() throws Throwable
{
Simple1PSBootstrap bootstrap = new Simple1PSBootstrap(getName());
bootstrap.run();
configureLoggingAfterBootstrap();
return bootstrap.getKernel();
}
public void testP0() throws Throwable
{
Kernel kernel = bootstrap();
KernelRegistry registry = kernel.getRegistry();
KernelRegistryEntry ns = registry.getEntry("TheNamingService");
assertNotNull("TheNamingService", ns);
DependencyInfo di = ns.getDependencyInfo();
Set dependsOnMe = di.getDependsOnMe(null);
assertEquals("NS:DependsOnMe.size == 2", 2, dependsOnMe.size());
KernelRegistryEntry txMgr = registry.getEntry("TheTxMgr");
assertNotNull("TheTxMgr", txMgr);
di = txMgr.getDependencyInfo();
dependsOnMe = di.getDependsOnMe(null);
assertEquals("TX:DependsOnMe.size == 1", 1, dependsOnMe.size());
KernelRegistryEntry jcaMgr = registry.getEntry("TheJCAMgr");
assertNotNull("TheJCAMgr", jcaMgr);
}
public void testP1() throws Throwable
{
}
}
1.1 date: 2006/07/14 04:27:25; author: starksm; state: Exp;system2/src/tests/org/jboss/test/profileservice/test/DataSourceTestCase.java
Index: DataSourceTestCase.java
===================================================================
package org.jboss.test.profileservice.test;
import org.jboss.test.kernel.AbstractKernelTest;
import org.jboss.test.profileservice.support.Simple1PSBootstrap;
import org.jboss.test.profileservice.support.Simple2PSBootstrap;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.registry.KernelRegistry;
import org.jboss.kernel.spi.registry.KernelRegistryEntry;
import org.jboss.profileservice.spi.*;
import org.jboss.deployers.spi.Deployment;
import org.jboss.deployers.spi.management.ManagedObject;
/**
* Test of deploying a couple of different DataSources using the profile service
*
* @author ccrouch at jboss.org
* @version $Revision$
*/
public class DataSourceTestCase extends AbstractKernelTest
{
public DataSourceTestCase(String name)
{
super(name);
}
public void testDataSource() throws Throwable
{
Simple2PSBootstrap bootstrap = new Simple2PSBootstrap(getName());
bootstrap.run();
configureLoggingAfterBootstrap();
ProfileService ps = bootstrap.getProfileService();
// shouldn't this be getName() instead of "default"?
ProfileKey profileKey = new ProfileKey("default");
Profile profile = ps.getProfile(profileKey);
String deploymentName = "notxDS";
Deployment deployment = profile.getDeployment(deploymentName);
ManagedObject mgdObj = deployment.getManagedObject();
assertNotNull(mgdObj);
// need a method for retrieving ManagedObjects by "type" not just name
// need a method to retrieve ManagedObjects without going through the Deployment, double check class diagram
// since we may have this already
int found = 0;
for(PropertyInfo prop : mgdObj.getProperties()){
if (prop.getName().equals("jndiName"))
{
// no sensible default can be specified for jndiName...
assertEquals(null, prop.getFieldValue("defaultValue"));
// but the field is definitely required
assertEquals(Boolean.TRUE, prop.getFieldValue("org.jboss.profileservice.requiredNotEmpty"));
// just use a non-localized label...
assertEquals("JNDI Name", prop.getFieldValue("org.jboss.profileservice.label"));
// and description
assertTrue(((String)prop.getFieldValue("org.jboss.profileservice.description")).startsWith("The name the Datasource"));
// we would have to construct a UI widget to accommodate a text field...
assertEquals(SimpleType.STRING, prop.getOpenType());
// approximately 30chars long
assertEquals(new Integer(30), prop.getFieldValue("org.jboss.profileservice.typicalLength"));
found++;
}
else if (prop.getName().equals("useJavaContext"))
{
// we know our widget is going to have at most three states (null, true, false)...
assertEquals(SimpleType.BOOLEAN, prop.getOpenType());
// since its required we know its only going to be two (true, false)
assertEquals(Boolean.TRUE, prop.getFieldValue("org.jboss.profileservice.requiredNotEmpty"));
// and we'll default our widget to being checked for example
assertEquals(Boolean.TRUE, prop.getFieldValue("defaultValue"));
found++;
}
assertNotNull(prop.getName());
}
assertTrue(found==2);
Kernel kernel = bootstrap.getKernel();
KernelRegistry registry = kernel.getRegistry();
// check some of the beans got deployed
KernelRegistryEntry defaultConnFac = registry.getEntry("name=DefaultDS,service=ManagedConnectionFactory");
assertNotNull("name=DefaultDS,service=ManagedConnectionFactory", defaultConnFac);
KernelRegistryEntry noTxConnMgr = registry.getEntry("name=notxDS,service=NoTxCM");
assertNotNull("name=notxDS,service=NoTxCM", noTxConnMgr);
}
}
1.1 date: 2006/07/14 04:27:25; author: starksm; state: Exp;system2/src/tests/org/jboss/test/profileservice/test/SimplePSTestCase.properties
Index: SimplePSTestCase.properties
===================================================================
test.Permission.0=java.util.PropertyPermission, jbosstest.deploy.dir, read
More information about the jboss-cvs-commits
mailing list