Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
VOSpace INAF
vospace-datamodel
Commits
2f2268ea
Commit
2f2268ea
authored
Jan 10, 2021
by
Sonia Zorba
Browse files
Renamed protocol to protocols in Transfer class. Added test class
parent
2785b8fb
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/net/ivoa/xml/vospace/v2/Transfer.java
View file @
2f2268ea
...
...
@@ -68,7 +68,7 @@ import javax.xml.bind.annotation.XmlType;
"target"
,
"direction"
,
"view"
,
"protocol"
,
"protocol
s
"
,
"keepBytes"
})
// <edit>
...
...
@@ -81,7 +81,8 @@ public class Transfer {
protected
String
target
;
protected
String
direction
;
protected
View
view
;
protected
List
<
Protocol
>
protocol
;
@XmlElement
(
name
=
"protocol"
)
protected
List
<
Protocol
>
protocols
;
protected
Boolean
keepBytes
;
// <edit> Fix: version is missing in VOSpace XSD
@XmlAttribute
...
...
@@ -182,11 +183,11 @@ public class Transfer {
*
*
*/
public
List
<
Protocol
>
getProtocol
()
{
if
(
protocol
==
null
)
{
protocol
=
new
ArrayList
<
Protocol
>();
public
List
<
Protocol
>
getProtocol
s
()
{
if
(
protocol
s
==
null
)
{
protocol
s
=
new
ArrayList
<>();
}
return
this
.
protocol
;
return
this
.
protocol
s
;
}
/**
...
...
src/test/java/net/ivoa/xml/uws/v1/JobSummaryTest.java
View file @
2f2268ea
...
...
@@ -65,9 +65,12 @@ public class JobSummaryTest {
transfer
.
setVersion
(
"2.1"
);
transfer
.
setTarget
(
"vos://example.com!vospace/mydata1"
);
transfer
.
setDirection
(
"pullFromVoSpace"
);
Protocol
protocol
=
new
Protocol
();
protocol
.
setUri
(
"ivo://ivoa.net/vospace/core#httpget"
);
transfer
.
getProtocol
().
add
(
protocol
);
Protocol
protocol1
=
new
Protocol
();
protocol1
.
setUri
(
"ivo://ivoa.net/vospace/core#httpget"
);
Protocol
protocol2
=
new
Protocol
();
protocol2
.
setUri
(
"ivo://ivoa.net/vospace/core#httpsget"
);
transfer
.
getProtocols
().
add
(
protocol1
);
transfer
.
getProtocols
().
add
(
protocol2
);
jobInfo
.
getAny
().
add
(
transfer
);
...
...
@@ -94,7 +97,7 @@ public class JobSummaryTest {
assertEquals
(
"pullFromVoSpace"
,
transfer
.
getDirection
());
assertEquals
(
"vos://example.com!vospace/mydata1"
,
transfer
.
getTarget
());
Protocol
protocol
=
transfer
.
getProtocol
().
get
(
0
);
Protocol
protocol
=
transfer
.
getProtocol
s
().
get
(
0
);
assertEquals
(
"ivo://ivoa.net/vospace/core#httpget"
,
protocol
.
getUri
());
}
}
src/test/java/net/ivoa/xml/vospace/v2/TransferTest.java
0 → 100644
View file @
2f2268ea
package
net.ivoa.xml.vospace.v2
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
java.io.StringReader
;
import
java.io.StringWriter
;
import
javax.xml.bind.JAXB
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
org.junit.jupiter.api.Test
;
public
class
TransferTest
{
private
static
final
ObjectMapper
MAPPER
=
new
ObjectMapper
();
private
static
final
String
URI_PREFIX
=
"vos://example.com!vospace"
;
@Test
public
void
testXmlSerialization
()
throws
Exception
{
Transfer
transfer
=
getTransfer
();
String
xml
;
try
(
StringWriter
sw
=
new
StringWriter
())
{
JAXB
.
marshal
(
transfer
,
sw
);
xml
=
sw
.
toString
();
System
.
out
.
println
(
xml
);
}
Transfer
deserialized
;
try
(
StringReader
sr
=
new
StringReader
(
xml
))
{
deserialized
=
JAXB
.
unmarshal
(
sr
,
Transfer
.
class
);
}
verifyTransfersAreEquals
(
transfer
,
deserialized
);
}
private
Transfer
getTransfer
()
{
Transfer
transfer
=
new
Transfer
();
transfer
.
setTarget
(
URI_PREFIX
+
"/mynode"
);
transfer
.
setDirection
(
"pullFromVoSpace"
);
Protocol
protocol
=
new
Protocol
();
protocol
.
setUri
(
"ivo://ivoa.net/vospace/core#httpget"
);
protocol
.
setEndpoint
(
"http://ia2.inaf.it/data?param1=value1¶m2=value2"
);
transfer
.
getProtocols
().
add
(
protocol
);
return
transfer
;
}
private
void
verifyTransfersAreEquals
(
Transfer
serialized
,
Transfer
deserialized
)
{
assertEquals
(
serialized
.
getTarget
(),
deserialized
.
getTarget
());
assertEquals
(
serialized
.
getDirection
(),
deserialized
.
getDirection
());
assertEquals
(
serialized
.
getProtocols
().
size
(),
deserialized
.
getProtocols
().
size
());
assertEquals
(
serialized
.
getProtocols
().
get
(
0
).
getEndpoint
(),
deserialized
.
getProtocols
().
get
(
0
).
getEndpoint
());
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment