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"));
}
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;
}
Aggregations