Skip to content

Commit d5e13a3

Browse files
committed
Added unit test for Enclosure element
1 parent e8ac831 commit d5e13a3

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed

src/test/groovy/com/github/magneticflux/rss/namespaces/standard/elements/CategoryTest.groovy

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@ class CategoryTest extends PersisterSpecification {
1212
when: 'the object is written to XML'
1313
def output = new StringBuffer()
1414
persister.write(object, new StringBufferWriter(output))
15-
and: 'the XML is read to an object'
16-
def input = persister.read(Category, xml)
1715

1816
then: 'the output XML equals the given XML'
1917
output.toString() == xml
20-
and: 'the input object equals the given object'
18+
19+
when: 'the XML is read to an object'
20+
def input = persister.read(Category, xml)
21+
22+
then: 'the input object equals the given object'
2123
input == object
2224

2325
where:
24-
2526
domain | text | xml
2627
'testDomain' | 'testText' | """<category domain="$domain">$text</category>"""
2728
null | 'testText' | """<category>$text</category>"""

src/test/groovy/com/github/magneticflux/rss/namespaces/standard/elements/CloudTest.groovy

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@ class CloudTest extends PersisterSpecification {
1111
when: 'the object is written to XML'
1212
def output = new StringBuffer()
1313
persister.write(object, new StringBufferWriter(output))
14-
and: 'the XML is read to an object'
15-
def input = persister.read(Cloud, xml)
1614

1715
then: 'the output XML equals the given XML'
1816
output.toString() == xml
19-
and: 'the input object equals the given object'
17+
18+
when: 'the XML is read to an object'
19+
def input = persister.read(Cloud, xml)
20+
21+
then: 'the input object equals the given object'
2022
input == object
2123

2224
where:
23-
2425
domain | path | port | protocol | registerProcedure | xml
2526
'testDomain' | 'testPath' | 8080 | 'testProtocol' | 'testRegisterProcedure' | """<cloud domain="$domain" path="$path" port="$port" protocol="$protocol" registerProcedure="$registerProcedure"/>"""
2627
object = new Cloud(domain, path, port, protocol, registerProcedure)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.github.magneticflux.rss.namespaces.standard.elements
2+
3+
import com.github.magneticflux.rss.PersisterSpecification
4+
import org.codehaus.groovy.runtime.StringBufferWriter
5+
import spock.lang.Unroll
6+
7+
class EnclosureTest extends PersisterSpecification {
8+
@Unroll
9+
def 'enclosure #object read/write'() {
10+
11+
when: 'the object is written to XML'
12+
def output = new StringBuffer()
13+
persister.write(object, new StringBufferWriter(output))
14+
15+
then: 'the output XML equals the given XML'
16+
output.toString() == xml
17+
18+
when: 'the XML is read to an object'
19+
def input = persister.read(Enclosure, xml)
20+
21+
then: 'the input object equals the given object'
22+
input == object
23+
24+
where:
25+
url | length | type | xml
26+
'http://www.example.com'.toURL() | 1000 | 'testType' | """<enclosure url="$url" length="$length" type="$type"/>"""
27+
object = new Enclosure(url, length, type)
28+
}
29+
}

0 commit comments

Comments
 (0)