|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.identityconnectors.contract.data.GroovyDataProvider
public class GroovyDataProvider
Default implementation of DataProvider. It uses ConfigSlurper from
Groovy to parse the property file.
The groovy files are read as classpath resources using following paths :
loader.getResource(prefix + "/config/config.groovy")loader.getResource(prefix + "/config/" + cfg + "/config.groovy") optionally where cfg is passed configuration loader.getResource(prefix + "/config-private/config.groovy") loader.getResource(prefix + "/config-private/" + cfg + "/config.groovy") optionally where cfg is passed configuration
Lazy.random("####") is used for generating random strings, in
case numeric object is needed, use for instance
Lazy.random("####", Long.class) to get a Long object with
random value.
Snapshot generation to output file -- this feature is
implemented by method flatten(Object). Snapshot
generating works in one direction, but the snapshot itself cannot be directly
used as an input to next testing.
Snapshots -- usage: add switch -Dtest.parameters.outFile=generated.properties
as an ANT parameter. The result snapshot file will be included in the connector's directory.
Note: snapshots for now support basic types such as Lazy, String. Other objects will be converted with toString() method to the output.
Snapshots of queried properties -- usage:
add switch -Dtest.parameters.outQueriedFile=dumpedq.properties
as an ANT parameter. The result snapshot file will be included in the connector's directory.
default values -- these values reside in file bootstrap.groovy. When the property foo.bar.boo is queried the following queries are executed:
1) foo.bar.boo 2) bar.boo 3) booIn case none of these queries succeed, the default value is used based on the type of the query.
isMultivalue boolean property -- is passed in get(...) methods of GroovyDataProvider. It has influence on default values generated, when property is missing.
| Field Summary | |
|---|---|
static String |
MULTI_VALUE_TYPE_PREFIX
prefix of default values that are multi |
| Constructor Summary | |
|---|---|
GroovyDataProvider()
default constructor |
|
GroovyDataProvider(String connectorName)
|
|
| Method Summary | |
|---|---|
void |
dispose()
free the allocated resources |
Object |
generate(String pattern)
generates a random string dynamically. |
Object |
generate(String pattern,
Class<?> clazz)
Random generator uses a pattern to generate a random sequence based on given pattern. |
Object |
get(Class<?> dataTypeName,
String name,
String componentName)
Gets data value by the specified parameters |
Object |
get(Class<?> dataTypeName,
String name,
String componentName,
int sequenceNumber,
boolean isMultivalue)
Gets data value by the specified parameters |
Object |
get(String name)
Acquire a property value for given name |
Object |
get(String name,
int sequenceNumber)
Aquire a property value marked with given iteration, for example i1.testProperty |
Object |
get(String name,
String type,
boolean useDefault)
Main get method. |
Set<Attribute> |
getAttributeSet(String propertySetName)
converts the given property submap to Attribute set. |
Object |
getConnectorAttribute(String propName)
Gets data value by the specified parameters |
String |
getString(String name,
String componentName)
Gets data value by the specified parameters |
String |
getString(String name,
String componentName,
int sequenceNumber)
Gets data value by the specified parameters |
Object |
getTestSuiteAttribute(String propName)
Gets test suite attribute |
Object |
getTestSuiteAttribute(String propName,
String testName)
Gets test suite attribute |
void |
loadConfiguration(String configName,
Configuration cfg)
adds to 'cfg' the complete map defined by property 'propertyName' |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String MULTI_VALUE_TYPE_PREFIX
| Constructor Detail |
|---|
public GroovyDataProvider()
public GroovyDataProvider(String connectorName)
| Method Detail |
|---|
public Object get(String name,
String type,
boolean useDefault)
public Object get(Class<?> dataTypeName,
String name,
String componentName,
int sequenceNumber,
boolean isMultivalue)
get in interface DataProviderisMultivalue - switch between single and multivalue query
public Object get(Class<?> dataTypeName,
String name,
String componentName)
get in interface DataProvider
public String getString(String name,
String componentName,
int sequenceNumber)
getString in interface DataProvider
public String getString(String name,
String componentName)
getString in interface DataProviderpublic Object getTestSuiteAttribute(String propName)
getTestSuiteAttribute in interface DataProvider
public Object getTestSuiteAttribute(String propName,
String testName)
getTestSuiteAttribute in interface DataProviderpublic Object getConnectorAttribute(String propName)
getConnectorAttribute in interface DataProviderpublic Object get(String name)
get in interface DataProvider
public Object generate(String pattern,
Class<?> clazz)
Random generator uses a pattern to generate a random sequence based on given pattern.
the supported characters are (can appear in pattern string):
Any other character inside the pattern is directly printed to the output.
Backslash is used to escape any character. For instance pattern "###\\.##" prints a floating point random number
generate in interface DataProviderpattern - the pattern for generationclazz - the type of returned random object
public Object generate(String pattern)
DataProvider.generate(String, Class)
generate in interface DataProvider
public Object get(String name,
int sequenceNumber)
get in interface DataProvidername - the suffix
public Set<Attribute> getAttributeSet(String propertySetName)
DataProvider
getAttributeSet in interface DataProviderpropertySetName -
Set of attributes
public void loadConfiguration(String configName,
Configuration cfg)
DataProvider
loadConfiguration in interface DataProviderconfigName - cfg - the configuration that will be updated by information from
property 'propertyName'
Sample usage:
static final String DEFAULT_CONFIGURATINON = "configuration.init"
// attempt to create the database in the directory..
config = new ConnectorConfiguration();
// LOAD THE submap in 'configuration' prefix to 'config' object.
dataProvider.loadConfiguration(DEFAULT_CONFIGURATINON, config);
//////// The groovy configuration
// account configurations
configuration{
init.driver="foo"
init.hostName="bar"
init.port="boo"
}
NoSuchFieldException
IllegalAccessException
InvocationTargetException
NoSuchMethodException
SecurityExceptionpublic void dispose()
DataProvider
dispose in interface DataProvider
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||