com.googlecode.lightest.core
Class Configuration

java.lang.Object
  extended by com.googlecode.lightest.core.Configuration
All Implemented Interfaces:
IConfiguration, groovy.lang.GroovyObject

public class Configuration
extends Object
implements groovy.lang.GroovyObject, IConfiguration


Field Summary
static String DEFAULT_ASSIGNMENT_STRATEGY
           
static String ROLE_FAILED_REPORTER
           
static String ROLE_PENDING_REPORTER
           
static String ROLE_XML_REPORTER
           
static List UNSPECIFIED_ENVS
           
static IPreferences UNSPECIFIED_PREFS
           
 
Constructor Summary
Configuration()
           
Configuration(groovy.lang.GroovyShell shell)
           
Configuration(groovy.lang.GroovyShell shell, groovy.lang.GroovyClassLoader classLoader)
           
Configuration(Map vars)
          A convenience constructor for creating a Configuration object whose text is parsed with the given variables in scope.
 
Method Summary
protected  void configureInstance(Object instance, groovy.util.Node instanceConfig)
           
protected  Object createConfiguredInstance(groovy.util.Node instanceConfig)
          Returns a new instance of a class, as defined in a configuration node.
protected  ILightestReporter createConfiguredReporter(groovy.util.Node instanceConfig, boolean isFailedReporter)
          Returns a configured ILightestReporter.
 groovy.lang.GroovyClassLoader getClassLoader()
          Returns the class loader used to load the configuration-related classes.
 List getClassPaths()
          Returns a List of Strings representing class paths under which tasks and potentially environment and preference classes are defined.
 String getContextClass()
          Returns the name of the class to be used as the context class.
 IDispatcherAssignmentStrategy getDispatcherAssignmentStrategy()
          Returns the specified dispatcher assignment strategy.
 List getEnvironments()
          Returns a List of ITestEnvironment instances.
 ILightestReporter getFailedReporter()
           
 List getListeners()
          Returns a list of listener instances to be registered directly with the TestNG runner.
 groovy.lang.MetaClass getMetaClass()
           
 String getOutputDir()
          Returns the output directory for the test run report.
 ILightestReporter getPendingReporter()
           
 IPreferences getPreferences()
          Returns an instance of the concrete implementation of IPreferences.
 Object getProperty(String name)
           
 List getReporters()
          Returns a list of reporter instances.
 ITaskDispatchStrategy getTaskDispatchStrategy()
          Returns an instance of the ITaskDispatchStrategy implementation to use instead of whatever implementation is available by default.
 ILightestReporter getXMLReporter()
           
 void init(String configText)
          Initializes the configuration.
 Object invokeMethod(String name, Object args)
           
protected  groovy.util.Node parseConfig(String configText)
           
 void setMetaClass(groovy.lang.MetaClass metaClass)
           
 void setProperty(String name, Object value)
           
 void validate()
          Determines if the specified configuration is a valid one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNSPECIFIED_PREFS

public static final IPreferences UNSPECIFIED_PREFS

UNSPECIFIED_ENVS

public static final List UNSPECIFIED_ENVS

ROLE_XML_REPORTER

public static final String ROLE_XML_REPORTER

ROLE_PENDING_REPORTER

public static final String ROLE_PENDING_REPORTER

ROLE_FAILED_REPORTER

public static final String ROLE_FAILED_REPORTER

DEFAULT_ASSIGNMENT_STRATEGY

public static final String DEFAULT_ASSIGNMENT_STRATEGY
Constructor Detail

Configuration

public Configuration()

Configuration

public Configuration(groovy.lang.GroovyShell shell)

Configuration

public Configuration(Map vars)
A convenience constructor for creating a Configuration object whose text is parsed with the given variables in scope.

Parameters:
vars - a Map of String's to Object's that will be used to initialize a Binding object, and set on the GroovyShell used to evaluate the configuration text.

Configuration

public Configuration(groovy.lang.GroovyShell shell,
                     groovy.lang.GroovyClassLoader classLoader)
Parameters:
shell - the GroovyShell to be used to evaluate the configuration text
classLoader - the class loader to use to load classes referenced in the configuration text
Method Detail

init

public void init(String configText)
Initializes the configuration.

Parameters:
configText - a text representation of the configuration to initialize. See the Lightest documentation for the format of this text.

parseConfig

protected groovy.util.Node parseConfig(String configText)

