org.aitools.programd.test.aiml
Class TestSuite

java.lang.Object
  extended by org.aitools.programd.test.aiml.TestSuite
All Implemented Interfaces:
java.lang.Iterable<TestCase>

public class TestSuite
extends java.lang.Object
implements java.lang.Iterable<TestCase>

A TestSuite comprises a set of TestCases.

Since:
4.5
Author:
Albertas Mickensas

Field Summary
private  java.lang.String clearInput
          The clearInput to use for this test suite.
private  java.util.LinkedList<TestResult> failures
          The test failures accumulated by this suite.
private  org.apache.log4j.Logger logger
          The Logger.
private  Multiplexor multiplexor
          The Multiplexor to use.
private  java.lang.String name
          The name of the test suite.
private  java.util.LinkedList<TestResult> successes
          The test auccesses accumulated by this suite.
static java.lang.String TESTCASE_NAMESPACE_URI
          The test cases namespace URI.
(package private)  java.util.ArrayList<TestCase> testCases
          The test cases in this suite.
private static java.lang.String TESTER_ID
          The userid to use for the tester.
 
Constructor Summary
private TestSuite(java.lang.String nameToUse, org.apache.log4j.Logger loggerToUse)
          Creates a new TestSuite (with no clearInput or Multiplexor(!)).
  TestSuite(java.lang.String nameToUse, Multiplexor multiplexorToUse, org.apache.log4j.Logger loggerToUse)
          Creates a new TestSuite (with no clearInput).
  TestSuite(java.lang.String nameToUse, java.lang.String clearInputToUse, Multiplexor multiplexorToUse, org.apache.log4j.Logger loggerToUse)
          Creates a new TestSuite.
 
Method Summary
 void addTestCase(TestCase testCase)
          Adds a test case to this suite.
 java.util.LinkedList<TestResult> getFailures()
           
 java.lang.String getName()
           
 java.util.LinkedList<TestResult> getSuccesses()
           
 java.util.ArrayList<TestCase> getTestCases()
           
 java.util.Iterator<TestCase> iterator()
           
static TestSuite load(java.net.URL path, java.net.URL schema, org.apache.log4j.Logger logger)
          Loads a test suite from the given path.
static TestSuite load(java.net.URL path, java.net.URL schema, Multiplexor multiplexor, org.apache.log4j.Logger logger)
          Loads a test suite from the given path.
private  void registerFailure(java.lang.String suite, java.lang.String tcase, java.lang.String pattern, java.lang.String response)
           
private  void registerSuccess(java.lang.String suite, java.lang.String tcase, java.lang.String pattern, java.lang.String response)
           
 boolean run(java.lang.String botid)
          Runs the test cases contained in this suite.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TESTCASE_NAMESPACE_URI

public static final java.lang.String TESTCASE_NAMESPACE_URI
The test cases namespace URI.

See Also:
Constant Field Values

testCases

java.util.ArrayList<TestCase> testCases
The test cases in this suite.


name

private java.lang.String name
The name of the test suite.


clearInput

private java.lang.String clearInput
The clearInput to use for this test suite.


multiplexor

private Multiplexor multiplexor
The Multiplexor to use.


logger

private org.apache.log4j.Logger logger
The Logger.


successes

private java.util.LinkedList<TestResult> successes
The test auccesses accumulated by this suite.


failures

private java.util.LinkedList<TestResult> failures
The test failures accumulated by this suite.


TESTER_ID

private static final java.lang.String TESTER_ID
The userid to use for the tester.

See Also:
Constant Field Values
Constructor Detail

TestSuite

public TestSuite(java.lang.String nameToUse,
                 java.lang.String clearInputToUse,
                 Multiplexor multiplexorToUse,
                 org.apache.log4j.Logger loggerToUse)
Creates a new TestSuite.

Parameters:
nameToUse - the name to give the test suite
clearInputToUse - the clearInput for the test suite
multiplexorToUse - the multiplexor to use

TestSuite

public TestSuite(java.lang.String nameToUse,
                 Multiplexor multiplexorToUse,
                 org.apache.log4j.Logger loggerToUse)
Creates a new TestSuite (with no clearInput).

Parameters:
nameToUse - the name to give the test suite
multiplexorToUse - the multiplexor to use

TestSuite

private TestSuite(java.lang.String nameToUse,
                  org.apache.log4j.Logger loggerToUse)
Creates a new TestSuite (with no clearInput or Multiplexor(!)).

Parameters:
nameToUse - the name to give the test suite
Method Detail

iterator

public java.util.Iterator<TestCase> iterator()
Specified by:
iterator in interface java.lang.Iterable<TestCase>
Returns:
an iterator over this suite's test cases
See Also:
Iterable.iterator()

addTestCase

public void addTestCase(TestCase testCase)
Adds a test case to this suite.

Parameters:
testCase - the test case to add.

getTestCases

public java.util.ArrayList<TestCase> getTestCases()
Returns:
the test cases in this suite

getName

public java.lang.String getName()
Returns:
the name of this suite

run

public boolean run(java.lang.String botid)
Runs the test cases contained in this suite.

Parameters:
botid - the botid for whom to run the test cases
Returns:
whether the test cases all passed successfully

registerSuccess

private void registerSuccess(java.lang.String suite,
                             java.lang.String tcase,
                             java.lang.String pattern,
                             java.lang.String response)

registerFailure

private void registerFailure(java.lang.String suite,
                             java.lang.String tcase,
                             java.lang.String pattern,
                             java.lang.String response)

getSuccesses

public java.util.LinkedList<TestResult> getSuccesses()
Returns:
the successes accumulated by this suite

getFailures

public java.util.LinkedList<TestResult> getFailures()
Returns:
the failures accumulated by this suite

load

public static TestSuite load(java.net.URL path,
                             java.net.URL schema,
                             org.apache.log4j.Logger logger)
Loads a test suite from the given path.

Parameters:
path - the path from which to load the test suite
schema - the URL to the copy of the schema for test cases
Returns:
the loaded test suite

load

public static TestSuite load(java.net.URL path,
                             java.net.URL schema,
                             Multiplexor multiplexor,
                             org.apache.log4j.Logger logger)
Loads a test suite from the given path.

Parameters:
path - the path from which to load the test suite
schema - the URL to the copy of the schema for test cases
multiplexor - the multiplexor to use
Returns:
the loaded test suite