|
Groovy example source code file (MixedMarkupTestSupport.groovy)
The Groovy MixedMarkupTestSupport.groovy source code
package groovy.xml
class MixedMarkupTestSupport {
private static def mixedXml = '''
<p>Please read the Home page
'''
static void checkMixedMarkup(Closure getRoot) {
def root = getRoot(mixedXml)
assert root != null
def children = root.children()
if (isSlurper(root)) {
assert children.size() == 1
assert children[0].name() == 'a'
} else {
assert children.size() == 3
assert children[1].name() == 'a'
if (isParser(root)) {
assert children[2] == 'page'
} else {
assert children[2].text() == 'page'
}
}
}
private static boolean isSlurper(node) {
return node.getClass().name.contains('slurper')
}
private static boolean isParser(node) {
return (node instanceof groovy.util.Node)
}
private static boolean isDom(node) {
return node.getClass().name.contains('Element')
}
}
Other Groovy examples (source code examples)Here is a short list of links related to this Groovy MixedMarkupTestSupport.groovy source code file: |
Other websites by Alvin Alexander:
Life/living in Alaska (OneMansAlaska.com)
How I Sold My Business (HowISoldMyBusiness.com)
Copyright 1998-2011 Alvin Alexander, devdaily.com
All Rights Reserved.