Skip to content

Commit e8ac831

Browse files
committed
Added unit test for Cloud element
1 parent cb71be0 commit e8ac831

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@ import spock.lang.Unroll
77
class CategoryTest extends PersisterSpecification {
88

99
@Unroll
10-
def 'category of #object read/write'() {
11-
expect:
10+
def 'category #object read/write'() {
1211

12+
when: 'the object is written to XML'
1313
def output = new StringBuffer()
14-
persister.write(new Category(domain, text), new StringBufferWriter(output))
15-
output.toString() == xml
16-
14+
persister.write(object, new StringBufferWriter(output))
15+
and: 'the XML is read to an object'
1716
def input = persister.read(Category, xml)
18-
input.domain == domain
19-
input.text == text
17+
18+
then: 'the output XML equals the given XML'
19+
output.toString() == xml
20+
and: 'the input object equals the given object'
21+
input == object
2022

2123
where:
2224

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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 CloudTest extends PersisterSpecification {
8+
@Unroll
9+
def 'cloud #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+
and: 'the XML is read to an object'
15+
def input = persister.read(Cloud, xml)
16+
17+
then: 'the output XML equals the given XML'
18+
output.toString() == xml
19+
and: 'the input object equals the given object'
20+
input == object
21+
22+
where:
23+
24+
domain | path | port | protocol | registerProcedure | xml
25+
'testDomain' | 'testPath' | 8080 | 'testProtocol' | 'testRegisterProcedure' | """<cloud domain="$domain" path="$path" port="$port" protocol="$protocol" registerProcedure="$registerProcedure"/>"""
26+
object = new Cloud(domain, path, port, protocol, registerProcedure)
27+
}
28+
}

0 commit comments

Comments
 (0)