Example usage for org.springframework.core.env PropertiesPropertySource PropertiesPropertySource

List of usage examples for org.springframework.core.env PropertiesPropertySource PropertiesPropertySource

Introduction

In this page you can find the example usage for org.springframework.core.env PropertiesPropertySource PropertiesPropertySource.

Prototype

protected PropertiesPropertySource(String name, Map<String, Object> source) 

Source Link

Usage

From source file:org.springframework.xd.dirt.stream.FileSourceModuleTests.java

@Test
public void testSplitterUsesIterator() throws Exception {
    System.out.println(System.getProperty("user.dir"));
    ConfigurableApplicationContext ctx = new FileSystemXmlApplicationContext(
            new String[] { "../modules/common/file-source-common-context.xml",
                    "classpath:org/springframework/xd/dirt/stream/ppc-context.xml" },
            false);//  ww  w  . j  av a2 s  .c  o  m
    StandardEnvironment env = new StandardEnvironment();
    Properties props = new Properties();
    props.setProperty("fixedDelay", "5");
    props.setProperty("timeUnit", "SECONDS");
    props.setProperty("initialDelay", "0");
    props.setProperty("withMarkers", "false");
    PropertiesPropertySource pps = new PropertiesPropertySource("props", props);
    env.getPropertySources().addLast(pps);
    env.setActiveProfiles("use-contents-with-split");
    ctx.setEnvironment(env);
    ctx.refresh();
    FileSplitter splitter = ctx.getBean(FileSplitter.class);
    File foo = File.createTempFile("foo", ".txt");
    final AtomicReference<Method> splitMessage = new AtomicReference<>();
    ReflectionUtils.doWithMethods(FileSplitter.class, new MethodCallback() {

        @Override
        public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
            method.setAccessible(true);
            splitMessage.set(method);
        }
    }, new MethodFilter() {

        @Override
        public boolean matches(Method method) {
            return method.getName().equals("splitMessage");
        }
    });
    Object result = splitMessage.get().invoke(splitter, new GenericMessage<File>(foo));
    assertThat(result, instanceOf(Iterator.class));
    ctx.close();
    foo.delete();
}

From source file:org.springframework.xd.module.CompositeModule.java

private void registerPropertySource(Properties properties) {
    int propertiesIndex = this.propertiesCounter.getAndIncrement();
    String propertySourceName = "properties-" + propertiesIndex;
    PropertySource<?> propertySource = new PropertiesPropertySource(propertySourceName, properties);
    this.context.getEnvironment().getPropertySources().addLast(propertySource);
}

From source file:org.springframework.xd.module.core.SimpleModule.java

private void registerPropertySource(Properties properties) {
    int propertiesIndex = this.propertiesCounter.getAndIncrement();
    String propertySourceName = "properties-" + propertiesIndex;
    PropertySource<?> propertySource = new PropertiesPropertySource(propertySourceName, properties);
    this.propertySources.addLast(propertySource);
}

From source file:org.springframework.xd.module.SimpleModule.java

private void registerPropertySource(Properties properties) {
    int propertiesIndex = this.propertiesCounter.getAndIncrement();
    String propertySourceName = "properties-" + propertiesIndex;
    PropertySource<?> propertySource = new PropertiesPropertySource(propertySourceName, properties);
    this.environment.getPropertySources().addLast(propertySource);
}