org.jboss.test
Class JBossTestServices

java.lang.Object
  extended byorg.jboss.test.JBossTestServices
Direct Known Subclasses:
JBossTestClusteredServices (src)

public class JBossTestServices
extends java.lang.Object

This is provides services for jboss junit test cases and TestSetups. It supplies access to log4j logging, the jboss jmx server, jndi, and a method for deploying ejb packages. You may supply the JNDI name under which the RMIAdaptor interface is located via the system property jbosstest.server.name default (jmx/rmi/RMIAdaptor) and the directory for deployable packages with the system property jbosstest.deploy.dir (default ../lib). Should be subclassed to derive junit support for specific services integrated into jboss.


Field Summary
static int DEFAULT_BEANCOUNT
           
static int DEFAULT_ITERATIONCOUNT
           
static java.lang.String DEFAULT_LOGIN_CONFIG
           
static java.lang.String DEFAULT_PASSWORD
           
static int DEFAULT_THREADCOUNT
           
static java.lang.String DEFAULT_USERNAME
           
static java.lang.String DEPLOYER_NAME
           
protected  javax.naming.InitialContext initialContext
           
protected  java.util.Hashtable jndiEnv
           
protected  javax.security.auth.login.LoginContext lc
           
protected  Category log
           
protected  RMIAdaptor (src) server
           
 
Constructor Summary
JBossTestServices(java.lang.String className)
          Constructor for the JBossTestCase object
 
Method Summary
 void deploy(java.lang.String name)
          Deploy a package with the main deployer.
protected  java.lang.String getDeployURL(java.lang.String filename)
          Returns the deployment directory to use.
 RMIAdaptor (src) getServer()
          Gets the Server attribute of the JBossTestCase object
 java.lang.String getServerHost()
          Get the JBoss server host from system property "jbosstest.server.host" This defaults to "localhost"
 void init()
          Lookup the RMIAdaptor interface from JNDI.
protected  java.lang.Object invoke(ObjectName (src)  name, java.lang.String method, java.lang.Object[] args, java.lang.String[] sig)
          invoke wraps an invoke call to the mbean server in a lot of exception unwrapping.
protected  java.lang.Object invoke(RMIAdaptor (src)  server, ObjectName (src)  name, java.lang.String method, java.lang.Object[] args, java.lang.String[] sig)
           
 void login()
          Do a JAAS login with the current username, password and login config.
 void logout()
           
 void redeploy(java.lang.String name)
           
 void reinit()
           
 void setUp()
          The JUnit setup method
 void tearDown()
          The teardown method for JUnit
 void undeploy(java.lang.String name)
          Undeploy a package with the main deployer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEPLOYER_NAME

public static final java.lang.String DEPLOYER_NAME
See Also:
Constant Field Values (src)

DEFAULT_USERNAME

public static final java.lang.String DEFAULT_USERNAME
See Also:
Constant Field Values (src)

DEFAULT_PASSWORD

public static final java.lang.String DEFAULT_PASSWORD
See Also:
Constant Field Values (src)

DEFAULT_LOGIN_CONFIG

public static final java.lang.String DEFAULT_LOGIN_CONFIG
See Also:
Constant Field Values (src)

DEFAULT_THREADCOUNT

public static final int DEFAULT_THREADCOUNT
See Also:
Constant Field Values (src)

DEFAULT_ITERATIONCOUNT

public static final int DEFAULT_ITERATIONCOUNT
See Also:
Constant Field Values (src)

DEFAULT_BEANCOUNT

public static final int DEFAULT_BEANCOUNT
See Also:
Constant Field Values (src)

server

protected RMIAdaptor (src)  server

log

protected Category log

initialContext

protected javax.naming.InitialContext initialContext

jndiEnv

protected java.util.Hashtable jndiEnv

lc

protected javax.security.auth.login.LoginContext lc
Constructor Detail

JBossTestServices

public JBossTestServices(java.lang.String className)
Constructor for the JBossTestCase object

Parameters:
className - Test case name
Method Detail

setUp

public void setUp()
           throws java.lang.Exception
The JUnit setup method

Throws:
java.lang.Exception

tearDown

public void tearDown()
              throws java.lang.Exception
The teardown method for JUnit

Throws:
java.lang.Exception

getServer

public RMIAdaptor (src)  getServer()
                     throws java.lang.Exception
Gets the Server attribute of the JBossTestCase object

Returns:
The Server value
Throws:
java.lang.Exception

getDeployURL

protected java.lang.String getDeployURL(java.lang.String filename)
                                 throws java.net.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:
java.net.MalformedURLException - Description of Exception

invoke

protected java.lang.Object invoke(ObjectName (src)  name,
                                  java.lang.String method,
                                  java.lang.Object[] args,
                                  java.lang.String[] sig)
                           throws java.lang.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:
java.lang.Exception - Description of Exception

invoke

protected java.lang.Object invoke(RMIAdaptor (src)  server,
                                  ObjectName (src)  name,
                                  java.lang.String method,
                                  java.lang.Object[] args,
                                  java.lang.String[] sig)
                           throws java.lang.Exception
Throws:
java.lang.Exception

deploy

public void deploy(java.lang.String name)
            throws java.lang.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:
java.lang.Exception - Description of Exception

redeploy

public void redeploy(java.lang.String name)
              throws java.lang.Exception
Throws:
java.lang.Exception

login

public void login()
           throws java.lang.Exception
Do a JAAS login with the current username, password and login config.

Throws:
java.lang.Exception

logout

public void logout()

undeploy

public void undeploy(java.lang.String name)
              throws java.lang.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:
java.lang.Exception - Description of Exception

init

public void init()
          throws java.lang.Exception
Lookup the RMIAdaptor interface from JNDI. By default this is bound under "jmx/rmi/RMIAdaptor" and this may be overriden with the jbosstest.server.name system property.

Throws:
java.lang.Exception

reinit

public void reinit()
            throws java.lang.Exception
Throws:
java.lang.Exception

getServerHost

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