home | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Groovy example source code file (MixedMarkupTestSupport.groovy)

This example Groovy source code file (MixedMarkupTestSupport.groovy) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

home, home, mixedmarkuptestsupport, mixedmarkuptestsupport

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:

my book on functional programming


new blog posts


Copyright 1998-2019 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.