JBoss Test 1.1.9.GA-redhat-2

org.jboss.test
Class JBossTestServices

java.lang.Object
  extended by org.jboss.test.AbstractTestDelegate
      extended by org.jboss.test.JBossTestServices
Direct Known Subclasses:
JBossTestClusteredServices

public class JBossTestServices
extends AbstractTestDelegate

This is provides services for jboss junit test cases and TestSetups. It supplies access to jboss 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 output/lib). Should be subclassed to derive junit support for specific services integrated into jboss.

Version:
$Revision: 91625 $
Author:
David Jencks, Christoph G. Jung, Scott Stark

Field Summary
static int DEFAULT_BEANCOUNT
           
static int DEFAULT_ITERATIONCOUNT
           
static String DEFAULT_LOGIN_CONFIG
           
static String DEFAULT_PASSWORD
           
static int DEFAULT_THREADCOUNT
           
static String DEFAULT_USERNAME
           
static String DEPLOYER_NAME
           
protected  InitialContext initialContext
           
protected  Hashtable jndiEnv
           
protected  LoginContext lc
           
protected  MBeanServerConnection server
           
 
Fields inherited from class org.jboss.test.AbstractTestDelegate
clazz, enableSecurity, log, logging, policy, securityPolicyName
 
Constructor Summary
JBossTestServices(Class clazz)
           
JBossTestServices(String className)
          Constructor for the JBossTestCase object
 
Method Summary
 void deploy(String name)
          Deploy a package with the main deployer.
protected  URL getDeployURL(String filename)
          Returns the deployment directory to use.
 InitialContext getInitialContext()
          Gets the InitialContext attribute of the JBossTestCase object
 MBeanServerConnection getServer()
          Gets the Server attribute of the JBossTestCase object
 String getServerHost()
          Returns the JBoss server host from system property "jbosstest.server.host" This defaults to "localhost"
 void init()
          Initializes the InitialContext if not set.
protected  Object invoke(MBeanServerConnection server, ObjectName name, String method, Object[] args, String[] sig)
           
protected  Object invoke(ObjectName name, String method, Object[] args, String[] sig)
          invoke wraps an invoke call to the mbean server in a lot of exception unwrapping.
 void login()
          Do a JAAS login with the current username, password and login config.
 void logout()
           
 void redeploy(String name)
           
 void reinit()
          Re-initializes the InitialContext.
 void setUp()
          The JUnit setup method
 void tearDown()
          The teardown method for JUnit
 void undeploy(String name)
          Undeploy a package with the main deployer.
 
Methods inherited from class org.jboss.test.AbstractTestDelegate
enableTrace, getDelegate, getLog, log, setUpLogging, setUpSecurity, tearDownLogging, tearDownSecurity
 
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 String DEPLOYER_NAME
See Also:
Constant Field Values

DEFAULT_USERNAME

public static final String DEFAULT_USERNAME
See Also:
Constant Field Values

DEFAULT_PASSWORD

public static final String DEFAULT_PASSWORD
See Also:
Constant Field Values

DEFAULT_LOGIN_CONFIG

public static final String DEFAULT_LOGIN_CONFIG
See Also:
Constant Field Values

DEFAULT_THREADCOUNT

public static final int DEFAULT_THREADCOUNT
See Also:
Constant Field Values

DEFAULT_ITERATIONCOUNT

public static final int DEFAULT_ITERATIONCOUNT
See Also:
Constant Field Values

DEFAULT_BEANCOUNT

public static final int DEFAULT_BEANCOUNT
See Also:
Constant Field Values

server

protected MBeanServerConnection server

initialContext

protected InitialContext initialContext

jndiEnv

protected Hashtable jndiEnv

lc

protected LoginContext lc
Constructor Detail

JBossTestServices

public JBossTestServices(String className)
Constructor for the JBossTestCase object

Parameters:
className - Test case name

JBossTestServices

public JBossTestServices(Class clazz)
Method Detail

setUp

public void setUp()
           throws Exception
The JUnit setup method

Overrides:
setUp in class AbstractTestDelegate
Throws:
Exception - for any error

tearDown

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

Overrides:
tearDown in class AbstractTestDelegate
Throws:
Exception - for any error

getInitialContext

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

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

getServer

public MBeanServerConnection getServer()
                                throws Exception
Gets the Server attribute of the JBossTestCase object

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

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 output/lib. Then it tries to construct a file url or a url.

Parameters:
filename - name of the file/url you want
Returns:
A URL
Throws:
MalformedURLException - Description of Exception

invoke

protected Object invoke(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

invoke

protected Object invoke(MBeanServerConnection server,
                        ObjectName name,
                        String method,
                        Object[] args,
                        String[] sig)
                 throws Exception
Throws:
Exception

deploy

public 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 output/lib.

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

redeploy

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

login

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

Throws:
Exception

logout

public void logout()

undeploy

public 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 output/lib.

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

init

public void init()
          throws Exception
Initializes the InitialContext if not set.

Throws:
Exception - for any error

reinit

public void reinit()
            throws Exception
Re-initializes the InitialContext.

Throws:
Exception - for any error

getServerHost

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

Returns:
the host name

JBoss Test 1.1.9.GA-redhat-2

Copyright © 2012 JBoss by Red Hat. All Rights Reserved.