org.apache.commons.latka.junit
Class JUnitTestAdapter

java.lang.Object
  extended by org.apache.commons.latka.junit.JUnitTestAdapter
All Implemented Interfaces:
junit.framework.Test

public class JUnitTestAdapter
extends Object
implements junit.framework.Test

A JUnit Test which is created by wrapping a Latka Suite

Version:
$Id: JUnitTestAdapter.java 155424 2005-02-26 13:09:29Z dirkv $
Author:
Chuck Burdick, dIon Gillard

Constructor Summary
protected JUnitTestAdapter(Suite suite, int testCount)
          Create a Test from a Latka suite and a number of tests
 
Method Summary
 int countTestCases()
          Provides access, post-parsing, of the number of request elements in the Latka Suite
static junit.framework.Test createTestFromFile(File file)
          Create a Test from a Java file
static junit.framework.Test createTestFromFile(String fileName)
          Create a Test from a Latka file
static junit.framework.Test createTestFromResource(String resourceName)
          Create a Test from a resource accessible via the class loader
static junit.framework.Test createTestFromURL(String url)
          Create a Test from a String containing a URL whose contents are in Latka's XML format
static junit.framework.Test createTestFromURL(URL url)
          Create a Test from a URL whose contents are in Latka's XML format
protected static int parse(InputSource xml)
          Parse the Latka XML document to count the requests
 void run(junit.framework.TestResult r)
          Run the test, adding results to the provided TestResult
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JUnitTestAdapter

protected JUnitTestAdapter(Suite suite,
                           int testCount)
Create a Test from a Latka suite and a number of tests

Parameters:
suite - The Latka Suite to be run as a JUnit Test
testCount - The number of 'request's in the Latka suite
Method Detail

createTestFromFile

public static junit.framework.Test createTestFromFile(String fileName)
Create a Test from a Latka file

Parameters:
fileName - The name of a readable file in Latka's XML format
Returns:
a JUnit Test, ready to run, or null if the file can't be resolved

createTestFromFile

public static junit.framework.Test createTestFromFile(File file)
Create a Test from a Java file

Parameters:
file - A readable java file containing Latka's XML format
Returns:
a JUnit Test, ready to run, or null if the file can't be resolved

createTestFromResource

public static junit.framework.Test createTestFromResource(String resourceName)
Create a Test from a resource accessible via the class loader

Parameters:
resourceName - A resource accessible by the class loader in Latka's XML format
Returns:
a JUnit Test, ready to run, or null if the resource can't be resolved

createTestFromURL

public static junit.framework.Test createTestFromURL(String url)
Create a Test from a String containing a URL whose contents are in Latka's XML format

Parameters:
url - the URL to fetch
Returns:
a JUnit Test, ready to run, or null if the url can't be resolved

createTestFromURL

public static junit.framework.Test createTestFromURL(URL url)
Create a Test from a URL whose contents are in Latka's XML format

Parameters:
url - the URL to fetch
Returns:
a JUnit Test, ready to run, or null if the url can't be resolved

parse

protected static int parse(InputSource xml)
                    throws IOException,
                           SAXException,
                           FactoryConfigurationError,
                           ParserConfigurationException
Parse the Latka XML document to count the requests

Parameters:
xml - The inputsource to parse
Returns:
the number of tests in the Latka suite
Throws:
IOException - When an IO occurs reading the document
SAXException - When the document is invalid XML
FactoryConfigurationError - When the SAX Parser factory can't be configured correctly
ParserConfigurationException - When the SAX Parser can't be configured correctly

countTestCases

public int countTestCases()
Provides access, post-parsing, of the number of request elements in the Latka Suite

Specified by:
countTestCases in interface junit.framework.Test
Returns:
the number of test cases in the Latka suite

run

public void run(junit.framework.TestResult r)
Run the test, adding results to the provided TestResult

Specified by:
run in interface junit.framework.Test
Parameters:
r - TestResult to accumulate


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.