org.ajax4jsf.tests
Class AbstractThreadedAjax4JsfTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.shale.test.base.AbstractJsfTestCase
              extended by org.ajax4jsf.tests.AbstractAjax4JsfTestCase
                  extended by org.ajax4jsf.tests.AbstractThreadedAjax4JsfTestCase
All Implemented Interfaces:
junit.framework.Test

public class AbstractThreadedAjax4JsfTestCase
extends AbstractAjax4JsfTestCase

Version:
$Revision: 1.1.2.3 $ $Date: 2007/02/20 20:58:08 $ /** A multi-threaded JUnit test case, with setup faces environment. To perform test cases that spin off threads to do tests:

That's it. An example is below:
 public class MTTest extends ThreadedVcpJsfTestCase
 {
   MTTest (String s) { super (s); }
   public class CounterThread extends TestCaseRunnable
   {
     public void runTestCase (FacesContext context) throws Throwable
     {
       for (int i = 0; i < 1000; i++)
       {
         System.out.println ("Counter Thread: " + Thread.currentThread () + " : " + i);
         // Do some testing...
         if (Thread.currentThread ().isInterrupted ()) {
           return;
         }
       }
     }
   }

   public void test1 ()
   {
     TestCaseRunnable tct [] = new TestCaseRunnable [5];
     for (int i = 0; i < 5; i++) 
     {
       tct[i] = new CounterThread ();
      }
     runTestCaseRunnables (tct);
   }
 }
 

Category: Test
Not guaranteed to be thread safe.
Author:
asmirnov@exadel.com (latest modification by $Author: ishabalov $)

Nested Class Summary
 class AbstractThreadedAjax4JsfTestCase.TestCaseRunnable
          A test case thread.
 
Field Summary
 
Fields inherited from class org.ajax4jsf.tests.AbstractAjax4JsfTestCase
ajaxContext, elContext, expressionFactory, SLASHED_RESOURCE_URI_PREFIX, vcpRenderKit, webClient, webConnection, webXml, writer
 
Fields inherited from class org.apache.shale.test.base.AbstractJsfTestCase
application, config, externalContext, facesContext, facesContextFactory, lifecycle, lifecycleFactory, renderKit, request, response, servletContext, session
 
Constructor Summary
AbstractThreadedAjax4JsfTestCase(java.lang.String s)
          Simple constructor.
 
Method Summary
protected  javax.faces.context.FacesContext createFacesContext()
          Create instance of faces context for current thread.
 void interruptThreads()
          Interrupt the running threads.
 void run(junit.framework.TestResult result)
          Override run so we can squirrel away the test result.
protected  void runTestCaseRunnables(AbstractThreadedAjax4JsfTestCase.TestCaseRunnable[] runnables)
          Run the test case threads.
protected  void runTestCaseThreads(java.lang.Class clazz, int numThreads)
          Create instances of classes and run threads with it.
 
Methods inherited from class org.ajax4jsf.tests.AbstractAjax4JsfTestCase
createComponent, createWebClient, evaluate, getCountValidScripts, getImageResource, getImplementationUrls, getResourceIfPresent, getSkinName, processResponse, processResponseWriter, renderChild, renderChildren, renderView, setUp, setupResponseWriter, setupWebClient, tearDown
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, 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, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractThreadedAjax4JsfTestCase

public AbstractThreadedAjax4JsfTestCase(java.lang.String s)
Simple constructor.

Method Detail

interruptThreads

public void interruptThreads()
Interrupt the running threads.


run

public void run(junit.framework.TestResult result)
Override run so we can squirrel away the test result.

Specified by:
run in interface junit.framework.Test
Overrides:
run in class junit.framework.TestCase

runTestCaseThreads

protected void runTestCaseThreads(java.lang.Class clazz,
                                  int numThreads)
Create instances of classes and run threads with it.

Parameters:
clazz - - class of test thread implementation.
numThreads - - number of threads to run.
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException

runTestCaseRunnables

protected void runTestCaseRunnables(AbstractThreadedAjax4JsfTestCase.TestCaseRunnable[] runnables)
Run the test case threads.

Parameters:
runnables - - array with instances of AbstractThreadedAjax4JsfTestCase.TestCaseRunnable with concrete tests

createFacesContext

protected javax.faces.context.FacesContext createFacesContext()
Create instance of faces context for current thread.

Returns:


Copyright © 2009. All Rights Reserved.