validate

public void validate()
Determines if the specified configuration is a valid one. If not, throws an exception. Not implemented.


createConfiguredInstance

protected Object createConfiguredInstance(groovy.util.Node instanceConfig)
Returns a new instance of a class, as defined in a configuration node. The class' binary name must be specified in the "class" attribute, and the node's children are considered name-value pairs that can be used to set properties on the new instance. The class loader used to load the class will include at least all paths returned by getClassPaths().

Parameters:
instanceConfig -

configureInstance

protected void configureInstance(Object instance,
                                 groovy.util.Node instanceConfig)

createConfiguredReporter

protected ILightestReporter createConfiguredReporter(groovy.util.Node instanceConfig,
                                                     boolean isFailedReporter)
Returns a configured ILightestReporter. If the new'd instance is not an ILightestReporter, but is an IReporter, it is wrapped with the appropriate decorator class - the FailedReporterDecorator if isFailedReporter is true, and LightestReporterAdapter otherwise. If the instance is neither an ILightestReporter nor a IReporter, returns null.


getClassLoader

public groovy.lang.GroovyClassLoader getClassLoader()
Returns the class loader used to load the configuration-related classes.

Specified by:
getClassLoader in interface IConfiguration

getClassPaths

public List getClassPaths()
Returns a List of Strings representing class paths under which tasks and potentially environment and preference classes are defined. The current directory is added by default.

Specified by:
getClassPaths in interface IConfiguration

getOutputDir

public String getOutputDir()
Returns the output directory for the test run report. The default output directory is "lightest-report".

Specified by:
getOutputDir in interface IConfiguration

getPreferences

public IPreferences getPreferences()
Returns an instance of the concrete implementation of IPreferences.

Specified by:
getPreferences in interface IConfiguration

getEnvironments

public List getEnvironments()
Returns a List of ITestEnvironment instances. The UNSPECIFIED_ENVS list containing three default environment entries will be returned if unspecified.

Specified by:
getEnvironments in interface IConfiguration

getContextClass

public String getContextClass()
Description copied from interface: IConfiguration
Returns the name of the class to be used as the context class. This class must be or extend LightestContext.

Specified by:
getContextClass in interface IConfiguration

getReporters

public List getReporters()
Description copied from interface: IConfiguration
Returns a list of reporter instances. They should implement either org.testng.IReporter or ILightestReporter .

Specified by:
getReporters in interface IConfiguration

getXMLReporter

public ILightestReporter getXMLReporter()
Specified by:
getXMLReporter in interface IConfiguration

getPendingReporter

public ILightestReporter getPendingReporter()
Specified by:
getPendingReporter in interface IConfiguration

getFailedReporter

public ILightestReporter getFailedReporter()
Specified by:
getFailedReporter in interface IConfiguration

getListeners

public List getListeners()
Description copied from interface: IConfiguration
Returns a list of listener instances to be registered directly with the TestNG runner. These should implement ITestNGListener.

Specified by:
getListeners in interface IConfiguration

getDispatcherAssignmentStrategy

public IDispatcherAssignmentStrategy getDispatcherAssignmentStrategy()
Returns the specified dispatcher assignment strategy. A DEFAULT_STRATEGY will be returned if unspecified.

Specified by:
getDispatcherAssignmentStrategy in interface IConfiguration

getTaskDispatchStrategy

public ITaskDispatchStrategy getTaskDispatchStrategy()
Description copied from interface: IConfiguration
Returns an instance of the ITaskDispatchStrategy implementation to use instead of whatever implementation is available by default. This method may return null if no custom strategy is specified.

Specified by:
getTaskDispatchStrategy in interface IConfiguration

getMetaClass

public groovy.lang.MetaClass getMetaClass()
Specified by:
getMetaClass in interface groovy.lang.GroovyObject

setMetaClass

public void setMetaClass(groovy.lang.MetaClass metaClass)
Specified by:
setMetaClass in interface groovy.lang.GroovyObject

invokeMethod

public Object invokeMethod(String name,
                           Object args)
Specified by:
invokeMethod in interface groovy.lang.GroovyObject

getProperty

public Object getProperty(String name)
Specified by:
getProperty in interface groovy.lang.GroovyObject

setProperty

public void setProperty(String name,
                        Object value)
Specified by:
setProperty in interface groovy.lang.GroovyObject


Copyright © 2009. All Rights Reserved.