Search in sources :

Example 1 with OverrideProperties

use of net.n2oapp.properties.OverrideProperties in project n2o-framework by i-novus-llc.

the class DataControllerTestBase 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");
    SimplePropertyResolver propertyResolver = new SimplePropertyResolver(properties);
    setUpStaticProperties(propertyResolver);
    environment.setSystemProperties(propertyResolver);
    builder = new N2oApplicationBuilder(environment);
    configure(builder);
    CompileInfo.setSourceTypes(builder.getEnvironment().getSourceTypeRegister());
}
Also used : N2oEnvironment(net.n2oapp.framework.config.compile.pipeline.N2oEnvironment) PersisterFactoryByMap(net.n2oapp.framework.config.selective.persister.PersisterFactoryByMap) MessageSourceAccessor(org.springframework.context.support.MessageSourceAccessor) N2oApplicationBuilder(net.n2oapp.framework.config.N2oApplicationBuilder) ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource) ReaderFactoryByMap(net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap) OverrideProperties(net.n2oapp.properties.OverrideProperties) SimplePropertyResolver(net.n2oapp.framework.config.test.SimplePropertyResolver) Before(org.junit.Before)

Example 2 with OverrideProperties

use of net.n2oapp.properties.OverrideProperties 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());
}
Also used : Locale(java.util.Locale) N2oEnvironment(net.n2oapp.framework.config.compile.pipeline.N2oEnvironment) PersisterFactoryByMap(net.n2oapp.framework.config.selective.persister.PersisterFactoryByMap) MessageSourceAccessor(org.springframework.context.support.MessageSourceAccessor) N2oApplicationBuilder(net.n2oapp.framework.config.N2oApplicationBuilder) ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource) ReaderFactoryByMap(net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap) OverrideProperties(net.n2oapp.properties.OverrideProperties)

Example 3 with OverrideProperties

use of net.n2oapp.properties.OverrideProperties 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());
}
Also used : N2oEnvironment(net.n2oapp.framework.config.compile.pipeline.N2oEnvironment) PersisterFactoryByMap(net.n2oapp.framework.config.selective.persister.PersisterFactoryByMap) MessageSourceAccessor(org.springframework.context.support.MessageSourceAccessor) N2oApplicationBuilder(net.n2oapp.framework.config.N2oApplicationBuilder) ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource) ReaderFactoryByMap(net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap) OverrideProperties(net.n2oapp.properties.OverrideProperties) SimplePropertyResolver(net.n2oapp.framework.config.test.SimplePropertyResolver) Before(org.junit.Before)

Example 4 with OverrideProperties

use of net.n2oapp.properties.OverrideProperties 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());
}
Also used : N2oEnvironment(net.n2oapp.framework.config.compile.pipeline.N2oEnvironment) PersisterFactoryByMap(net.n2oapp.framework.config.selective.persister.PersisterFactoryByMap) MessageSourceAccessor(org.springframework.context.support.MessageSourceAccessor) N2oApplicationBuilder(net.n2oapp.framework.config.N2oApplicationBuilder) ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource) ReaderFactoryByMap(net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap) OverrideProperties(net.n2oapp.properties.OverrideProperties) SimplePropertyResolver(net.n2oapp.framework.config.test.SimplePropertyResolver) Before(org.junit.Before)

Example 5 with OverrideProperties

use of net.n2oapp.properties.OverrideProperties in project n2o-framework by i-novus-llc.

the class PropertiesReader method getPropertiesFromURI.

public static OverrideProperties getPropertiesFromURI(String locationPattern) {
    OverrideProperties properties = new OverrideProperties();
    PathMatchingResourcePatternResolver r = new PathMatchingResourcePatternResolver();
    try {
        for (Resource resource : r.getResources(locationPattern)) {
            try (InputStream is = resource.getInputStream()) {
                if (is != null) {
                    try {
                        properties.load(is);
                    } catch (IOException e) {
                        throw new IllegalStateException(e);
                    }
                } else {
                    log.debug("{} not found.", locationPattern);
                }
            }
        }
        return properties;
    } catch (IOException e) {
        log.error(e.getMessage(), e);
    }
    return null;
}
Also used : InputStream(java.io.InputStream) ClassPathResource(org.springframework.core.io.ClassPathResource) FileSystemResource(org.springframework.core.io.FileSystemResource) Resource(org.springframework.core.io.Resource) IOException(java.io.IOException) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) OverrideProperties(net.n2oapp.properties.OverrideProperties)

Aggregations

OverrideProperties (net.n2oapp.properties.OverrideProperties)7 N2oEnvironment (net.n2oapp.framework.config.compile.pipeline.N2oEnvironment)5 N2oApplicationBuilder (net.n2oapp.framework.config.N2oApplicationBuilder)4 PersisterFactoryByMap (net.n2oapp.framework.config.selective.persister.PersisterFactoryByMap)4 ReaderFactoryByMap (net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap)4 SimplePropertyResolver (net.n2oapp.framework.config.test.SimplePropertyResolver)4 MessageSourceAccessor (org.springframework.context.support.MessageSourceAccessor)4 ResourceBundleMessageSource (org.springframework.context.support.ResourceBundleMessageSource)4 Before (org.junit.Before)3 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Locale (java.util.Locale)1 Properties (java.util.Properties)1 PropertyResolver (org.springframework.core.env.PropertyResolver)1 ClassPathResource (org.springframework.core.io.ClassPathResource)1 FileSystemResource (org.springframework.core.io.FileSystemResource)1 Resource (org.springframework.core.io.Resource)1 PathMatchingResourcePatternResolver (org.springframework.core.io.support.PathMatchingResourcePatternResolver)1