org.glassfish.fighterfish.test.util
Class TestContext

java.lang.Object
  extended by org.glassfish.fighterfish.test.util.TestContext

public class TestContext
extends Object

A TestContext is a facade through which a test interacts with underlying OSGi or Java EE platform. It provides functionality like installing/uninstalling bundles, configuring Java EE resources like JDBC data sources, JMS destinations, etc. Each test method is accompanied by a single TestContext object. A TestContext object's life cycle is scoped to a test method for this reason. Each test method must create a TestContext by calling the factory method create(BundleContext) at the beginning of the test method and destroy it by calling destroy() at the end of the test method. When a test context is destroyed, all changes done so far will be rolled back. This includes any bundles deployed. any domain configuration made, etc.

Author:
Sanjeeb.Sahoo@Sun.COM

Method Summary
 void configureEmbeddedDerby()
           
static TestContext create(org.osgi.framework.BundleContext ctx)
           
 void createJmsCF(String cfName)
           
 void createJmsTopic(String topicName)
           
 EjbBundle deployEjbBundle(org.osgi.framework.Bundle bundle, String[] services)
          Deploy the given EJB OSGi bundle.
 EntityBundle deployEntityBundle(org.osgi.framework.Bundle bundle)
          Deploy the given JPA Entities bundle.
 WebAppBundle deployWebAppBundle(org.osgi.framework.Bundle bundle)
          Deploy the given OSGi Web Application Bundle.
 void destroy()
           
 org.osgi.framework.BundleContext getBundleContext()
           
 org.glassfish.embeddable.GlassFish getGlassFish()
           
 org.osgi.framework.Bundle installTestBundle(String location)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static TestContext create(org.osgi.framework.BundleContext ctx)
                          throws org.glassfish.embeddable.GlassFishException,
                                 InterruptedException
Throws:
org.glassfish.embeddable.GlassFishException
InterruptedException

destroy

public void destroy()
             throws org.osgi.framework.BundleException,
                    org.glassfish.embeddable.GlassFishException
Throws:
org.osgi.framework.BundleException
org.glassfish.embeddable.GlassFishException

deployWebAppBundle

public WebAppBundle deployWebAppBundle(org.osgi.framework.Bundle bundle)
                                throws org.osgi.framework.BundleException,
                                       InterruptedException
Deploy the given OSGi Web Application Bundle. WAB deployment happens asynchronously when a WAB is activated. It waits for a configured amount time for deployment to take place successfully. If deployment fails or does not happen within the configured times, it throws TimeoutException.

Parameters:
bundle -
Returns:
ServletContext associated with the deployed web application
Throws:
org.osgi.framework.BundleException
InterruptedException

deployEntityBundle

public EntityBundle deployEntityBundle(org.osgi.framework.Bundle bundle)
                                throws org.osgi.framework.BundleException,
                                       InterruptedException
Deploy the given JPA Entities bundle. If a service of type EntityManagerFactory does not get registered in the specified time, assume the deployment has failed and throw a TimeoutException.

Parameters:
bundle - Entity bundle to be deployed
Returns:
a handle to the deployed application
Throws:
org.osgi.framework.BundleException
InterruptedException
TimeoutException

deployEjbBundle

public EjbBundle deployEjbBundle(org.osgi.framework.Bundle bundle,
                                 String[] services)
                          throws org.osgi.framework.BundleException,
                                 InterruptedException
Deploy the given EJB OSGi bundle. Deployment is triggered asynchronously by starting the bundle. If none of the user specified services show up in service registry in the specified amount of time, it assumes the operation has failed and throws TimeoutOperation.

Parameters:
bundle - EJB Bundle to be deployed
services - Services that are expected to be made available by this EJB bundle if deployment is successful.
Returns:
a handle to the deployed application
Throws:
org.osgi.framework.BundleException
InterruptedException
TimeoutException

getGlassFish

public org.glassfish.embeddable.GlassFish getGlassFish()
                                                throws org.glassfish.embeddable.GlassFishException,
                                                       InterruptedException
Throws:
org.glassfish.embeddable.GlassFishException
InterruptedException

configureEmbeddedDerby

public void configureEmbeddedDerby()
                            throws org.glassfish.embeddable.GlassFishException,
                                   InterruptedException
Throws:
org.glassfish.embeddable.GlassFishException
InterruptedException

getBundleContext

public org.osgi.framework.BundleContext getBundleContext()

installTestBundle

public org.osgi.framework.Bundle installTestBundle(String location)
                                            throws org.osgi.framework.BundleException
Throws:
org.osgi.framework.BundleException

createJmsCF

public void createJmsCF(String cfName)
                 throws org.glassfish.embeddable.GlassFishException,
                        InterruptedException
Throws:
org.glassfish.embeddable.GlassFishException
InterruptedException

createJmsTopic

public void createJmsTopic(String topicName)
                    throws org.glassfish.embeddable.GlassFishException,
                           InterruptedException
Throws:
org.glassfish.embeddable.GlassFishException
InterruptedException


Copyright © 2011. All Rights Reserved.