Hi Marc,
Thanks a lot for your support.
To make it easier for next users, I'll make a short summary here, how one can
add encoding support to property files
1) add following groovy script into your test file somewhere after you have
groovy task defined.
<groovyScript>
class MyProperty extends org.apache.tools.ant.taskdefs.Property
{
String encoding
protected void loadFile(File file)
{
def text = file.getText(encoding)
def lines = text.split("[\\n\\r]+")
lines.each {
if (!it.startsWith("#")) {
def pos = it.indexOf("=")
if (pos > 0) {
addProperty(it[0..pos-1], it[(pos+1)..-1])
}
}
}
}
}
project.addTaskDefinition "myProperty", MyProperty
</groovyScript>
2) define your property file and encoding
<myProperty file="yourFile.txt" encoding="UTF-8"/>
3) property file should start with comment row
#propertyName=propertyValue
(if doesn't start with comment row, then questionmark will be added somehow in
front of property name (?propertyName) and property value is not resolved)
Mart
PS! It seems that ant properties cannot be used inside step <testInfo>. The
property value still wasn't resolved there while it worked quite ok inside other
steps.
Marc Guillemot wrote:
ups, there were 2 errors in my script: wrong regexp and bad index to get
text before "=".
Following works:
<groovyScript>
class MyProperty extends org.apache.tools.ant.taskdefs.Property
{
String encoding
protected void loadFile(File file)
{
def text = file.getText(encoding)
def lines = text.split("[\\n\\r]+")
lines.each {
if (!it.startsWith("#")) {
def pos = it.indexOf("=")
if (pos > 0) {
addProperty(it[0..pos-1], it[(pos+1)..-1])
}
}
}
}
}
project.addTaskDefinition "myProperty", MyProperty
</groovyScript>
Cheers,
Marc.
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest