use of net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap in project n2o-framework by i-novus-llc.
the class IOProcessorTest method testChildrenToMapString.
@Test
public void testChildrenToMapString() throws Exception {
ReaderFactoryByMap readerFactory = new ReaderFactoryByMap();
IOProcessor p = new IOProcessorImpl(readerFactory);
readerFactory.register(new BodyNamespaceEntityIO());
Element in = dom("net/n2oapp/framework/config/io/ioprocessor7.xml");
MapStringNamespaceEntity map = new MapStringNamespaceEntity();
p.childrenToStringMap(in, "children", "el2", "attr", null, map::getEntityStringMap, map::setEntityStringMap);
assertThat(map.getEntityStringMap().get("1"), equalTo("1"));
assertThat(map.getEntityStringMap().get("test2"), equalTo("test2"));
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.childrenToStringMap(out, "children", "el2", "attr", null, map::getEntityStringMap, map::setEntityStringMap);
assertThat(in, isSimilarTo(out));
}
use of net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap in project n2o-framework by i-novus-llc.
the class N2oTestBase method setUp.
public void setUp() throws Exception {
N2oEnvironment environment = new N2oEnvironment();
environment.setNamespacePersisterFactory(new PersisterFactoryByMap());
environment.setNamespaceReaderFactory(new ReaderFactoryByMap());
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.addBasenames("n2o_api_messages", "n2o_api_messages", "n2o_config_messages", "test_messages", "messages");
messageSource.setDefaultEncoding("UTF-8");
Locale locale = new Locale("ru");
LocaleContextHolder.setLocale(locale);
environment.setMessageSource(new MessageSourceAccessor(messageSource));
OverrideProperties n2oProperties = PropertiesReader.getPropertiesFromClasspath("META-INF/n2o.properties");
OverrideProperties appProperties = PropertiesReader.getPropertiesFromClasspath("application.properties");
appProperties.setBaseProperties(n2oProperties);
environment.setSystemProperties(new SimplePropertyResolver(appProperties));
builder = new N2oApplicationBuilder(environment);
configure(builder);
CompileInfo.setSourceTypes(builder.getEnvironment().getSourceTypeRegister());
}
use of net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap in project n2o-framework by i-novus-llc.
the class IOProcessorTest method testChild.
@Test
public void testChild() throws Exception {
ReaderFactoryByMap readerFactory = new ReaderFactoryByMap();
readerFactory.register(new BodyNamespaceEntityIO());
IOProcessor p = new IOProcessorImpl(readerFactory);
Element in1 = dom("net/n2oapp/framework/config/io/ioprocessor13.xml");
Element in2 = dom("net/n2oapp/framework/config/io/ioprocessor14.xml");
ChildEntity childrenEntity1 = new ChildEntity();
ChildEntity childrenEntity2 = new ChildEntity();
p.child(in1, "children", "el1", childrenEntity1::getChild, childrenEntity1::setChild, IOProcessorTest.ChildEntity::new, this::children);
p.child(in2, null, "el1", childrenEntity2::getChild, childrenEntity2::setChild, IOProcessorTest.ChildEntity::new, this::children);
assertThat(childrenEntity1.getChild().getAtt(), equalTo("test1"));
assertThat(childrenEntity2.getChild().getAtt(), equalTo("test1"));
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.child(out1, "children", "el1", childrenEntity1::getChild, childrenEntity1::setChild, IOProcessorTest.ChildEntity::new, this::children);
p.child(out2, null, "el1", childrenEntity2::getChild, childrenEntity2::setChild, 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 CopyValuesControllerTest method setUp.
@Before
public void setUp() {
N2oEnvironment environment = new N2oEnvironment();
environment.setNamespacePersisterFactory(new PersisterFactoryByMap());
environment.setNamespaceReaderFactory(new ReaderFactoryByMap());
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasenames("n2o_messages", "messages");
messageSource.setDefaultEncoding("UTF-8");
environment.setMessageSource(new MessageSourceAccessor(messageSource));
OverrideProperties properties = PropertiesReader.getPropertiesFromClasspath("META-INF/n2o.properties");
properties.put("n2o.engine.mapper", "spel");
environment.setSystemProperties(new SimplePropertyResolver(properties));
builder = new N2oApplicationBuilder(environment);
configure(builder);
CompileInfo.setSourceTypes(builder.getEnvironment().getSourceTypeRegister());
}
use of net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap in project n2o-framework by i-novus-llc.
the class DefaultValuesControllerTest method setUp.
@Before
public void setUp() {
N2oEnvironment environment = new N2oEnvironment();
environment.setNamespacePersisterFactory(new PersisterFactoryByMap());
environment.setNamespaceReaderFactory(new ReaderFactoryByMap());
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasenames("n2o_messages", "messages");
messageSource.setDefaultEncoding("UTF-8");
environment.setMessageSource(new MessageSourceAccessor(messageSource));
OverrideProperties properties = PropertiesReader.getPropertiesFromClasspath("META-INF/n2o.properties");
properties.put("n2o.engine.mapper", "spel");
environment.setSystemProperties(new SimplePropertyResolver(properties));
builder = new N2oApplicationBuilder(environment);
configure(builder);
CompileInfo.setSourceTypes(builder.getEnvironment().getSourceTypeRegister());
}
Aggregations