Loading src/main/java/net/ivoa/xml/vospace/v2/Transfer.java +7 −6 Original line number Original line Diff line number Diff line Loading @@ -68,7 +68,7 @@ import javax.xml.bind.annotation.XmlType; "target", "target", "direction", "direction", "view", "view", "protocol", "protocols", "keepBytes" "keepBytes" }) }) // <edit> // <edit> Loading @@ -81,7 +81,8 @@ public class Transfer { protected String target; protected String target; protected String direction; protected String direction; protected View view; protected View view; protected List<Protocol> protocol; @XmlElement(name = "protocol") protected List<Protocol> protocols; protected Boolean keepBytes; protected Boolean keepBytes; // <edit> Fix: version is missing in VOSpace XSD // <edit> Fix: version is missing in VOSpace XSD @XmlAttribute @XmlAttribute Loading Loading @@ -182,11 +183,11 @@ public class Transfer { * * * * */ */ public List<Protocol> getProtocol() { public List<Protocol> getProtocols() { if (protocol == null) { if (protocols == null) { protocol = new ArrayList<Protocol>(); protocols = new ArrayList<>(); } } return this.protocol; return this.protocols; } } /** /** Loading src/test/java/net/ivoa/xml/uws/v1/JobSummaryTest.java +7 −4 Original line number Original line Diff line number Diff line Loading @@ -65,9 +65,12 @@ public class JobSummaryTest { transfer.setVersion("2.1"); transfer.setVersion("2.1"); transfer.setTarget("vos://example.com!vospace/mydata1"); transfer.setTarget("vos://example.com!vospace/mydata1"); transfer.setDirection("pullFromVoSpace"); transfer.setDirection("pullFromVoSpace"); Protocol protocol = new Protocol(); Protocol protocol1 = new Protocol(); protocol.setUri("ivo://ivoa.net/vospace/core#httpget"); protocol1.setUri("ivo://ivoa.net/vospace/core#httpget"); transfer.getProtocol().add(protocol); Protocol protocol2= new Protocol(); protocol2.setUri("ivo://ivoa.net/vospace/core#httpsget"); transfer.getProtocols().add(protocol1); transfer.getProtocols().add(protocol2); jobInfo.getAny().add(transfer); jobInfo.getAny().add(transfer); Loading @@ -94,7 +97,7 @@ public class JobSummaryTest { assertEquals("pullFromVoSpace", transfer.getDirection()); assertEquals("pullFromVoSpace", transfer.getDirection()); assertEquals("vos://example.com!vospace/mydata1", transfer.getTarget()); assertEquals("vos://example.com!vospace/mydata1", transfer.getTarget()); Protocol protocol = transfer.getProtocol().get(0); Protocol protocol = transfer.getProtocols().get(0); assertEquals("ivo://ivoa.net/vospace/core#httpget", protocol.getUri()); assertEquals("ivo://ivoa.net/vospace/core#httpget", protocol.getUri()); } } } } src/test/java/net/ivoa/xml/vospace/v2/TransferTest.java 0 → 100644 +58 −0 Original line number Original line Diff line number Diff line 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()); } } Loading
src/main/java/net/ivoa/xml/vospace/v2/Transfer.java +7 −6 Original line number Original line Diff line number Diff line Loading @@ -68,7 +68,7 @@ import javax.xml.bind.annotation.XmlType; "target", "target", "direction", "direction", "view", "view", "protocol", "protocols", "keepBytes" "keepBytes" }) }) // <edit> // <edit> Loading @@ -81,7 +81,8 @@ public class Transfer { protected String target; protected String target; protected String direction; protected String direction; protected View view; protected View view; protected List<Protocol> protocol; @XmlElement(name = "protocol") protected List<Protocol> protocols; protected Boolean keepBytes; protected Boolean keepBytes; // <edit> Fix: version is missing in VOSpace XSD // <edit> Fix: version is missing in VOSpace XSD @XmlAttribute @XmlAttribute Loading Loading @@ -182,11 +183,11 @@ public class Transfer { * * * * */ */ public List<Protocol> getProtocol() { public List<Protocol> getProtocols() { if (protocol == null) { if (protocols == null) { protocol = new ArrayList<Protocol>(); protocols = new ArrayList<>(); } } return this.protocol; return this.protocols; } } /** /** Loading
src/test/java/net/ivoa/xml/uws/v1/JobSummaryTest.java +7 −4 Original line number Original line Diff line number Diff line Loading @@ -65,9 +65,12 @@ public class JobSummaryTest { transfer.setVersion("2.1"); transfer.setVersion("2.1"); transfer.setTarget("vos://example.com!vospace/mydata1"); transfer.setTarget("vos://example.com!vospace/mydata1"); transfer.setDirection("pullFromVoSpace"); transfer.setDirection("pullFromVoSpace"); Protocol protocol = new Protocol(); Protocol protocol1 = new Protocol(); protocol.setUri("ivo://ivoa.net/vospace/core#httpget"); protocol1.setUri("ivo://ivoa.net/vospace/core#httpget"); transfer.getProtocol().add(protocol); Protocol protocol2= new Protocol(); protocol2.setUri("ivo://ivoa.net/vospace/core#httpsget"); transfer.getProtocols().add(protocol1); transfer.getProtocols().add(protocol2); jobInfo.getAny().add(transfer); jobInfo.getAny().add(transfer); Loading @@ -94,7 +97,7 @@ public class JobSummaryTest { assertEquals("pullFromVoSpace", transfer.getDirection()); assertEquals("pullFromVoSpace", transfer.getDirection()); assertEquals("vos://example.com!vospace/mydata1", transfer.getTarget()); assertEquals("vos://example.com!vospace/mydata1", transfer.getTarget()); Protocol protocol = transfer.getProtocol().get(0); Protocol protocol = transfer.getProtocols().get(0); assertEquals("ivo://ivoa.net/vospace/core#httpget", protocol.getUri()); assertEquals("ivo://ivoa.net/vospace/core#httpget", protocol.getUri()); } } } }
src/test/java/net/ivoa/xml/vospace/v2/TransferTest.java 0 → 100644 +58 −0 Original line number Original line Diff line number Diff line 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()); } }