use of javax.xml.bind.JAXBContext in project opennms by OpenNMS.
the class MarshallTest method setUp.
@Before
public void setUp() throws JAXBException {
// Create a Marshaller
JAXBContext context = JAXBContext.newInstance(ServiceAlarmNotification.class);
m_marshaller = context.createMarshaller();
m_marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
m_unmarshaller = context.createUnmarshaller();
}
use of javax.xml.bind.JAXBContext in project ORCID-Source by ORCID.
the class JpaJaxbOtherNameAdapterTest method getOtherName.
private OtherName getOtherName() throws JAXBException {
JAXBContext context = JAXBContext.newInstance(new Class[] { OtherName.class });
Unmarshaller unmarshaller = context.createUnmarshaller();
String name = "/record_2.0/samples/read_samples/other-name-2.0.xml";
InputStream inputStream = getClass().getResourceAsStream(name);
return (OtherName) unmarshaller.unmarshal(inputStream);
}
use of javax.xml.bind.JAXBContext in project ORCID-Source by ORCID.
the class JpaJaxbExternalIdentifierAdapterTest method getExternalIdentifier.
private PersonExternalIdentifier getExternalIdentifier() throws JAXBException {
JAXBContext context = JAXBContext.newInstance(new Class[] { PersonExternalIdentifier.class });
Unmarshaller unmarshaller = context.createUnmarshaller();
String name = "/record_2.0/samples/read_samples/external-identifier-2.0.xml";
InputStream inputStream = getClass().getResourceAsStream(name);
return (PersonExternalIdentifier) unmarshaller.unmarshal(inputStream);
}
use of javax.xml.bind.JAXBContext in project ORCID-Source by ORCID.
the class JpaJaxbEmploymentAdapterTest method getEmployment.
private Employment getEmployment(boolean full) throws JAXBException {
JAXBContext context = JAXBContext.newInstance(new Class[] { Employment.class });
Unmarshaller unmarshaller = context.createUnmarshaller();
String name = "/record_2.0/samples/read_samples/employment-2.0.xml";
if (full) {
name = "/record_2.0/samples/read_samples/employment-full-2.0.xml";
}
InputStream inputStream = getClass().getResourceAsStream(name);
return (Employment) unmarshaller.unmarshal(inputStream);
}
use of javax.xml.bind.JAXBContext in project ORCID-Source by ORCID.
the class ConvertV2ToV2_1Test method upgradePeerReviewsToV21Test.
@Test
public void upgradePeerReviewsToV21Test() throws JAXBException {
JAXBContext jaxbContext1 = JAXBContext.newInstance(PeerReviews.class);
JAXBContext jaxbContext2 = JAXBContext.newInstance(PeerReviews.class);
Unmarshaller jaxbUnmarshaller = jaxbContext1.createUnmarshaller();
InputStream v20Stream = ConvertV2ToV2_1Test.class.getClassLoader().getResourceAsStream("test-peer-reviews-2.0.xml");
InputStream v21Stream = ConvertV2ToV2_1Test.class.getClassLoader().getResourceAsStream("test-peer-reviews-2.1.xml");
PeerReviews v20PeerReviews = (PeerReviews) jaxbUnmarshaller.unmarshal(v20Stream);
jaxbUnmarshaller = jaxbContext2.createUnmarshaller();
PeerReviews v21PeerReviews1 = (PeerReviews) jaxbUnmarshaller.unmarshal(v21Stream);
V2Convertible result = versionConverterV2_0ToV2_1.upgrade(new V2Convertible(v20PeerReviews, "v2.1"));
PeerReviews v21PeerReviews2 = (PeerReviews) result.getObjectToConvert();
assertEquals(v21PeerReviews1, v21PeerReviews2);
}
Aggregations