com.sun.javatest.lib
Class MultiTest

java.lang.Object
  extended by com.sun.javatest.lib.MultiTest
All Implemented Interfaces:
Test

public class MultiTest
extends java.lang.Object
implements Test

Base class for tests with multiple sub test cases. This base class implements the standard com.sun.javatest.Test features so that you can provide the additional test cases without concern about the boilerplate needed to execute individual test case methods.

You must add individual test case methods to your derived test class to create a useful test class. Each test case method must take no arguments. If you need to pass an argument into a test method, you should design a wrapper test case to calculate the argument values and then call the test method with the correct arguments. The test case methods must implement this interface:

public Status methodName( )

See Also:
Test, TestCases

Nested Class Summary
static class MultiTest.SetupException
          This exception is thrown when a problem occurs initializing the test.
 
Field Summary
protected  java.io.PrintWriter log
          Output to be logged to result file.
protected  java.io.PrintWriter ref
          Output to be logged to result file.
 
Constructor Summary
MultiTest()
           
 
Method Summary
protected  void decodeAllArgs(java.lang.String[] args)
          Parses the arguments passed to the test.
protected  int decodeArg(java.lang.String[] args, int index)
          Decode the next argument in the argument array.
protected  void init()
          A setup method called after argument decoding is complete, and before the test cases are executed.
protected  Status init(java.lang.String[] args)
          Deprecated. Use decodeArg(String) and init() instead.
protected  Status invokeTestCase(java.lang.reflect.Method m)
          Default way to invoke a specified test case.
 Status run(java.lang.String[] argv, java.io.PrintStream log, java.io.PrintStream ref)
          Run the test cases contained in this object This method is a convenience wrapper around the primary run method which takes PrintWriters: this variant takes PrintStreams and wraps them into PrintWriters.
 Status run(java.lang.String[] args, java.io.PrintWriter log, java.io.PrintWriter ref)
          Run the test cases contained in this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ref

protected java.io.PrintWriter ref
Output to be logged to result file.


log

protected java.io.PrintWriter log
Output to be logged to result file.

Constructor Detail

MultiTest

public MultiTest()
Method Detail

run

public Status run(java.lang.String[] args,
                  java.io.PrintWriter log,
                  java.io.PrintWriter ref)
Run the test cases contained in this object. The test cases are determined and invoked via reflection. The set of test cases can be specified with -select case1,case2,case3... and/or restricted with -exclude case1,case2,case3...

Specified by:
run in interface Test
Parameters:
args - Execute arguments passed in from either the command line or the execution harness.
log - Output stream for general messages from the tests.
ref - Output stream for reference output from the tests.
Returns:
Overall status of running all of the test cases.
See Also:
decodeAllArgs(java.lang.String[]), init(java.lang.String[])

run

public final Status run(java.lang.String[] argv,
                        java.io.PrintStream log,
                        java.io.PrintStream ref)
Run the test cases contained in this object This method is a convenience wrapper around the primary run method which takes PrintWriters: this variant takes PrintStreams and wraps them into PrintWriters.

Parameters:
argv - Execute arguments passed in from either the command line or the execution harness.
log - Output stream for general messages from the tests.
ref - Output stream for reference output from the tests.
Returns:
Overall status of running all of the test cases.
See Also:
decodeAllArgs(java.lang.String[]), init(java.lang.String[])

init

protected Status init(java.lang.String[] args)
Deprecated. Use decodeArg(String) and init() instead.

Initialize the test from the given arguments. The arguments will be passed to decodeAllArgs, and then init() will be called.

Parameters:
args - The arguments for the test, passed to decodeArgs.
Returns:
null if initialization is successful, or a status indicating why initialization was not successful.
See Also:
decodeAllArgs(java.lang.String[]), decodeArg(java.lang.String[], int), init()

init

protected void init()
             throws MultiTest.SetupException
A setup method called after argument decoding is complete, and before the test cases are executed. By default, it does nothing; it may be overridden to provide additional behavior.

Throws:
MultiTest.SetupException - if processing should not continue. This may be due to some inconsistency in the arguments, or if it is determined the test should not execute for some reason.

decodeAllArgs

protected final void decodeAllArgs(java.lang.String[] args)
                            throws MultiTest.SetupException
Parses the arguments passed to the test. This method embodies the main loop for all of the test's arguments. It calls decodeArg for successive arguments in the argument array.

Parameters:
args - arguments passed to the test.
Throws:
MultiTest.SetupException - raised when an invalid parameter is passed, or another error occurred.
See Also:
decodeArg(java.lang.String[], int)

decodeArg

protected int decodeArg(java.lang.String[] args,
                        int index)
                 throws MultiTest.SetupException
Decode the next argument in the argument array. This will typically be overridden by subtypes that wish to decode additional arguments. If an overriding method does not recognize an argument, it should return super.decodeArg(args, index) to give supertypes a change to decode the argument as well.

Parameters:
args - The array containing all the arguments
index - The position of the next argument to be decoded.
Returns:
the number of elements in the array were "consumed" by this call.
Throws:
MultiTest.SetupException - is there is a problem decoding the argument.

invokeTestCase

protected Status invokeTestCase(java.lang.reflect.Method m)
                         throws java.lang.IllegalAccessException,
                                java.lang.reflect.InvocationTargetException
Default way to invoke a specified test case.

Parameters:
m - The method to be invoked.
Returns:
The result of invoking the specified test case.
Throws:
java.lang.IllegalAccessException - if there was a problem accessing the specified method
java.lang.reflect.InvocationTargetException - if the specified method threw an exception when it was invoked.


Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.