public class ScriptableDataSet
extends org.dbunit.dataset.AbstractDataSet
An implementation of a DBUnit IDataSet, that allows the use of
script expressions in its fields. In order to use a certain scripting language in a scriptable data set, a
JSR 223 ("Scripting for the JavaTM Platform")
compatible script engine has to exist for that language.
Using the JRuby engine e.g., a scriptable data set file could look like this:
<dataset>
<location num="jruby:12/2" addr="jruby:'Webster Street'.reverse" date="jruby:DateTime::now() - 14"/>
</dataset>
A ScriptableDataSet can be created as follows:
IDataSet wrapped = ...;
List<ScriptInvocationHandler> handlers = new ArrayList<Class<? extends ScriptInvocationHandler>>();
handlers.add(new JRubyImportAddingInvocationHandler());
IDataSet scriptableDS = new ScriptableDataSet(
wrapped, new ScriptableDataSetConfig("jruby", "jruby:", handlers));
where
ScriptEngineManagerScriptInvocationHandler s,
that can be used to pre-process scripts (e.g. to add common imports) and post-process scripts (e.g. to convert
results into data types understood by DBUnit).| Constructor and Description |
|---|
ScriptableDataSet(org.dbunit.dataset.IDataSet wrapped,
ScriptableDataSetConfig... configurations)
Creates a new ScriptableDataSet.
|
| Modifier and Type | Method and Description |
|---|---|
protected org.dbunit.dataset.ITableIterator |
createIterator(boolean reversed) |
public ScriptableDataSet(org.dbunit.dataset.IDataSet wrapped,
ScriptableDataSetConfig... configurations)
wrapped - Another data set to be wrapped by this scriptable data set. Must not be null.configurations - At least one scriptable data set configuration.Copyright © 2011–2020 hazendaz. All rights reserved.