use of org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext in project aai-aai-common by onap.
the class StoreNotificationEventTest method testStoreDynamicEventAAIException.
@Test(expected = Exception.class)
public void testStoreDynamicEventAAIException() throws Exception {
DynamicJAXBContext notificationJaxbContext = nodeIngestor.getContextForVersion(schemaVersions.getEdgeLabelVersion());
DynamicEntity obj = Mockito.mock(DynamicEntity.class);
DynamicEntity eventHeader = Mockito.mock(DynamicEntity.class);
sne.storeDynamicEvent(notificationJaxbContext, "v12", eventHeader, obj);
}
use of org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext in project aai-aai-common by onap.
the class NodeIngestorTest method testGetContextForVersion.
@Test
public void testGetContextForVersion() {
DynamicJAXBContext ctx10 = nodeIngestor.getContextForVersion(new SchemaVersion("v10"));
// should work bc Foo is valid in test_network_v10 schema
DynamicEntity foo10 = ctx10.newDynamicEntity("Foo");
foo10.set("fooId", "bar");
assertEquals("bar", foo10.get("fooId"));
// should work bc Bar is valid in test_business_v10 schema
DynamicEntity bar10 = ctx10.newDynamicEntity("Bar");
bar10.set("barId", "bar2");
assertEquals("bar2", bar10.get("barId"));
XSDOutputResolver outputResolver10 = new XSDOutputResolver();
ctx10.generateSchema(outputResolver10);
DynamicJAXBContext ctx11 = nodeIngestor.getContextForVersion(new SchemaVersion("v11"));
// should work bc Foo.quantity is valid in test_network_v11 schema
DynamicEntity foo11 = ctx11.newDynamicEntity("Foo");
foo11.set("quantity", "12");
assertEquals("12", foo11.get("quantity"));
DynamicEntity quux11 = ctx11.newDynamicEntity("Quux");
quux11.set("qManagerName", "some guy");
assertEquals("some guy", quux11.get("qManagerName"));
XSDOutputResolver outputResolver11 = new XSDOutputResolver();
ctx11.generateSchema(outputResolver11);
thrown.expect(IllegalArgumentException.class);
// should fail bc Quux not in v10 test schema
ctx10.newDynamicEntity("Quux");
}
use of org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext in project aai-aai-common by onap.
the class OxmModelLoader method loadModel.
private static synchronized void loadModel(String version, String resourceName, InputStream inputStream) throws JAXBException, IOException {
Map<String, Object> properties = new HashMap<>();
properties.put(JAXBContextProperties.OXM_METADATA_SOURCE, inputStream);
final DynamicJAXBContext jaxbContext = DynamicJAXBContextFactory.createContextFromOXM(Thread.currentThread().getContextClassLoader(), properties);
versionContextMap.put(version, jaxbContext);
LOGGER.info(OxmModelLoaderMsgs.LOADED_OXM_FILE, resourceName);
}
use of org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext in project aai-aai-common by onap.
the class NodeIngestor method translateAll.
private void translateAll(Translator translator) throws ExceptionInInitializerError {
if (translator instanceof ConfigTranslator) {
this.localSchema = "true";
}
Boolean retrieveLocalSchema = Boolean.parseBoolean(this.localSchema);
/*
* Set this to default schemaVersion
*/
this.schemaVersions = translator.getSchemaVersions();
List<SchemaVersion> schemaVersionList = translator.getSchemaVersions().getVersions();
try {
for (SchemaVersion version : schemaVersionList) {
LOGGER.debug("Version being processed" + version);
List<InputStream> inputStreams = retrieveOXM(version, translator);
LOGGER.debug("Retrieved OXMs from SchemaService");
/*
* IOUtils.copy and copy the inputstream
*/
if (inputStreams.isEmpty()) {
continue;
}
final DynamicJAXBContext ctx = ingest(inputStreams);
versionContextMap.put(version, ctx);
setAllTypesAndProperties(version, inputStreams);
schemaPerVersion.put(version, createCombinedSchema(inputStreams, version, retrieveLocalSchema));
}
} catch (JAXBException | ParserConfigurationException | SAXException | IOException e) {
throw new ExceptionInInitializerError(e);
}
}
use of org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext in project eclipselink by eclipse-ee4j.
the class DynamicJAXBFromSessionsXMLTestCases method testSecondProject.
public void testSecondProject() throws Exception {
// Ensure that the second project's descriptor is also available from this context
DynamicEntity emp = ((DynamicJAXBContext) jaxbContext).newDynamicEntity(EMP_CLASS_NAME);
assertNotNull("Could not instantiate Descriptor from second project.", emp);
}
Aggregations