Search in sources :

Example 51 with Unmarshaller

use of javax.xml.bind.Unmarshaller in project ORCID-Source by ORCID.

the class ConvertV2ToV2_1Test method upgradeFundingsToV21Test.

@Test
public void upgradeFundingsToV21Test() throws JAXBException {
    JAXBContext jaxbContext1 = JAXBContext.newInstance(Fundings.class);
    JAXBContext jaxbContext2 = JAXBContext.newInstance(Fundings.class);
    Unmarshaller jaxbUnmarshaller = jaxbContext1.createUnmarshaller();
    InputStream v20Stream = ConvertV2ToV2_1Test.class.getClassLoader().getResourceAsStream("test-fundings-2.0.xml");
    InputStream v21Stream = ConvertV2ToV2_1Test.class.getClassLoader().getResourceAsStream("test-fundings-2.1.xml");
    Fundings v20Fundings = (Fundings) jaxbUnmarshaller.unmarshal(v20Stream);
    jaxbUnmarshaller = jaxbContext2.createUnmarshaller();
    Fundings v21Fundings1 = (Fundings) jaxbUnmarshaller.unmarshal(v21Stream);
    V2Convertible result = versionConverterV2_0ToV2_1.upgrade(new V2Convertible(v20Fundings, "v2.1"));
    Fundings v21Fundings2 = (Fundings) result.getObjectToConvert();
    assertEquals(v21Fundings1, v21Fundings2);
}
Also used : V2Convertible(org.orcid.core.version.V2Convertible) Fundings(org.orcid.jaxb.model.record.summary_v2.Fundings) InputStream(java.io.InputStream) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 52 with Unmarshaller

use of javax.xml.bind.Unmarshaller in project ORCID-Source by ORCID.

the class ConvertVrc1ToVrc2Test method upgradePeerReviewsToVrc2Test.

@Test
public void upgradePeerReviewsToVrc2Test() throws JAXBException {
    JAXBContext jaxbContext1 = JAXBContext.newInstance(PeerReviews.class);
    JAXBContext jaxbContext2 = JAXBContext.newInstance(org.orcid.jaxb.model.record.summary_rc2.PeerReviews.class);
    Unmarshaller jaxbUnmarshaller = jaxbContext1.createUnmarshaller();
    InputStream rc1Stream = ConvertVrc1ToVrc2Test.class.getClassLoader().getResourceAsStream("test-peer-reviews-2.0_rc1.xml");
    InputStream rc2Stream = ConvertVrc1ToVrc2Test.class.getClassLoader().getResourceAsStream("test-peer-reviews-2.0_rc2.xml");
    PeerReviews rc1PeerReviews = (PeerReviews) jaxbUnmarshaller.unmarshal(rc1Stream);
    jaxbUnmarshaller = jaxbContext2.createUnmarshaller();
    org.orcid.jaxb.model.record.summary_rc2.PeerReviews rc2PeerReviews1 = (org.orcid.jaxb.model.record.summary_rc2.PeerReviews) jaxbUnmarshaller.unmarshal(rc2Stream);
    V2Convertible result = versionConverterV2_0_rc1ToV2_0_rc2.upgrade(new V2Convertible(rc1PeerReviews, "v2_rc1"));
    org.orcid.jaxb.model.record.summary_rc2.PeerReviews rc2PeerReviews2 = (org.orcid.jaxb.model.record.summary_rc2.PeerReviews) result.getObjectToConvert();
    assertEquals(rc2PeerReviews1.getLastModifiedDate(), rc2PeerReviews2.getLastModifiedDate());
}
Also used : V2Convertible(org.orcid.core.version.V2Convertible) InputStream(java.io.InputStream) PeerReviews(org.orcid.jaxb.model.record.summary_rc1.PeerReviews) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 53 with Unmarshaller

use of javax.xml.bind.Unmarshaller in project ORCID-Source by ORCID.

the class ConvertVrc2ToVrc3Test method upgradeFundingsToVrc3Test.

@Test
public void upgradeFundingsToVrc3Test() throws JAXBException {
    JAXBContext jaxbContext1 = JAXBContext.newInstance(Fundings.class);
    JAXBContext jaxbContext2 = JAXBContext.newInstance(org.orcid.jaxb.model.record.summary_rc3.Fundings.class);
    Unmarshaller jaxbUnmarshaller = jaxbContext1.createUnmarshaller();
    InputStream rc2Stream = ConvertVrc2ToVrc3Test.class.getClassLoader().getResourceAsStream("test-fundings-2.0_rc2.xml");
    InputStream rc3Stream = ConvertVrc2ToVrc3Test.class.getClassLoader().getResourceAsStream("test-fundings-2.0_rc3.xml");
    Fundings rc2Fundings = (Fundings) jaxbUnmarshaller.unmarshal(rc2Stream);
    jaxbUnmarshaller = jaxbContext2.createUnmarshaller();
    org.orcid.jaxb.model.record.summary_rc3.Fundings rc3Fundings1 = (org.orcid.jaxb.model.record.summary_rc3.Fundings) jaxbUnmarshaller.unmarshal(rc3Stream);
    V2Convertible result = versionConverterV2_0_rc2ToV2_0_rc3.upgrade(new V2Convertible(rc2Fundings, "v2_rc2"));
    org.orcid.jaxb.model.record.summary_rc3.Fundings rc3Fundings2 = (org.orcid.jaxb.model.record.summary_rc3.Fundings) result.getObjectToConvert();
    assertEquals(rc3Fundings1, rc3Fundings2);
}
Also used : V2Convertible(org.orcid.core.version.V2Convertible) Fundings(org.orcid.jaxb.model.record.summary_rc2.Fundings) InputStream(java.io.InputStream) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 54 with Unmarshaller

