use of net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap in project n2o-framework by i-novus-llc.
the class RouterTest method setUp.
@Before
public void setUp() {
N2oEnvironment env = new N2oEnvironment();
env.setSystemProperties(new SimplePropertyResolver(new Properties()));
env.setNamespacePersisterFactory(new PersisterFactoryByMap());
env.setNamespaceReaderFactory(new ReaderFactoryByMap());
builder = new N2oApplicationBuilder(env).packs(new N2oOperationsPack());
}
use of net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap in project n2o-framework by i-novus-llc.
the class N2oApplicationBuilderTest method test.
@Test
@Ignore
public void test() {
ReadCompileBindTerminalPipeline pipeline = new N2oApplicationBuilder().scanners(new MockInfoScanner()).loaders(new XmlMetadataLoader(new ReaderFactoryByMap().register(new SimplePageElementIOv3()))).compilers(new StandardPageCompiler()).sources(new XmlInfo("test", N2oPage.class, "classpath:", "net/n2oapp/framework/config/test.page.xml")).routes(new RouteInfo("/test", new PageContext("test"))).propertySources("application-test.properties").scan().read().compile().bind();
new N2oApplicationBuilder().compile().copy().cache().bind();
// new N2oApplicationBuilder().read().cache().validate().persist().set(null);
// new N2oApplicationBuilder().read().merge().get()
Page page = pipeline.get(new PageContext("test"), new DataSet());
}
use of net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap in project n2o-framework by i-novus-llc.
the class IOProcessorTest method testChildren.
@Test
public void testChildren() throws Exception {
ReaderFactoryByMap readerFactory = new ReaderFactoryByMap();
readerFactory.register(new BodyNamespaceEntityIO());
IOProcessor p = new IOProcessorImpl(readerFactory);
Element in1 = dom("net/n2oapp/framework/config/io/ioprocessor12.xml");
Element in2 = dom("net/n2oapp/framework/config/io/ioprocessor15.xml");
ChildrenEntityList childrenEntityList1 = new ChildrenEntityList();
ChildrenEntityList childrenEntityList2 = new ChildrenEntityList();
p.children(in1, "children", "el1", childrenEntityList1::getChildEntities, childrenEntityList1::setChildEntities, IOProcessorTest.ChildEntity::new, this::children);
p.children(in2, null, "el1", childrenEntityList2::getChildEntities, childrenEntityList2::setChildEntities, IOProcessorTest.ChildEntity::new, this::children);
assertThat(childrenEntityList1.getChildEntities().length, equalTo(3));
assertThat(childrenEntityList1.getChildEntities()[0].getAtt(), equalTo("test1"));
assertThat(childrenEntityList1.getChildEntities()[1].getAtt(), equalTo("test2"));
assertThat(childrenEntityList1.getChildEntities()[2].getAtt(), equalTo("test3"));
assertThat(childrenEntityList2.getChildEntities().length, equalTo(3));
assertThat(childrenEntityList2.getChildEntities()[0].getAtt(), equalTo("test1"));
assertThat(childrenEntityList2.getChildEntities()[1].getAtt(), equalTo("test2"));
assertThat(childrenEntityList2.getChildEntities()[2].getAtt(), equalTo("test3"));
PersisterFactoryByMap persisterFactory = new PersisterFactoryByMap();
persisterFactory.register(new BodyNamespaceEntityIO());
p = new IOProcessorImpl(persisterFactory);
Element out1 = new Element("test", Namespace.getNamespace("http://example.com/n2o/ext-1.0"));
Element out2 = new Element("test", Namespace.getNamespace("http://example.com/n2o/ext-1.0"));
p.children(out1, "children", "el1", childrenEntityList1::getChildEntities, childrenEntityList1::setChildEntities, IOProcessorTest.ChildEntity::new, this::children);
p.children(out2, null, "el1", childrenEntityList2::getChildEntities, childrenEntityList2::setChildEntities, IOProcessorTest.ChildEntity::new, this::children);
assertThat(in1, isSimilarTo(out1));
assertThat(in2, isSimilarTo(out2));
}
use of net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap in project n2o-framework by i-novus-llc.
the class IOProcessorTest method testChildrenToMap.
@Test
public void testChildrenToMap() throws Exception {
ReaderFactoryByMap readerFactory = new ReaderFactoryByMap();
IOProcessor pR = new IOProcessorImpl(readerFactory);
readerFactory.register(new BodyNamespaceEntityIO());
Element in = dom("net/n2oapp/framework/config/io/ioprocessor7.xml");
MapNamespaceEntity map = new MapNamespaceEntity();
pR.childrenToMap(in, "children", "el2", "attr", null, map::getEntityMap, map::setEntityMap);
assertThat(map.getEntityMap().get("1"), equalTo(1));
assertThat(map.getEntityMap().get("test2"), equalTo("test2"));
PersisterFactoryByMap persisterFactory = new PersisterFactoryByMap();
persisterFactory.register(new BodyNamespaceEntityIO());
IOProcessor pW = new IOProcessorImpl(persisterFactory);
Element out = new Element("test", Namespace.getNamespace("http://example.com/n2o/ext-1.0"));
pW.childrenToMap(out, "children", "el2", "attr", null, map::getEntityMap, map::setEntityMap);
assertThat(in, isSimilarTo(out));
map.entityMap.clear();
in = dom("net/n2oapp/framework/config/io/ioprocessor24.xml");
pR.childrenToMap(in, "children", "el", map::getEntityMap, map::setEntityMap);
assertThat(map.getEntityMap().get("attr"), equalTo(1));
assertThat(map.getEntityMap().get("attr1"), equalTo("test1"));
out = new Element("test", Namespace.getNamespace("http://example.com/n2o/ext-1.0"));
pW.childrenToMap(out, "children", "el", map::getEntityMap, map::setEntityMap);
assertThat(in, isSimilarTo(out));
}
use of net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap in project n2o-framework by i-novus-llc.
the class IOProcessorTest method testElement.
@Test
public void testElement() throws Exception {
ReaderFactoryByMap readerFactory = new ReaderFactoryByMap();
readerFactory.register(new BodyNamespaceEntityIO());
IOProcessor p = new IOProcessorImpl(readerFactory);
Element in = dom("net/n2oapp/framework/config/io/ioprocessor17.xml");
BaseEntity baseEntity = new BaseEntity();
p.element(in, "attr", baseEntity::getAttr, baseEntity::setAttr);
assertThat(baseEntity.getAttr(), equalTo("test"));
PersisterFactoryByMap persisterFactory = new PersisterFactoryByMap();
persisterFactory.register(new BodyNamespaceEntityIO());
p = new IOProcessorImpl(persisterFactory);
Element out = new Element("test", Namespace.getNamespace("http://example.com/n2o/ext-1.0"));
p.element(out, "attr", baseEntity::getAttr, baseEntity::setAttr);
assertThat(in, isSimilarTo(out));
}
Aggregations