org.apache.geronimo.validator
Class ValidationTest

java.lang.Object
  extended byorg.apache.geronimo.validator.ValidationTest
Direct Known Subclasses:
BaseEjbJarTest

public abstract class ValidationTest
extends Object

The base class for all validation tests. They will work similarly to JUnit tests, in that any method beginning with "test" will be executed. The test methods should return a ValidationResult, though they may also indicate problems by throwing a ValidationException. The difference is that a ValidationException is considered to be fatal, whereas a ValidationResult may indicate a warning or a non-fatal error as well. Each test class may specify a deployment descriptor and XPath, in which case the same test class will have its tests executed multiple times with a different context each time (once for each DD and/or hit on the XPath).

Version:
$Revision: 1.4 $ $Date: 2004/03/10 09:58:44 $

Field Summary
protected  ValidationContext context
           
 
Constructor Summary
ValidationTest()
           
 
Method Summary
protected  ValidationResult error(String messageCode)
           
protected  ValidationResult error(String messageCode, Object param)
           
protected  ValidationResult error(String messageCode, Object[] params)
           
protected  ValidationResult error(String messageCode, ValidationResult oldState)
           
protected  ValidationResult error(String messageCode, ValidationResult oldState, Object param)
           
protected  ValidationResult error(String messageCode, ValidationResult oldState, Object[] params)
           
abstract  org.apache.xmlbeans.SchemaType getSchemaType()
          Any given test class is typically associated with one particular deployment descriptor.
abstract  String getXpath()
          Any given test class can be associated with a specific XPath in its deployment descriptor.
abstract  ValidationResult initialize(ValidationContext context)
          Called before any test methods are run in order to establish the context for the test.
protected  Class loadClass(String className, String description)
          Loads a class from the application module.
protected  ValidationResult warn(String messageCode)
           
protected  ValidationResult warn(String messageCode, Object param)
           
protected  ValidationResult warn(String messageCode, Object[] params)
           
protected  ValidationResult warn(String messageCode, ValidationResult oldState)
           
protected  ValidationResult warn(String messageCode, ValidationResult oldState, Object param)
           
protected  ValidationResult warn(String messageCode, ValidationResult oldState, Object[] params)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

protected ValidationContext context
Constructor Detail

ValidationTest

public ValidationTest()
Method Detail

getSchemaType

public abstract org.apache.xmlbeans.SchemaType getSchemaType()
Any given test class is typically associated with one particular deployment descriptor. If the returns a non-null value, this test will be invoked with a context specific to the provided deployment descriptor. If it returns null, this test will be invoked once for the module as a whole.

Returns:
A standard deployment descriptor name, with no directory, (such as "ejb-jar.xml"), or null to be invoked with no particular DD context.

getXpath

public abstract String getXpath()
Any given test class can be associated with a specific XPath in its deployment descriptor. It wil be invoked one for every hit on that XPath, with a context set to the node that matches the XPath. For example, a test class that returns a standard DD name of "ejb-jar.xml" and an XPath of "/ejb-jar/enterprise-beans/session" would be invoked once on every session bean.

Returns:
An Xpath of interest to this test class, or null if the class should be invoked once on the entire deployment descriptor or module. If getSchemaType returns null, this method nust return null as well.

initialize

public abstract ValidationResult initialize(ValidationContext context)
Called before any test methods are run in order to establish the context for the test. This method will typically read the current node (set corresponding to the XPath of interest) and cast it to some specific object type (from XmlObject to SessionBeanType, for example).

Parameters:
context - The context for all test methods in this class to use.
Returns:
The result of the initialization. Usually returns success, but may not in a case, for example, where during initialization it is determined that no tests could run successfully (due to missing classes or whatever). If this method does not return PASSED or PASSED_WITH_WARNINGS, then no test methods on this class will be run.

loadClass

protected Class loadClass(String className,
                          String description)
                   throws ValidationException
Loads a class from the application module.

Parameters:
className - The fully-qualified Java class name of the class to load.
description - A description of the why this class is being loaded, used in an error message if it cannot be loaded. ("Class [className] could not be loaded ([description])")
Returns:
A class.
Throws:
ValidationException - occurs when the class can't be loaded. Don't both to catch this exception unless you don't want a failure to load the class to be interpreted as a fatal error.

warn

protected ValidationResult warn(String messageCode,
                                ValidationResult oldState)

warn

protected ValidationResult warn(String messageCode,
                                ValidationResult oldState,
                                Object param)

warn

protected ValidationResult warn(String messageCode,
                                ValidationResult oldState,
                                Object[] params)

warn

protected ValidationResult warn(String messageCode)

warn

protected ValidationResult warn(String messageCode,
                                Object param)

warn

protected ValidationResult warn(String messageCode,
                                Object[] params)

error

protected ValidationResult error(String messageCode,
                                 ValidationResult oldState)

error

protected ValidationResult error(String messageCode,
                                 ValidationResult oldState,
                                 Object param)

error

protected ValidationResult error(String messageCode,
                                 ValidationResult oldState,
                                 Object[] params)

error

protected ValidationResult error(String messageCode)

error

protected ValidationResult error(String messageCode,
                                 Object param)

error

protected ValidationResult error(String messageCode,
                                 Object[] params)


Copyright © 2003-2005 Apache Software Foundation. All Rights Reserved.