Repository: groovy Updated Branches: refs/heads/GROOVY_2_4_X 342451759 -> c1dda9d86
add XmlJavadocAssertionTest and enable testing of some groovy-xml javadoc examples Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/0c830952 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/0c830952 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/0c830952 Branch: refs/heads/GROOVY_2_4_X Commit: 0c83095287b84a59c252cd5d2fdec9cc982bc4a5 Parents: 3424517 Author: pascalschumacher <[email protected]> Authored: Thu Mar 3 21:33:45 2016 +0100 Committer: pascalschumacher <[email protected]> Committed: Thu Mar 3 23:13:55 2016 +0100 ---------------------------------------------------------------------- .../main/groovy/groovy/xml/StaxBuilder.groovy | 9 ++++--- .../src/main/java/groovy/util/XmlParser.java | 2 +- .../src/main/java/groovy/util/XmlSlurper.java | 4 +-- .../groovy/util/slurpersupport/GPathResult.java | 6 +++-- .../groovy/xml/XmlJavadocAssertionTest.groovy | 27 ++++++++++++++++++++ 5 files changed, 39 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/groovy/blob/0c830952/subprojects/groovy-xml/src/main/groovy/groovy/xml/StaxBuilder.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-xml/src/main/groovy/groovy/xml/StaxBuilder.groovy b/subprojects/groovy-xml/src/main/groovy/groovy/xml/StaxBuilder.groovy index 9ed2879..91dac1e 100644 --- a/subprojects/groovy-xml/src/main/groovy/groovy/xml/StaxBuilder.groovy +++ b/subprojects/groovy-xml/src/main/groovy/groovy/xml/StaxBuilder.groovy @@ -21,19 +21,20 @@ package groovy.xml /** * A Groovy builder that works with Stax processors. * A typical usage is as follows: - * <pre> + * <pre class="groovyTestCase"> + * import javax.xml.stream.XMLOutputFactory * def factory = XMLOutputFactory.newInstance() * def writer = new StringWriter() - * def builder = new StaxBuilder(factory.createXMLStreamWriter(writer)) + * def builder = new groovy.xml.StaxBuilder(factory.createXMLStreamWriter(writer)) * builder.root1(a:5, b:7) { * elem1('hello1') * elem2('hello2') * elem3(x:7) * } - * assert writer.toString() == '<?xml version="1.0" ?><root1 a="5" b="7"><elem1>hello1</elem1><elem2>hello2</elem2><elem3 x="7" /></root1>' + * assert writer.toString() == '<?xml version="1.0" ?><root1 a="5" b="7"><elem1>hello1</elem1><elem2>hello2</elem2><elem3 x="7"></elem3></root1>' * </pre> * Or an external library such as Jettison can be used as follows: - * <pre> + * <pre class="groovyTestCase"> * @Grab('org.codehaus.jettison:jettison:1.2') * import org.codehaus.jettison.mapped.* * import javax.xml.stream.XMLStreamException http://git-wip-us.apache.org/repos/asf/groovy/blob/0c830952/subprojects/groovy-xml/src/main/java/groovy/util/XmlParser.java ---------------------------------------------------------------------- diff --git a/subprojects/groovy-xml/src/main/java/groovy/util/XmlParser.java b/subprojects/groovy-xml/src/main/java/groovy/util/XmlParser.java index 2733e22..40eecb9 100644 --- a/subprojects/groovy-xml/src/main/java/groovy/util/XmlParser.java +++ b/subprojects/groovy-xml/src/main/java/groovy/util/XmlParser.java @@ -57,7 +57,7 @@ import java.util.Map; * most simple use cases of processing XML. * <p> * Example usage: - * <pre> + * <pre class="groovyTestCase"> * def xml = '<root><one a1="uno!"/><two>Some text!</two></root>' * def rootNode = new XmlParser().parseText(xml) * assert rootNode.name() == 'root' http://git-wip-us.apache.org/repos/asf/groovy/blob/0c830952/subprojects/groovy-xml/src/main/java/groovy/util/XmlSlurper.java ---------------------------------------------------------------------- diff --git a/subprojects/groovy-xml/src/main/java/groovy/util/XmlSlurper.java b/subprojects/groovy-xml/src/main/java/groovy/util/XmlSlurper.java index 49ff017..209167f 100644 --- a/subprojects/groovy-xml/src/main/java/groovy/util/XmlSlurper.java +++ b/subprojects/groovy-xml/src/main/java/groovy/util/XmlSlurper.java @@ -56,7 +56,7 @@ import org.xml.sax.helpers.DefaultHandler; /** * Parse XML into a document tree that may be traversed similar to XPath * expressions. For example: - * <pre> + * <pre class="groovyTestCase"> * def rootNode = new XmlSlurper().parseText( * '<root><one a1="uno!"/><two>Some text!</two></root>' ) * @@ -68,7 +68,7 @@ import org.xml.sax.helpers.DefaultHandler; * <p> * Note that in some cases, a 'selector' expression may not resolve to a * single node. For example: - * <pre> + * <pre class="groovyTestCase"> * def rootNode = new XmlSlurper().parseText( * '''<root> * <a>one!</a> http://git-wip-us.apache.org/repos/asf/groovy/blob/0c830952/subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/GPathResult.java ---------------------------------------------------------------------- diff --git a/subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/GPathResult.java b/subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/GPathResult.java index 72ab4fd..4bebe67 100644 --- a/subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/GPathResult.java +++ b/subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/GPathResult.java @@ -374,7 +374,8 @@ public abstract class GPathResult extends GroovyObjectSupport implements Writabl /** * Supports the subscript operator for a GPathResult. - * <pre> + * <pre class="groovyTestCase"> + * import groovy.util.slurpersupport.* * def text = """ * <characterList> * <character/> @@ -416,7 +417,8 @@ public abstract class GPathResult extends GroovyObjectSupport implements Writabl /** * Supports the range subscript operator for a GPathResult. - * <pre> + * <pre class="groovyTestCase"> + * import groovy.util.slurpersupport.* * def text = """ * <characterList> * <character>Wallace</character> http://git-wip-us.apache.org/repos/asf/groovy/blob/0c830952/subprojects/groovy-xml/src/test/groovy/groovy/xml/XmlJavadocAssertionTest.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-xml/src/test/groovy/groovy/xml/XmlJavadocAssertionTest.groovy b/subprojects/groovy-xml/src/test/groovy/groovy/xml/XmlJavadocAssertionTest.groovy new file mode 100644 index 0000000..812cd87 --- /dev/null +++ b/subprojects/groovy-xml/src/test/groovy/groovy/xml/XmlJavadocAssertionTest.groovy @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package groovy.json + +import org.junit.runners.Suite +import org.junit.runner.RunWith + +@RunWith(Suite) [email protected](JavadocAssertionTestSuite) +class XmlJavadocAssertionTest { +}
