org.progeeks.junit
Class JUnitHandler

java.lang.Object
  extended by org.progeeks.util.xml.AbstractObjectHandler
      extended by org.progeeks.junit.JUnitHandler
All Implemented Interfaces:
ObjectHandler

public class JUnitHandler
extends AbstractObjectHandler

ObjectHandler implementation that load JUnit test suite's, which can consist of other test suites, test cases, and FixturedTestCase (a custom test case) objects.

Version:
$Revision: 1.13 $
Author:
Paul Wisneskey

Field Summary
static java.lang.String FILE_ATTRIBUTE
          Attribute required for the testSuiteXml tag that denotes the external file to load the test suite from.
static java.lang.String LOAD_SUITE_TAG
          Tag denoting a test suite that is to be loaded from another XML file.
static java.lang.String NAME_FIELD
          Field/attribute which denotes the name of the test suite.
static java.lang.String TEST_SUITE_TAG
          Tag denoting a test suite.
static java.lang.String TESTS_FIELD
          Field containing a list of the tests that belong to the suite.
 
Constructor Summary
JUnitHandler()
           
 
Method Summary
 boolean canHandle(java.lang.String tag)
          See if we can handle that tag we're being presented with.
 java.lang.Object createObject(java.lang.String tag, org.xml.sax.Attributes atts, ObjectXmlReader reader)
          Creates and returns an test suite based on the specified parameters.
protected  void generateContextualTestCases(junit.framework.TestSuite suite, ContextualTestCase contextualTest)
          Uses introspection to determine the test methods inside of a contextual test case and adds those tests to the supplied test suite.
 java.lang.Object getProperty(java.lang.Object obj, java.lang.String field, ObjectXmlReader reader)
          Returns the current value of the specified property in the specified object.
 java.lang.Class getPropertyClass(java.lang.Object object, java.lang.String field, ObjectXmlReader reader)
          Returns the base type for the specified field for the given test suite.
 java.util.Collection getPropertyCollection(java.lang.Object obj, java.lang.String field, ObjectXmlReader reader)
          Returns a collection for the specified field that can be used to accumulate multiple object values.
 void setProperty(java.lang.Object object, java.lang.String field, java.lang.Object value, ObjectXmlReader reader)
          Sets a property on the specified test suite.
 void setTextProperty(java.lang.Object object, java.lang.String field, java.lang.String value, ObjectXmlReader reader)
          Sets a text property on the specified test suite.
 
Methods inherited from class org.progeeks.util.xml.AbstractObjectHandler
resolveObject, setConfigurationProperty, setContainedText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TEST_SUITE_TAG

public static final java.lang.String TEST_SUITE_TAG
Tag denoting a test suite.

See Also:
Constant Field Values

LOAD_SUITE_TAG

public static final java.lang.String LOAD_SUITE_TAG
Tag denoting a test suite that is to be loaded from another XML file.

See Also:
Constant Field Values

NAME_FIELD

public static final java.lang.String NAME_FIELD
Field/attribute which denotes the name of the test suite.

See Also:
Constant Field Values

TESTS_FIELD

public static final java.lang.String TESTS_FIELD
Field containing a list of the tests that belong to the suite. These can either be individidual test cases, test suites, or class instances. In the last case, Junit will use introspection to discover the test methods in the class.

See Also:
Constant Field Values

FILE_ATTRIBUTE

public static final java.lang.String FILE_ATTRIBUTE
Attribute required for the testSuiteXml tag that denotes the external file to load the test suite from.

See Also:
Constant Field Values
Constructor Detail

JUnitHandler

public JUnitHandler()
Method Detail

canHandle

public boolean canHandle(java.lang.String tag)
See if we can handle that tag we're being presented with.

Specified by:
canHandle in interface ObjectHandler
Specified by:
canHandle in class AbstractObjectHandler

createObject

public java.lang.Object createObject(java.lang.String tag,
                                     org.xml.sax.Attributes atts,
                                     ObjectXmlReader reader)
Creates and returns an test suite based on the specified parameters.

Specified by:
createObject in interface ObjectHandler
Specified by:
createObject in class AbstractObjectHandler

getPropertyClass

public java.lang.Class getPropertyClass(java.lang.Object object,
                                        java.lang.String field,
                                        ObjectXmlReader reader)
Returns the base type for the specified field for the given test suite.

Specified by:
getPropertyClass in interface ObjectHandler
Specified by:
getPropertyClass in class AbstractObjectHandler

setProperty

public void setProperty(java.lang.Object object,
                        java.lang.String field,
                        java.lang.Object value,
                        ObjectXmlReader reader)
Sets a property on the specified test suite.

Specified by:
setProperty in interface ObjectHandler
Specified by:
setProperty in class AbstractObjectHandler

setTextProperty

public void setTextProperty(java.lang.Object object,
                            java.lang.String field,
                            java.lang.String value,
                            ObjectXmlReader reader)
Sets a text property on the specified test suite.

Specified by:
setTextProperty in interface ObjectHandler
Specified by:
setTextProperty in class AbstractObjectHandler

getPropertyCollection

public java.util.Collection getPropertyCollection(java.lang.Object obj,
                                                  java.lang.String field,
                                                  ObjectXmlReader reader)
Returns a collection for the specified field that can be used to accumulate multiple object values. This is used when the XML field declaration specifies the progressive attribute.

Specified by:
getPropertyCollection in interface ObjectHandler
Specified by:
getPropertyCollection in class AbstractObjectHandler

getProperty

public java.lang.Object getProperty(java.lang.Object obj,
                                    java.lang.String field,
                                    ObjectXmlReader reader)
Description copied from class: AbstractObjectHandler
Returns the current value of the specified property in the specified object. This is used by the xml.existingValue directive and may eventually replace getPropertyCollection() as well.

Specified by:
getProperty in interface ObjectHandler
Specified by:
getProperty in class AbstractObjectHandler

generateContextualTestCases

protected void generateContextualTestCases(junit.framework.TestSuite suite,
                                           ContextualTestCase contextualTest)
Uses introspection to determine the test methods inside of a contextual test case and adds those tests to the supplied test suite.

Parameters:
suite - Test suite to add tests to.
contextualTest - Contextual test object to find test methods in.


Copyright © 2002-2003 Paul Speed. All Rights Reserved.