It looks like you have \1 \2 \3 etc in your regex instead of \\1 \\2 \\3.
Just on regex syntax, you can use Groovy's slashy string terminators
abc = /\d\s\1/
and you don't need the double backslashes or alternatively you can use
the multiline regex modifier (?x) and multiline strings so you can write
regex's with formatting and comments like:
re = '''(?x) # to enable whitespace and comments
( # capture the hostname in $1
(?: # these parens for grouping only
(?! [-_] ) # lookahead for neither underscore nor dash
[\\w-] + # hostname component
\\. # and the domain dot
) + # now repeat that whole thing a bunch of times
[A-Za-z] # next must be a letter
[\\w-] + # now trailing domain part
) # end of $1 capture
'''
Cheers, Paul.
Lars Burgess wrote:
Hello,
I have a webtest groovy script which has a verifyXPath call with the
following regex:
// Verify datetime format "DDD MMM dd hh:mm:ss T yyyy"
static final String DATETIME_REGEX =
"^(?=\\d)(?:(?:(?:(?:(?:0?[13578]|1[02])" +
"(\\/|-|\\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])" +
"(\\/|-|\\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\\d)" +
"?\\d{2})|(?:0?2(\\/|-|\\.)29\3(?:(?:(?:1[6-9]|[2-9]\\d)" +
"?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))"
+
"|(?:(?:0?[1-9])|(?:1[0-2]))(\\/|-|\\.)(?:0?[1-9]|1\\d|2[0-8])" +
"\4(?:(?:1[6-9]|[2-9]\\d)?\\d{2}))(\$|\\ (?=\\d)))?(((0?[1-9]|1[012])" +
"(:[0-5]\\d){0,2}(\\ [AP]M))|([01]\\d|2[0-3])(:[0-5]\\d){1,2})?\$"
Webtest throws an exception when trying to write the results to xml:
INFO (com.canoo.webtest.steps.Step) - >>>> Start Step: verifyXPath (7/7)
INFO (com.canoo.webtest.ant.WebtestTask) - Finished executing webtest
"TagLibTest: Positive: Test ContextUtil tag libraries" (: )
ERROR (com.canoo.webtest.ant.WebtestTask) - Exception caught while
writing test report
java.io.IOException: The character '' is an invalid XML character
at org.apache.xml.serialize.BaseMarkupSerializer.fatalError (Unknown
Source)
at org.apache.xml.serialize.BaseMarkupSerializer.surrogates(Unknown
Source)
at org.apache.xml.serialize.XMLSerializer.printEscaped(Unknown Source)
at org.apache.xml.serialize.XMLSerializer.serializeElement (Unknown
Source)
at
org.apache.xml.serialize.BaseMarkupSerializer.serializeNode(Unknown Source)
at org.apache.xml.serialize.XMLSerializer.serializeElement(Unknown
Source)
at org.apache.xml.serialize.BaseMarkupSerializer.serializeNode
(Unknown Source)
at org.apache.xml.serialize.XMLSerializer.serializeElement(Unknown
Source)
at
org.apache.xml.serialize.BaseMarkupSerializer.serializeNode(Unknown Source)
at org.apache.xml.serialize.XMLSerializer.serializeElement (Unknown
Source)
at
org.apache.xml.serialize.BaseMarkupSerializer.serializeNode(Unknown Source)
at org.apache.xml.serialize.XMLSerializer.serializeElement(Unknown
Source)
at org.apache.xml.serialize.BaseMarkupSerializer.serializeNode
(Unknown Source)
at org.apache.xml.serialize.BaseMarkupSerializer.serialize(Unknown
Source)
at
com.canoo.webtest.reporting.XmlReporter.writeXmlFile(XmlReporter.java:70)
at com.canoo.webtest.reporting.XmlReporter.writeXmlFile
(XmlReporter.java:50)
at
com.canoo.webtest.reporting.XmlReporter.generateReport(XmlReporter.java:78)
at com.canoo.webtest.ant.WebtestTask.report(WebtestTask.java:311)
at com.canoo.webtest.ant.WebtestTask.callSelectedReporter
(WebtestTask.java:303)
at
com.canoo.webtest.ant.WebtestTask.writeTestReportIfNeeded(WebtestTask.java:296)
at com.canoo.webtest.ant.WebtestTask.execute(WebtestTask.java:174)
at org.apache.tools.ant.Task.perform (Task.java:364)
at groovy.util.AntBuilder.nodeCompleted(AntBuilder.java:184)
at groovy.util.BuilderSupport.doInvokeMethod(BuilderSupport.java:184)
at groovy.util.AntBuilder.doInvokeMethod(AntBuilder.java :145)
at groovy.util.BuilderSupport.invokeMethod(BuilderSupport.java:95)
at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:136)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod
(InvokerHelper.java:111)
at
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
at
net.webtest.tests.TagLibTest.testContextUtilTags(TagLibTest.groovy:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke (Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected (TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run (TestSuite.java:203)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:210)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet
(AbstractDirectoryTestSuite.java:135)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:122)
at org.apache.maven.surefire.Surefire.run(Surefire.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:225)
at
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java
:747)
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.672 sec
Is there something else I can do so webtest doesn't try to write this
regex to the result file?
Thanks,
Lars
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest