Search in sources :

Example 26 with StreamPersistenceProvider

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

the class JSONPersistencesTest method testParseAndGenerateWithPrettyPrinter.

@Test
public void testParseAndGenerateWithPrettyPrinter() throws Exception {
    IEntity sampleModel = JSONSourcePersistenceKit.instance().readModel(new StreamPersistenceProvider(getClass().getResourceAsStream("sample.json")));
    assertEquals(sampleString, PrettyPrinterOperation.toPrettyPrintString(sampleModel));
}
Also used : IEntity(org.whole.lang.model.IEntity) StreamPersistenceProvider(org.whole.lang.codebase.StreamPersistenceProvider) Test(org.junit.Test)

Example 27 with StreamPersistenceProvider

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

the class JSONPersistencesTest method testStreamAndBuildParserEquivalence.

@Test
public void testStreamAndBuildParserEquivalence() throws Exception {
    IEntity sampleModelByFactory = JSONSourcePersistenceKit.instance().readModel(new StreamPersistenceProvider(getClass().getResourceAsStream("sample.json")));
    ModelBuilderOperation op = new ModelBuilderOperation();
    new JSONParserTemplateFactory(new JsonFactory().createParser(sampleString)).apply(op);
    IEntity sampleModelByBuilder = ReflectionFactory.makeRootEntity(op.wGetResult());
    assertTrue(Matcher.match(sampleModelByFactory, sampleModelByBuilder));
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation) IEntity(org.whole.lang.model.IEntity) JsonFactory(com.fasterxml.jackson.core.JsonFactory) StreamPersistenceProvider(org.whole.lang.codebase.StreamPersistenceProvider) JSONParserTemplateFactory(org.whole.lang.json.util.JSONParserTemplateFactory) Test(org.junit.Test)

Example 28 with StreamPersistenceProvider

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

the class GrammarsUtilsTest method testUnparseXmlDocument.

@Category(KnownFailingTests.class)
@Test
public void testUnparseXmlDocument() throws Exception {
    IEntity xmlDocument = XmlSourcePersistenceKit.instance().readModel(new StreamPersistenceProvider(getClass().getResourceAsStream("sample.xwl")));
    StringBuilder sb = new StringBuilder();
    GrammarsUtils.unparse(xmlDocument, sb, xmlGrammarURI);
    Assert.assertEquals("FIXME encoding and indentation", sb.toString());
}
Also used : IEntity(org.whole.lang.model.IEntity) StreamPersistenceProvider(org.whole.lang.codebase.StreamPersistenceProvider) 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