org.jboss.test
Class JBossTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.jboss.test.AbstractTestCase
              extended by org.jboss.test.AbstractTestCaseWithSetup
                  extended by org.jboss.test.JBossTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
JBossIIOPTestCase

public class JBossTestCase
extends AbstractTestCaseWithSetup

This is the standard base test case for jboss junit test cases. It supplies access to jboss 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).

Version:
$Revision: 58499 $
Author:
David Jencks, Scott.Stark@jboss.org

Field Summary
protected  JBossTestServices delegate
           
protected static Exception deploymentException
          Saved exception from deployment.
protected  org.jboss.logging.Logger log
          Local variable for backward compatibility
 
Constructor Summary
JBossTestCase(String name)
          Constructor for the JBossTestCase object
 
Method Summary
protected  void deploy(String name)
          Deploy a package with the main deployer.
protected  void flushAuthCache()
           
protected  void flushAuthCache(String domain)
           
protected  int getBeanCount()
           
static AbstractTestDelegate getDelegate(Class clazz)
          Overriden to return JBossTestServices as the test delegate.
protected  javax.management.ObjectName getDeployerName()
          Gets the DeployerName attribute of the JBossTestCase object
static junit.framework.Test getDeploySetup(Class clazz, String jarName)
           
static junit.framework.Test getDeploySetup(Class clazz, junit.framework.Test test, String jarNames)
          Get a JBossTestSetup that does login and deployment in setUp/tearDown
static junit.framework.Test getDeploySetup(junit.framework.Test test, String jarName)
           
protected  URL 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()
           
 org.jboss.logging.Logger getLog()
          Overriden to restore the old behavior where the log was initialized post ctor rather than post setUp.
protected  String getResourceURL(String resource)
          Get a URL string to a resource in the testsuite/output/resources dir.
protected  javax.management.MBeanServerConnection getServer()
          Gets the Server attribute of the JBossTestCase object
 String getServerHost()
          Get the JBoss server host from system property "jbosstest.server.host" 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)
          Redeploy a package with the main deployer.
 void resetDelegate()
           
protected  void restartDBPool()
          Restart the connection pool associated with the DefaultDS
 void serverFound()
          This just checks the server is there...
protected  void setUp()
          Create a delegate by calling AbstractTestDelegate.getDelegate(clazz) to allow for a test specific delegate.
protected  void sleep(long interval)
           
protected  void tearDown()
          This method then delegates to the AbstractTestDelegate.tearDown method.
protected  void undeploy(String name)
          Undeploy a package with the main deployer.
 
Methods inherited from class org.jboss.test.AbstractTestCaseWithSetup
enableTrace, getDelegate, suite
 
Methods inherited from class org.jboss.test.AbstractTestCase
assertEmpty, assertEmpty, assertEquals, assertEquals, assertEquals, assertEquals, checkThrowable, configureLogging, deserialize, findResource, getResource, serialize
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, 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

deploymentException

protected static Exception deploymentException
Saved exception from deployment.


delegate

protected JBossTestServices delegate

log

protected org.jboss.logging.Logger log
Local variable for backward compatibility

Constructor Detail

JBossTestCase

public JBossTestCase(String name)
Constructor for the JBossTestCase object

Parameters:
name - Test case name
Method Detail

getDelegate

public static AbstractTestDelegate getDelegate(Class clazz)
                                        throws Exception
Overriden to return JBossTestServices as the test delegate.

Throws:
Exception

setUp

protected void setUp()
              throws Exception
Create a delegate by calling AbstractTestDelegate.getDelegate(clazz) to allow for a test specific delegate. This method then delegates to the AbstractTestDelegate.setUp method.

Overrides:
setUp in class AbstractTestCaseWithSetup
Throws:
Exception

tearDown

protected void tearDown()
                 throws Exception
This method then delegates to the AbstractTestDelegate.tearDown method.

Overrides:
tearDown in class AbstractTestCaseWithSetup
Throws:
Exception

getLog

public org.jboss.logging.Logger getLog()
Overriden to restore the old behavior where the log was initialized post ctor rather than post setUp.

Overrides:
getLog in class AbstractTestCaseWithSetup
Returns:
the log

resetDelegate

public void resetDelegate()

serverFound

public void serverFound()
                 throws Exception
This just checks the server is there... so you should get at least one success! Also checks if an exception occurred during deployment, and throws any such exception from here.

Throws:
Exception - Description of Exception

getInitialContext

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

Returns:
The InitialContext value
Throws:
Exception - for any error

getServer

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

Returns:
The Server value
Throws:
Exception - for any error

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 URL 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 resource)
                         throws MalformedURLException
Get a URL string to a resource in the testsuite/output/resources dir. This relies on the output/resources directory being in the testcase classpath.

Parameters:
resource - the resource name
Returns:
the string version of the resource url
Throws:
MalformedURLException - for an invalid url

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
Redeploy 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

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

getDeploySetup

public static junit.framework.Test getDeploySetup(Class clazz,
                                                  junit.framework.Test test,
                                                  String jarNames)
                                           throws Exception
Get a JBossTestSetup that does login and deployment in setUp/tearDown

Parameters:
test - a Test
jarNames - is a comma seperated list of deployments
Returns:
the wrapping test that does the setup
Throws:
Exception - for any error

getDeploySetup

public static junit.framework.Test getDeploySetup(junit.framework.Test test,
                                                  String jarName)
                                           throws Exception
Throws:
Exception

getDeploySetup

public static junit.framework.Test getDeploySetup(Class clazz,
                                                  String jarName)
                                           throws Exception
Throws:
Exception

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.server.host" This defaults to "localhost"

Returns:
the host name

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

sleep

protected void sleep(long interval)
              throws InterruptedException
Throws:
InterruptedException


Copyright © 2004 JBoss Inc. All Rights Reserved.