File tree Expand file tree Collapse file tree 5 files changed +26
-12
lines changed
groovy/com/github/magneticflux/rss/namespaces/standard/elements
resources/META-INF/services Expand file tree Collapse file tree 5 files changed +26
-12
lines changed Original file line number Diff line number Diff line change 11package com.github.magneticflux.rss.namespaces.standard.elements
22
33import com.github.magneticflux.rss.PersisterSpecification
4- import org.codehaus.groovy.runtime.StringBufferWriter
54import spock.lang.Unroll
65
76class CategoryTest extends PersisterSpecification {
@@ -10,11 +9,10 @@ class CategoryTest extends PersisterSpecification {
109 def ' category #object read/write' () {
1110
1211 when : ' the object is written to XML'
13- def output = new StringBuffer ()
14- persister. write(object, new StringBufferWriter (output))
12+ def output = persister. write(object)
1513
1614 then : ' the output XML equals the given XML'
17- output. toString() == xml
15+ output == xml
1816
1917 when : ' the XML is read to an object'
2018 def input = persister. read(Category , xml)
Original file line number Diff line number Diff line change 11package com.github.magneticflux.rss.namespaces.standard.elements
22
33import com.github.magneticflux.rss.PersisterSpecification
4- import org.codehaus.groovy.runtime.StringBufferWriter
54import spock.lang.Unroll
65
76class CloudTest extends PersisterSpecification {
87 @Unroll
98 def ' cloud #object read/write' () {
109
1110 when : ' the object is written to XML'
12- def output = new StringBuffer ()
13- persister. write(object, new StringBufferWriter (output))
11+ def output = persister. write(object)
1412
1513 then : ' the output XML equals the given XML'
16- output. toString() == xml
14+ output == xml
1715
1816 when : ' the XML is read to an object'
1917 def input = persister. read(Cloud , xml)
Original file line number Diff line number Diff line change 11package com.github.magneticflux.rss.namespaces.standard.elements
22
33import com.github.magneticflux.rss.PersisterSpecification
4- import org.codehaus.groovy.runtime.StringBufferWriter
54import spock.lang.Unroll
65
76class EnclosureTest extends PersisterSpecification {
87 @Unroll
98 def ' enclosure #object read/write' () {
109
1110 when : ' the object is written to XML'
12- def output = new StringBuffer ()
13- persister. write(object, new StringBufferWriter (output))
11+ def output = persister. write(object)
1412
1513 then : ' the output XML equals the given XML'
16- output. toString() == xml
14+ output == xml
1715
1816 when : ' the XML is read to an object'
1917 def input = persister. read(Enclosure , xml)
Original file line number Diff line number Diff line change 1+ package com.github.magneticflux.rss
2+
3+ import org.codehaus.groovy.runtime.StringBufferWriter
4+ import org.simpleframework.xml.core.Persister
5+
6+ /* *
7+ * This extension function helps getting XML data from a persister as a String.
8+ *
9+ * @param any the object to write
10+ * @return a String containing the written XML
11+ * @receiver the persister with which to write the XML
12+ */
13+ fun Persister.write (any : Any ): String {
14+ val buffer = StringBuffer ()
15+ this .write(any, StringBufferWriter (buffer))
16+ return buffer.toString()
17+ }
Original file line number Diff line number Diff line change 1+ moduleName=persister-module
2+ moduleVersion=1.0
3+ extensionClasses=com.github.magneticflux.rss.PersisterUtilsKt
You can’t perform that action at this time.
0 commit comments