Search in sources :

Example 11 with StreamPersistenceProvider

use of org.whole.lang.codebase.StreamPersistenceProvider in project whole by wholeplatform.

the class XsdMappingTest method testMaven.

@Category(SlowTests.class)
@Test
public void testMaven() throws Exception {
    InputStream is = loader.getResourceAsStream("maven-v4_0_0.xsd");
    StreamSource ss = new StreamSource(is);
    Schema schema = factory.newSchema(ss);
    is = loader.getResourceAsStream("maven-v4_0_0.xml");
    Validator v = schema.newValidator();
    v.validate(new StreamSource(is));
    is = loader.getResourceAsStream("maven-v4_0_0.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 Maven400Instance().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) IPersistenceProvider(org.whole.lang.codebase.IPersistenceProvider) StreamPersistenceProvider(org.whole.lang.codebase.StreamPersistenceProvider) Maven400Instance(org.whole.lang.xsd.mapping.samples.Maven400Instance) Validator(javax.xml.validation.Validator) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 12 with StreamPersistenceProvider

use of org.whole.lang.codebase.StreamPersistenceProvider in project whole by wholeplatform.

the class XsdMappingTest method testSimpleContent.

// Requires an Internet connection
// FIXME remove KnownFailingTests
@Category({ SlowTests.class, KnownFailingTests.class })
@Test
public void testSimpleContent() throws Exception {
    InputStream is = loader.getResourceAsStream("simpleContent.xsd");
    StreamSource ss = new StreamSource(is);
    Schema schema = factory.newSchema(ss);
    is = loader.getResourceAsStream("simpleContent.xml");
    Validator v = schema.newValidator();
    v.validate(new StreamSource(is));
    is = loader.getResourceAsStream("simpleContent.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 SimpleContentInstance().create(), model));
}
Also used : SimpleContentInstance(org.whole.lang.xsd.mapping.samples.SimpleContentInstance) IEntity(org.whole.lang.model.IEntity) InputStream(java.io.InputStream) StreamSource(javax.xml.transform.stream.StreamSource) Schema(javax.xml.validation.Schema) 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)

Example 13 with StreamPersistenceProvider

use of org.whole.lang.codebase.StreamPersistenceProvider in project whole by wholeplatform.

the class XsdMappingTest method testChoiceSample.

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

Example 14 with StreamPersistenceProvider

use of org.whole.lang.codebase.StreamPersistenceProvider in project whole by wholeplatform.

the class XsdMappingTest method testFreemind.

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

Example 15 with StreamPersistenceProvider

use of org.whole.lang.codebase.StreamPersistenceProvider 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

StreamPersistenceProvider (org.whole.lang.codebase.StreamPersistenceProvider)28 IEntity (org.whole.lang.model.IEntity)24 Test (org.junit.Test)20 Category (org.junit.experimental.categories.Category)13 InputStream (java.io.InputStream)12 StreamSource (javax.xml.transform.stream.StreamSource)9 Schema (javax.xml.validation.Schema)9 Validator (javax.xml.validation.Validator)9 IPersistenceProvider (org.whole.lang.codebase.IPersistenceProvider)9 IBindingManager (org.whole.lang.bindings.IBindingManager)4 ModelBuilderOperation (org.whole.lang.builders.ModelBuilderOperation)4 ModelTemplate (org.whole.lang.templates.ModelTemplate)4 File (java.io.File)3 IPersistenceKit (org.whole.lang.codebase.IPersistenceKit)3 XmlNormalizerBuilderOperation (org.whole.lang.xml.codebase.XmlNormalizerBuilderOperation)3 JsonFactory (com.fasterxml.jackson.core.JsonFactory)2 PrintWriter (java.io.PrintWriter)2 StringPersistenceProvider (org.whole.lang.codebase.StringPersistenceProvider)2 XmlPrettyPrinterBuilderOperation (org.whole.lang.xml.codebase.XmlPrettyPrinterBuilderOperation)2 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1