use of javax.xml.bind.Unmarshaller in project ORCID-Source by ORCID.

the class ConvertVrc2ToVrc3Test method upgradeActivitiesToVrc3Test.

@Test
public void upgradeActivitiesToVrc3Test() throws JAXBException {
    JAXBContext jaxbContext1 = JAXBContext.newInstance(ActivitiesSummary.class);
    JAXBContext jaxbContext2 = JAXBContext.newInstance(org.orcid.jaxb.model.record.summary_rc3.ActivitiesSummary.class);
    Unmarshaller jaxbUnmarshaller1 = jaxbContext1.createUnmarshaller();
    Unmarshaller jaxbUnmarshaller2 = jaxbContext2.createUnmarshaller();
    InputStream rc2Stream = ConvertVrc2ToVrc3Test.class.getClassLoader().getResourceAsStream("test-activities-2.0_rc2.xml");
    InputStream rc3Stream = ConvertVrc2ToVrc3Test.class.getClassLoader().getResourceAsStream("test-activities-2.0_rc3.xml");
    ActivitiesSummary rc2Activities = (ActivitiesSummary) jaxbUnmarshaller1.unmarshal(rc2Stream);
    org.orcid.jaxb.model.record.summary_rc3.ActivitiesSummary rc3Activities1 = (org.orcid.jaxb.model.record.summary_rc3.ActivitiesSummary) jaxbUnmarshaller2.unmarshal(rc3Stream);
    V2Convertible result = versionConverterV2_0_rc2ToV2_0_rc3.upgrade(new V2Convertible(rc2Activities, "v2_rc2"));
    org.orcid.jaxb.model.record.summary_rc3.ActivitiesSummary rc3Activities2 = (org.orcid.jaxb.model.record.summary_rc3.ActivitiesSummary) result.getObjectToConvert();
    assertEquals(rc3Activities1, rc3Activities2);
}
Also used : V2Convertible(org.orcid.core.version.V2Convertible) InputStream(java.io.InputStream) JAXBContext(javax.xml.bind.JAXBContext) ActivitiesSummary(org.orcid.jaxb.model.record.summary_rc2.ActivitiesSummary) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 55 with Unmarshaller

use of javax.xml.bind.Unmarshaller in project ORCID-Source by ORCID.

the class ConvertVrc3ToVrc4Test method upgradeActivitiesToVrc3Test.

@Test
public void upgradeActivitiesToVrc3Test() throws JAXBException {
    JAXBContext jaxbContext1 = JAXBContext.newInstance(ActivitiesSummary.class);
    JAXBContext jaxbContext2 = JAXBContext.newInstance(org.orcid.jaxb.model.record.summary_rc4.ActivitiesSummary.class);
    Unmarshaller jaxbUnmarshaller1 = jaxbContext1.createUnmarshaller();
    Unmarshaller jaxbUnmarshaller2 = jaxbContext2.createUnmarshaller();
    InputStream rc3Stream = ConvertVrc3ToVrc4Test.class.getClassLoader().getResourceAsStream("test-activities-2.0_rc3.xml");
    InputStream rc4Stream = ConvertVrc3ToVrc4Test.class.getClassLoader().getResourceAsStream("test-activities-2.0_rc4.xml");
    ActivitiesSummary rc3Activities = (ActivitiesSummary) jaxbUnmarshaller1.unmarshal(rc3Stream);
    org.orcid.jaxb.model.record.summary_rc4.ActivitiesSummary rc4Activities1 = (org.orcid.jaxb.model.record.summary_rc4.ActivitiesSummary) jaxbUnmarshaller2.unmarshal(rc4Stream);
    V2Convertible result = versionConverterV2_0_rc3ToV2_0_rc4.upgrade(new V2Convertible(rc3Activities, "v2_rc3"));
    org.orcid.jaxb.model.record.summary_rc4.ActivitiesSummary rc4Activities2 = (org.orcid.jaxb.model.record.summary_rc4.ActivitiesSummary) result.getObjectToConvert();
    assertEquals(rc4Activities1, rc4Activities2);
}
Also used : V2Convertible(org.orcid.core.version.V2Convertible) InputStream(java.io.InputStream) JAXBContext(javax.xml.bind.JAXBContext) ActivitiesSummary(org.orcid.jaxb.model.record.summary_rc3.ActivitiesSummary) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Aggregations

Unmarshaller (javax.xml.bind.Unmarshaller)292 JAXBContext (javax.xml.bind.JAXBContext)240 JAXBException (javax.xml.bind.JAXBException)97 InputStream (java.io.InputStream)91 Test (org.junit.Test)79 StringReader (java.io.StringReader)40 BaseTest (org.orcid.core.BaseTest)39 V2Convertible (org.orcid.core.version.V2Convertible)39 File (java.io.File)33 InputSource (org.xml.sax.InputSource)22 IOException (java.io.IOException)21 JAXBElement (javax.xml.bind.JAXBElement)18 Marshaller (javax.xml.bind.Marshaller)18 ByteArrayInputStream (java.io.ByteArrayInputStream)17 SAXSource (javax.xml.transform.sax.SAXSource)17 SAXParserFactory (javax.xml.parsers.SAXParserFactory)13 XMLInputFactory (javax.xml.stream.XMLInputFactory)13 XMLStreamException (javax.xml.stream.XMLStreamException)13 XMLStreamReader (javax.xml.stream.XMLStreamReader)13 Schema (javax.xml.validation.Schema)13