Search in sources :

Example 21 with N2oEnvironment

use of net.n2oapp.framework.config.compile.pipeline.N2oEnvironment in project n2o-framework by i-novus-llc.

the class RouterTest method get_repair4.

@Test
public void get_repair4() {
    N2oEnvironment env = (N2oEnvironment) builder.getEnvironment();
    env.getRouteRegister().addRoute("/p", new MockCompileContext<>("/p", "p", null, Page.class));
    MockBindPipeline pipeline = new MockBindPipeline(env);
    N2oRouter router = new N2oRouter(env, pipeline);
    pipeline.mock("p", (r, p) -> {
        r.getRouteRegister().addRoute("/p", new MockCompileContext<>("/p", "q", null, CompiledQuery.class));
    });
    CompileContext<CompiledQuery, ?> res;
    res = router.get("/p", CompiledQuery.class, null);
    assertThat(res, notNullValue());
    assertThat(res.getSourceId(null), is("q"));
}
Also used : N2oEnvironment(net.n2oapp.framework.config.compile.pipeline.N2oEnvironment) Page(net.n2oapp.framework.api.metadata.meta.page.Page) CompiledQuery(net.n2oapp.framework.api.metadata.local.CompiledQuery) Test(org.junit.Test)

Example 22 with N2oEnvironment

use of net.n2oapp.framework.config.compile.pipeline.N2oEnvironment in project n2o-framework by i-novus-llc.

the class N2oApplicationBuilder method propertySources.

/**
 * Добавить файлы properties из classpath
 */
public N2oApplicationBuilder propertySources(String... propertySources) {
    PropertyResolver systemProperties = environment.getSystemProperties();
    if (!(systemProperties instanceof SimplePropertyResolver))
        throw new IllegalArgumentException("System properties is readonly");
    Properties baseProperties = ((SimplePropertyResolver) systemProperties).getProperties();
    for (String propertySource : propertySources) {
        OverrideProperties properties = PropertiesReader.getPropertiesFromClasspath(propertySource);
        properties.setBaseProperties(baseProperties);
        baseProperties = properties;
    }
    ((N2oEnvironment) environment).setSystemProperties(new SimplePropertyResolver(baseProperties));
    return this;
}
Also used : N2oEnvironment(net.n2oapp.framework.config.compile.pipeline.N2oEnvironment) PropertyResolver(org.springframework.core.env.PropertyResolver) SimplePropertyResolver(net.n2oapp.framework.config.test.SimplePropertyResolver) OverrideProperties(net.n2oapp.properties.OverrideProperties) Properties(java.util.Properties) OverrideProperties(net.n2oapp.properties.OverrideProperties) SimplePropertyResolver(net.n2oapp.framework.config.test.SimplePropertyResolver)

Aggregations

N2oEnvironment (net.n2oapp.framework.config.compile.pipeline.N2oEnvironment)22 Test (org.junit.Test)13 Page (net.n2oapp.framework.api.metadata.meta.page.Page)11 Before (org.junit.Before)7 CompiledQuery (net.n2oapp.framework.api.metadata.local.CompiledQuery)6 N2oApplicationBuilder (net.n2oapp.framework.config.N2oApplicationBuilder)6 SimplePropertyResolver (net.n2oapp.framework.config.test.SimplePropertyResolver)6 PersisterFactoryByMap (net.n2oapp.framework.config.selective.persister.PersisterFactoryByMap)5 ReaderFactoryByMap (net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap)5 OverrideProperties (net.n2oapp.properties.OverrideProperties)5 ContextProcessor (net.n2oapp.framework.api.context.ContextProcessor)4 N2oInvocationFactory (net.n2oapp.framework.engine.data.N2oInvocationFactory)4 TestDataProviderEngine (net.n2oapp.framework.engine.data.json.TestDataProviderEngine)4 MessageSourceAccessor (org.springframework.context.support.MessageSourceAccessor)4 ResourceBundleMessageSource (org.springframework.context.support.ResourceBundleMessageSource)4 HashMap (java.util.HashMap)3 DataSet (net.n2oapp.criteria.dataset.DataSet)3 N2oSubModelsProcessor (net.n2oapp.framework.config.util.N2oSubModelsProcessor)3 N2oQueryExceptionHandler (net.n2oapp.framework.engine.data.N2oQueryExceptionHandler)3 N2oQueryProcessor (net.n2oapp.framework.engine.data.N2oQueryProcessor)3