use of org.whole.lang.codebase.StreamPersistenceProvider in project whole by wholeplatform.
the class XsdMappingTest method testDatatypes.
@Category(SlowTests.class)
@Test
public void testDatatypes() throws Exception {
InputStream is = loader.getResourceAsStream("datatypes.xsd");
StreamSource ss = new StreamSource(is);
Schema schema = factory.newSchema(ss);
is = loader.getResourceAsStream("datatypes.xml");
Validator v = schema.newValidator();
v.validate(new StreamSource(is));
is = loader.getResourceAsStream("datatypes.xml");
IPersistenceProvider pp = new StreamPersistenceProvider(is);
pp.getBindings().wDefValue("packageName", "org.whole.lang.xsd.mapping.samples");
IEntity model = XsiPersistenceKit.instance().readModel(pp);
Assert.assertTrue(Matcher.match(new DatatypesInstance().create(), model));
}
use of org.whole.lang.codebase.StreamPersistenceProvider in project whole by wholeplatform.
the class XsiModelTemplateTest method testXsiModelTemplate.
@Category({ KnownFailingTests.class, SlowTests.class })
@Test
public void testXsiModelTemplate() throws Exception {
fail();
IBindingManager bm = BindingManagerFactory.instance.createBindingManager();
bm.wDefValue("folderLocation", new File("test/org/whole/lang/xsd/templates").getAbsolutePath());
bm.wDefValue("packageName", "");
XsdDeployStrategies.setDeployStrategy(bm, XsdDeployStrategies.ALL);
String fileName = "S202SCTDIRPFRAA0001.C.xml";
IEntity xsiModel = XsiPersistenceKit.instance().readModel(new StreamPersistenceProvider(getInputStream(fileName), null, bm));
CommonsEntityFactory.instance.createRootFragment(xsiModel.wGetAdapter(CommonsEntityDescriptorEnum.Any));
IEntity xmlModel = XmlSourcePersistenceKit.instance().readModel(new StreamPersistenceProvider(getInputStream(fileName), null, bm));
CommonsEntityFactory.instance.createRootFragment(xmlModel.wGetAdapter(CommonsEntityDescriptorEnum.Any));
ModelBuilderOperation mop = new ModelBuilderOperation();
XmlNormalizerBuilderOperation xnbo = new XmlNormalizerBuilderOperation(mop);
XsiModelTemplate xsiModelTemplate = new XsiModelTemplate(xsiModel);
xsiModelTemplate.apply(xnbo);
IEntity xmlModelFromXsiModel = mop.wGetResult();
Assert.assertTrue(Matcher.match(xmlModelFromXsiModel, xmlModel));
}
use of org.whole.lang.codebase.StreamPersistenceProvider in project whole by wholeplatform.
the class XsiModelTemplateTest method testXsdModelTemplate.
@Test
public void testXsdModelTemplate() throws Exception {
String pacs002FileName = "pacs.002.001.02S2.xsd";
IEntity xsdPacs002 = loadXMLSchema(pacs002FileName);
CommonsEntityFactory.instance.createRootFragment(xsdPacs002.wGetAdapter(CommonsEntityDescriptorEnum.Any));
IEntity xmlPacs002 = XmlSourcePersistenceKit.instance().readModel(new StreamPersistenceProvider(getInputStream(pacs002FileName)));
CommonsEntityFactory.instance.createRootFragment(xmlPacs002.wGetAdapter(CommonsEntityDescriptorEnum.Any));
ModelBuilderOperation mop = new ModelBuilderOperation();
XmlNormalizerBuilderOperation xnbo = new XmlNormalizerBuilderOperation(mop);
XsdModelTemplate xsdModelTemplate = new XsdModelTemplate(xsdPacs002);
xsdModelTemplate.apply(xnbo);
IEntity xmlModelFromXsdPacs002 = mop.wGetResult();
Assert.assertTrue(OrderedMatcher.match(xmlModelFromXsdPacs002, xmlPacs002, comparatorsMap));
String credTrfFileName = "SCTCcfBlkCredTrf.xsd";
IEntity xsdCredTrf = loadXMLSchema(credTrfFileName);
CommonsEntityFactory.instance.createRootFragment(xsdCredTrf.wGetAdapter(CommonsEntityDescriptorEnum.Any));
IEntity xmlCredTrf = XmlSourcePersistenceKit.instance().readModel(new StreamPersistenceProvider(getInputStream(credTrfFileName)));
CommonsEntityFactory.instance.createRootFragment(xmlCredTrf.wGetAdapter(CommonsEntityDescriptorEnum.Any));
mop = new ModelBuilderOperation();
xnbo = new XmlNormalizerBuilderOperation(mop);
xsdModelTemplate = new XsdModelTemplate(xsdCredTrf);
xsdModelTemplate.apply(xnbo);
IEntity xmlModelFromXsdCredTrf = mop.wGetResult();
Assert.assertTrue(OrderedMatcher.match(xmlModelFromXsdCredTrf, xmlCredTrf, comparatorsMap));
}
use of org.whole.lang.codebase.StreamPersistenceProvider in project whole by wholeplatform.
the class XsdLanguageTest method loadSchemaInstance.
private void loadSchemaInstance(String schemaFileName, String... instanceFileNames) throws Exception {
IBindingManager bm = BindingManagerFactory.instance.createArguments();
String folderLocation = new File("test/org/whole/lang/xsd/util").getAbsolutePath();
bm.wDefValue("folderLocation", folderLocation);
bm.wDefValue("packageName", "");
Schema xsd = loadXsd(schemaFileName);
InterpreterOperation.interpret(xsd, bm);
for (String instanceFileName : instanceFileNames) XsiPersistenceKit.instance().readModel(new StreamPersistenceProvider(getInputStream(instanceFileName)));
}
use of org.whole.lang.codebase.StreamPersistenceProvider in project whole by wholeplatform.
the class XsdLanguageTest method testArtifactsMappedModel.
@Category(KnownFailingTests.class)
@Test
public void testArtifactsMappedModel() {
try {
IBindingManager bm = BindingManagerFactory.instance.createBindingManager();
PathExpression path = new ModelToXmlSchemaQuery().create();
IEntity model = XmlBuilderPersistenceKit.instance().readModel(new ClasspathPersistenceProvider("org/whole/lang/artifacts/ArtifactsModel.xwl"));
Assert.assertNotNull(BehaviorUtils.evaluateFirstResult(path, model, bm));
InterpreterOperation.interpret(bm.wGet("mapping"));
bm.wDefValue("folderLocation", new File("test/org/whole/lang/xsd/util").getAbsolutePath());
bm.wDefValue("packageName", "");
IEntity artifacts = XsiPersistenceKit.instance().readModel(new StreamPersistenceProvider(getInputStream("Artifacts.xml"), null, bm));
Assert.assertTrue(Matcher.match(new Artifacts().create(), artifacts));
} catch (Exception e) {
Assert.fail(e.getMessage());
}
}
Aggregations