org.jboss.test
Class JBossTestSetup

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.extensions.TestDecorator
          extended byjunit.extensions.TestSetup
              extended byorg.jboss.test.JBossTestSetup
All Implemented Interfaces:
junit.framework.Test

public class JBossTestSetup
extends junit.extensions.TestSetup

This is a TestSetup class for jboss junit test cases that provides the jboss test services. It supplies access to log4j logging, the jboss jmx server, jndi, and a method for deploying ejb packages. You may supply the name of the machine the jboss server is on with the system property jbosstest.server.name (default getInetAddress().getLocalHost().getHostName()) and the directory for deployable packages with the system property jbosstest.deploy.dir (default ../lib). Should be sublassed to derive junit support for specific services integrated into JBoss.

Version:
$Revision: 1.1 $
Author:
David Jencks, Christoph G. Jung

Field Summary
protected  JBossTestServices delegate
           
 
Fields inherited from class junit.extensions.TestDecorator
fTest
 
Constructor Summary
JBossTestSetup(junit.framework.Test test)
          Constructor for the JBossTestCase object
 
Method Summary
protected  JBossTestServices createTestServices()
           
protected  void deploy(String name)
          Deploy a package with the main deployer.
protected  void flushAuthCache()
           
protected  void flushAuthCache(String domain)
           
protected  int getBeanCount()
           
protected  javax.management.ObjectName getDeployerName()
          Gets the DeployerName attribute of the JBossTestCase object
protected  String getDeployURL(String filename)
          Returns the deployment directory to use.
protected  InitialContext getInitialContext()
          Gets the InitialContext attribute of the JBossTestCase object
protected  int getIterationCount()
           
protected  String getJndiInitFactory()
           
protected  String getJndiURL()
           
protected  org.apache.log4j.Category getLog()
          Gets the Log attribute of the JBossTestCase object
protected  String getResourceURL(String path)
           
protected  javax.management.MBeanServerConnection getServer()
          Gets the Server attribute of the JBossTestCase object
 String getServerHost()
          Get the JBoss server host from system property "jbosstest.host.name" This defaults to "localhost"
protected  int getThreadCount()
           
protected  Object invoke(javax.management.ObjectName name, String method, Object[] args, String[] sig)
          invoke wraps an invoke call to the mbean server in a lot of exception unwrapping.
protected  void redeploy(String name)
           
protected  void restartDBPool()
          Restart the connection pool associated with the DefaultDS
protected  void undeploy(String name)
          Undeploy a package with the main deployer.
 
Methods inherited from class junit.extensions.TestSetup
run, setUp, tearDown
 
Methods inherited from class junit.extensions.TestDecorator
basicRun, countTestCases, getTest, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

delegate

protected JBossTestServices delegate
Constructor Detail

JBossTestSetup

public JBossTestSetup(junit.framework.Test test)
               throws Exception
Constructor for the JBossTestCase object

Method Detail

createTestServices

protected JBossTestServices createTestServices()

getInitialContext

protected InitialContext getInitialContext()
                                    throws Exception
Gets the InitialContext attribute of the JBossTestCase object

Returns:
The InitialContext value
Throws:
Exception

getServer

protected javax.management.MBeanServerConnection getServer()
                                                    throws Exception
Gets the Server attribute of the JBossTestCase object

Returns:
The Server value
Throws:
Exception

getLog

protected org.apache.log4j.Category getLog()
Gets the Log attribute of the JBossTestCase object

Returns:
The Log value

getDeployerName

protected javax.management.ObjectName getDeployerName()
                                               throws javax.management.MalformedObjectNameException
Gets the DeployerName attribute of the JBossTestCase object

Returns:
The DeployerName value
Throws:
javax.management.MalformedObjectNameException - Description of Exception

getDeployURL

protected String getDeployURL(String filename)
                       throws MalformedURLException
Returns the deployment directory to use. This does it's best to figure out where you are looking. If you supply a complete url, it returns it. Otherwise, it looks for jbosstest.deploy.dir or if missing ../lib. Then it tries to construct a file url or a url.

Parameters:
filename - name of the file/url you want
Returns:
A more or less canonical string for the url.
Throws:
MalformedURLException - Description of Exception

getResourceURL

protected String getResourceURL(String path)

invoke

protected Object invoke(javax.management.ObjectName name,
                        String method,
                        Object[] args,
                        String[] sig)
                 throws Exception
invoke wraps an invoke call to the mbean server in a lot of exception unwrapping.

Parameters:
name - ObjectName of the mbean to be called
method - mbean method to be called
args - Object[] of arguments for the mbean method.
sig - String[] of types for the mbean methods parameters.
Returns:
Object returned by mbean method invocation.
Throws:
Exception - Description of Exception

deploy

protected void deploy(String name)
               throws Exception
Deploy a package with the main deployer. The supplied name is interpreted as a url, or as a filename in jbosstest.deploy.lib or ../lib.

Parameters:
name - filename/url of package to deploy.
Throws:
Exception - Description of Exception

redeploy

protected void redeploy(String name)
                 throws Exception
Throws:
Exception

undeploy

protected void undeploy(String name)
                 throws Exception
Undeploy a package with the main deployer. The supplied name is interpreted as a url, or as a filename in jbosstest.deploy.lib or ../lib.

Parameters:
name - filename/url of package to undeploy.
Throws:
Exception - Description of Exception

flushAuthCache

protected void flushAuthCache()
                       throws Exception
Throws:
Exception

flushAuthCache

protected void flushAuthCache(String domain)
                       throws Exception
Throws:
Exception

restartDBPool

protected void restartDBPool()
                      throws Exception
Restart the connection pool associated with the DefaultDS

Throws:
Exception - on failure

getJndiURL

protected String getJndiURL()

getJndiInitFactory

protected String getJndiInitFactory()

getThreadCount

protected int getThreadCount()

getIterationCount

protected int getIterationCount()

getBeanCount

protected int getBeanCount()

getServerHost

public String getServerHost()
Get the JBoss server host from system property "jbosstest.host.name" This defaults to "localhost"



Copyright © 2002 JBoss Group, LLC. All Rights Reserved.