Search in sources :

Example 1 with PainInstance

use of org.whole.lang.xsd.mapping.samples.PainInstance in project whole by wholeplatform.

the class XsdMappingTest method testPain.

@Category(SlowTests.class)
@Test
public void testPain() throws Exception {
    InputStream is = loader.getResourceAsStream("pain.xsd");
    StreamSource ss = new StreamSource(is);
    Schema schema = factory.newSchema(ss);
    is = loader.getResourceAsStream("pain.xml");
    Validator v = schema.newValidator();
    v.validate(new StreamSource(is));
    is = loader.getResourceAsStream("pain.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 PainInstance().create(), model));
}
Also used : IEntity(org.whole.lang.model.IEntity) InputStream(java.io.InputStream) StreamSource(javax.xml.transform.stream.StreamSource) Schema(javax.xml.validation.Schema) PainInstance(org.whole.lang.xsd.mapping.samples.PainInstance) IPersistenceProvider(org.whole.lang.codebase.IPersistenceProvider) StreamPersistenceProvider(org.whole.lang.codebase.StreamPersistenceProvider) Validator(javax.xml.validation.Validator) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Aggregations

InputStream (java.io.InputStream)1 StreamSource (javax.xml.transform.stream.StreamSource)1 Schema (javax.xml.validation.Schema)1 Validator (javax.xml.validation.Validator)1 Test (org.junit.Test)1 Category (org.junit.experimental.categories.Category)1 IPersistenceProvider (org.whole.lang.codebase.IPersistenceProvider)1 StreamPersistenceProvider (org.whole.lang.codebase.StreamPersistenceProvider)1 IEntity (org.whole.lang.model.IEntity)1 PainInstance (org.whole.lang.xsd.mapping.samples.PainInstance)1