org.glassfish.fighterfish.test.util
Class WebAppBundle

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

public class WebAppBundle
extends java.lang.Object

This class is used by tests to deploy WABs. Since a WAB deployment happens asynchronously when a WAB is activated, for a test case to know whether the deployment is successful or not is not as simple as checking if wab.start() returns succesfully or not. This is where this class is helpful. It listens to events raised by the OSGi Web Container as required by the OSGi Web Application spec and depending on the events, returns success or failure when a WAB is deployed. It also uses a timeout mechanism if the deployment does not happen in a specified amount of time.

Author:
Sanjeeb.Sahoo@Sun.COM

Constructor Summary
WebAppBundle(org.osgi.framework.BundleContext context, org.osgi.framework.Bundle b)
          A handle to the web application bundle being deployed.
 
Method Summary
 javax.servlet.ServletContext deploy(long timeout, java.util.concurrent.TimeUnit timeUnit)
          Deploy the given OSGi Web Application Bundle.
 org.osgi.framework.Bundle getBundle()
           
 java.lang.String getHttpResponse(java.lang.String relativePath)
           
 java.lang.String getResponse(java.lang.String relativePath)
          Make a request to the resource available at the path relative to this web app.
 javax.servlet.ServletContext getServletContext()
           
 void undeploy()
          Undeploy the OSGi Web Application Bundle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebAppBundle

public WebAppBundle(org.osgi.framework.BundleContext context,
                    org.osgi.framework.Bundle b)
A handle to the web application bundle being deployed.

Parameters:
context - BundleContext of test used for various OSGi operation. This is not the context of the WAB.
b - Web App Bundle
Method Detail

deploy

public javax.servlet.ServletContext deploy(long timeout,
                                           java.util.concurrent.TimeUnit timeUnit)
                                    throws java.lang.InterruptedException,
                                           org.osgi.framework.BundleException,
                                           TimeoutException
Deploy the given OSGi Web Application Bundle.

Parameters:
timeout - Amount of time it will wait for the deployment to happen before failing
timeUnit -
Returns:
ServletContext associated with the deployed web application
Throws:
java.lang.InterruptedException
org.osgi.framework.BundleException
TimeoutException - if deployment takes longer than the specified timeout value.

undeploy

public void undeploy()
              throws org.osgi.framework.BundleException
Undeploy the OSGi Web Application Bundle. There is no timeout needed here, because the OSGi Web Application Spec requires undeployment to be synchrinously handled when a WAB is stopped.

Throws:
org.osgi.framework.BundleException

getResponse

public java.lang.String getResponse(java.lang.String relativePath)
                             throws java.io.IOException
Make a request to the resource available at the path relative to this web app.

Parameters:
relativePath -
Returns:
Throws:
java.io.IOException

getHttpResponse

public java.lang.String getHttpResponse(java.lang.String relativePath)
                                 throws java.io.IOException
Throws:
java.io.IOException

getServletContext

public javax.servlet.ServletContext getServletContext()

getBundle

public org.osgi.framework.Bundle getBundle()


Copyright © 2013. All Rights Reserved.