Java 类org.springframework.boot.test.EnvironmentTestUtils 实例源码

项目:spring-boot-square-oss-support    文件:OkHttpAutoConfigurationTest.java   
@Test
public void testOkHttpClientAutoConfiguredWithCustomProperties() {
    context = new AnnotationConfigApplicationContext();
    context.register(OkHttpAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(context, "spring.okhttp.connection-timeout:500");
    EnvironmentTestUtils.addEnvironment(context, "spring.okhttp.read-timeout:600");
    EnvironmentTestUtils.addEnvironment(context, "spring.okhttp.write-timeout:700");
    context.refresh();

    OkHttpClient okHttpClient = context.getBean(OkHttpClient.class);

    assertThat(okHttpClient).isNotNull();
    assertThat(okHttpClient.connectTimeoutMillis()).isEqualTo(500);
    assertThat(okHttpClient.readTimeoutMillis()).isEqualTo(600);
    assertThat(okHttpClient.writeTimeoutMillis()).isEqualTo(700);
}
项目:contestparser    文件:EnvironmentEndpointTests.java   
@SuppressWarnings("unchecked")
@Test
public void testKeySanitizationWithCustomPatternByEnvironment() throws Exception {
    this.context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(this.context,
            "endpoints.env.keys-to-sanitize: .*pass.*");
    this.context.register(Config.class);
    this.context.refresh();
    System.setProperty("dbPassword", "123456");
    System.setProperty("apiKey", "123456");
    EnvironmentEndpoint report = getEndpointBean();
    Map<String, Object> env = report.invoke();
    assertEquals("******",
            ((Map<String, Object>) env.get("systemProperties")).get("dbPassword"));
    assertEquals("123456",
            ((Map<String, Object>) env.get("systemProperties")).get("apiKey"));
}
项目:contestparser    文件:ConfigurationPropertiesReportEndpointSerializationTests.java   
@Test
@SuppressWarnings("unchecked")
public void testCycle() throws Exception {
    this.context.register(CycleConfig.class);
    EnvironmentTestUtils.addEnvironment(this.context, "foo.name:foo");
    this.context.refresh();
    ConfigurationPropertiesReportEndpoint report = this.context
            .getBean(ConfigurationPropertiesReportEndpoint.class);
    Map<String, Object> properties = report.invoke();
    Map<String, Object> nestedProperties = (Map<String, Object>) properties
            .get("foo");
    assertNotNull(nestedProperties);
    assertEquals("foo", nestedProperties.get("prefix"));
    Map<String, Object> map = (Map<String, Object>) nestedProperties
            .get("properties");
    assertNotNull(map);
    assertEquals(1, map.size());
    assertEquals("Cannot serialize 'foo'", map.get("error"));
}
项目:contestparser    文件:DataSourceAutoConfigurationTests.java   
@Test
public void testExplicitDriverClassClearsUserName() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.datasource.driverClassName:org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfigurationTests$DatabaseDriver",
            "spring.datasource.url:jdbc:foo://localhost");
    this.context.register(DataSourceAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    DataSource bean = this.context.getBean(DataSource.class);
    assertNotNull(bean);
    org.apache.tomcat.jdbc.pool.DataSource pool = (org.apache.tomcat.jdbc.pool.DataSource) bean;
    assertEquals(
            "org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfigurationTests$DatabaseDriver",
            pool.getDriverClassName());
    assertNull(pool.getUsername());
}
项目:contestparser    文件:ConfigurationPropertiesReportEndpointSerializationTests.java   
@Test
@SuppressWarnings("unchecked")
public void testNaming() throws Exception {
    this.context.register(FooConfig.class);
    EnvironmentTestUtils.addEnvironment(this.context, "foo.name:foo");
    this.context.refresh();
    ConfigurationPropertiesReportEndpoint report = this.context
            .getBean(ConfigurationPropertiesReportEndpoint.class);
    Map<String, Object> properties = report.invoke();
    Map<String, Object> nestedProperties = (Map<String, Object>) properties
            .get("foo");
    assertNotNull(nestedProperties);
    assertEquals("foo", nestedProperties.get("prefix"));
    Map<String, Object> map = (Map<String, Object>) nestedProperties
            .get("properties");
    assertNotNull(map);
    assertEquals(2, map.size());
    assertEquals("foo", map.get("name"));
}
项目:contestparser    文件:DeviceDelegatingViewResolverAutoConfigurationTests.java   
@Test
public void defaultPropertyValues() throws Exception {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.mobile.devicedelegatingviewresolver.enabled:true");
    this.context.register(Config.class, WebMvcAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class,
            DeviceDelegatingViewResolverConfiguration.class);
    this.context.refresh();
    LiteDeviceDelegatingViewResolver liteDeviceDelegatingViewResolver = this.context
            .getBean("deviceDelegatingViewResolver",
                    LiteDeviceDelegatingViewResolver.class);

    DirectFieldAccessor accessor = new DirectFieldAccessor(
            liteDeviceDelegatingViewResolver);
    assertEquals(false, accessor.getPropertyValue("enableFallback"));
    assertEquals("", accessor.getPropertyValue("normalPrefix"));
    assertEquals("mobile/", accessor.getPropertyValue("mobilePrefix"));
    assertEquals("tablet/", accessor.getPropertyValue("tabletPrefix"));
    assertEquals("", accessor.getPropertyValue("normalSuffix"));
    assertEquals("", accessor.getPropertyValue("mobileSuffix"));
    assertEquals("", accessor.getPropertyValue("tabletSuffix"));
}
项目:contestparser    文件:MongoDataAutoConfigurationTests.java   
public void testFieldNamingStrategy(String strategy,
        Class<? extends FieldNamingStrategy> expectedType) {
    this.context = new AnnotationConfigApplicationContext();
    if (strategy != null) {
        EnvironmentTestUtils.addEnvironment(this.context,
                "spring.data.mongodb.field-naming-strategy:" + strategy);
    }
    this.context.register(PropertyPlaceholderAutoConfiguration.class,
            MongoAutoConfiguration.class, MongoDataAutoConfiguration.class);
    this.context.refresh();
    MongoMappingContext mappingContext = this.context
            .getBean(MongoMappingContext.class);
    FieldNamingStrategy fieldNamingStrategy = (FieldNamingStrategy) ReflectionTestUtils
            .getField(mappingContext, "fieldNamingStrategy");
    assertEquals(expectedType, fieldNamingStrategy.getClass());
}
项目:contestparser    文件:ElasticsearchAutoConfigurationTests.java   
@Test
public void createNodeClientWithOverrides() {
    this.context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.data.elasticsearch.properties.foo.bar:baz",
            "spring.data.elasticsearch.properties.path.data:target/data",
            "spring.data.elasticsearch.properties.path.logs:target/logs",
            "spring.data.elasticsearch.properties.node.local:false",
            "spring.data.elasticsearch.properties.node.data:true",
            "spring.data.elasticsearch.properties.http.enabled:true");
    this.context.register(PropertyPlaceholderAutoConfiguration.class,
            ElasticsearchAutoConfiguration.class);
    this.context.refresh();
    assertEquals(1, this.context.getBeanNamesForType(Client.class).length);
    NodeClient client = (NodeClient) this.context.getBean(Client.class);
    assertThat(client.settings().get("foo.bar"), is(equalTo("baz")));
    assertThat(client.settings().get("node.local"), is(equalTo("false")));
    assertThat(client.settings().get("node.data"), is(equalTo("true")));
    assertThat(client.settings().get("http.enabled"), is(equalTo("true")));
}
项目:contestparser    文件:ConfigurationPropertiesReportEndpointTests.java   
@SuppressWarnings("unchecked")
@Test
public void testKeySanitizationWithCustomPatternAndKeyByEnvironment()
        throws Exception {
    this.context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(this.context,
            "endpoints.configprops.keys-to-sanitize: .*pass.*, property");
    this.context.register(Config.class);
    this.context.refresh();
    ConfigurationPropertiesReportEndpoint report = getEndpointBean();
    Map<String, Object> properties = report.invoke();
    Map<String, Object> nestedProperties = (Map<String, Object>) ((Map<String, Object>) properties
            .get("testProperties")).get("properties");
    assertNotNull(nestedProperties);
    assertEquals("******", nestedProperties.get("dbPassword"));
    assertEquals("******", nestedProperties.get("myTestProperty"));
}
项目:contestparser    文件:ConfigurationPropertiesReportEndpointSerializationTests.java   
@Test
@SuppressWarnings("unchecked")
public void testMap() throws Exception {
    this.context.register(MapConfig.class);
    EnvironmentTestUtils.addEnvironment(this.context, "foo.map.name:foo");
    this.context.refresh();
    ConfigurationPropertiesReportEndpoint report = this.context
            .getBean(ConfigurationPropertiesReportEndpoint.class);
    Map<String, Object> properties = report.invoke();
    Map<String, Object> nestedProperties = (Map<String, Object>) properties
            .get("foo");
    assertNotNull(nestedProperties);
    assertEquals("foo", nestedProperties.get("prefix"));
    Map<String, Object> map = (Map<String, Object>) nestedProperties
            .get("properties");
    assertNotNull(map);
    assertEquals(3, map.size());
    assertEquals("foo", ((Map<String, Object>) map.get("map")).get("name"));
}
项目:contestparser    文件:DeviceDelegatingViewResolverAutoConfigurationTests.java   
@Test(expected = NoSuchBeanDefinitionException.class)
public void deviceDelegatingInternalResourceViewResolverDisabled() throws Exception {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.mobile.devicedelegatingviewresolver.enabled:false");
    this.context.register(Config.class, WebMvcAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class,
            DeviceDelegatingViewResolverConfiguration.class);
    this.context.refresh();
    assertNotNull(this.context.getBean(InternalResourceViewResolver.class));
    try {
        this.context.getBean(ThymeleafViewResolver.class);
    }
    catch (NoSuchBeanDefinitionException ex) {
        // expected. ThymeleafViewResolver shouldn't be defined.
    }
    this.context.getBean("deviceDelegatingViewResolver",
            AbstractDeviceDelegatingViewResolver.class);
}
项目:contestparser    文件:HealthIndicatorAutoConfigurationTests.java   
@Test
public void elasticSearchHealthIndicator() {
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.data.elasticsearch.properties.path.data:target/data",
            "spring.data.elasticsearch.properties.path.logs:target/logs",
            "management.health.diskspace.enabled:false");
    this.context.register(ElasticsearchAutoConfiguration.class,
            ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
    this.context.refresh();

    Map<String, HealthIndicator> beans = this.context
            .getBeansOfType(HealthIndicator.class);
    assertEquals(1, beans.size());
    assertEquals(ElasticsearchHealthIndicator.class,
            beans.values().iterator().next().getClass());
}
项目:spring-cloud-dashboard    文件:OnSecurityEnabledAndOAuth2DisabledTests.java   
private AnnotationConfigApplicationContext load(Class<?> config, String... env) {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(context, env);
    context.register(config);
    context.refresh();
    return context;
}
项目:spring-cloud-dashboard    文件:OnSecurityEnabledAndOAuth2EnabledTests.java   
private AnnotationConfigApplicationContext load(Class<?> config, String... env) {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(context, env);
    context.register(config);
    context.refresh();
    return context;
}
项目:spring-boot-starter-amazon-s3    文件:S3AutoConfigurationTest.java   
private void load(Class<?> config, String... environment) {
    AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(applicationContext, environment);
    applicationContext.register(config);
    applicationContext.register(S3AutoConfiguration.class);
    applicationContext.refresh();
    this.context = applicationContext;
}
项目:graphql-spring-boot    文件:GraphQLAutoConfigurationTest.java   
private void load(Class<?> config, String... environment) {
    AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(applicationContext, environment);
    applicationContext.register(config);
    applicationContext.register(GraphQLAutoConfiguration.class);
    applicationContext.refresh();
    this.context = applicationContext;
}
项目:static-creds-broker    文件:ServicePropertiesTest.java   
@Test
public void should_set_service_with_valid_id_name_and_description_and_plans() {
    this.context.register(TestConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context,
            "services.tripadvisor.name:a_name",
            "services.tripadvisor.description:a_description",
            "services.tripadvisor.plans.default.name:default",
            "services.tripadvisor.plans.default.id:default_id",
            "services.tripadvisor.plans.default.credentials.uri:http://localhost");
    this.context.refresh();
}
项目:static-creds-broker    文件:ServicePropertiesTest.java   
@Test
public void fail_to_set_service_with_no_name() {
    this.context.register(TestConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context,
            "services.tripadvisor.name:",
            "services.tripadvisor.description:a_description",
            "services.tripadvisor.plans.default.name:default");
    this.thrown.expect(BeanCreationException.class);
    this.thrown.expectMessage(ServiceProperties.NO_NAME_ERROR);
    this.context.refresh();
}
项目:static-creds-broker    文件:ServicePropertiesTest.java   
@Test
public void fail_to_set_service_with_no_description() {
    this.context.register(TestConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context,
            "services.tripadvisor.name:a_name",
            "services.tripadvisor.description:",
            "services.tripadvisor.plans.default.name:default");
    this.thrown.expect(BeanCreationException.class);
    this.thrown.expectMessage(ServiceProperties.NO_DESCRIPTION_ERROR);
    this.context.refresh();
}
项目:Zipkin    文件:StreamEnvironmentPostProcessorTests.java   
@Test
public void headersAppendedIfNecessary() {
    EnvironmentTestUtils.addEnvironment(this.environment, "spring.cloud.stream.test.binder.headers[0]=X-Custom",
            "spring.cloud.stream.test.binder.headers[1]=X-Mine");
    this.processor.postProcessEnvironment(this.environment,
            new SpringApplication(StreamEnvironmentPostProcessorTests.class));
    assertThat(this.environment.getProperty("spring.cloud.stream.test.binder.headers[2]"))
            .isEqualTo(Span.SPAN_ID_NAME);
}
项目:spring-cloud-stream-app-starters    文件:FtpSourcePropertiesTests.java   
@Test
public void localDirCanBeCustomized() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(context, "ftp.localDir:local");
    context.register(Conf.class);
    context.refresh();
    FtpSourceProperties properties = context.getBean(FtpSourceProperties.class);
    assertThat(properties.getLocalDir(), equalTo(new File("local")));
}
项目:spring-cloud-stream-app-starters    文件:FtpSourcePropertiesTests.java   
@Test
public void remoteDirCanBeCustomized() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(context, "ftp.remoteDir:/remote");
    context.register(Conf.class);
    context.refresh();
    FtpSourceProperties properties = context.getBean(FtpSourceProperties.class);
    assertThat(properties.getRemoteDir(), equalTo("/remote"));
}
项目:spring-cloud-stream-app-starters    文件:FtpSourcePropertiesTests.java   
@Test
public void deleteRemoteFilesCanBeEnabled() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(context, "ftp.deleteRemoteFiles:true");
    context.register(Conf.class);
    context.refresh();
    FtpSourceProperties properties = context.getBean(FtpSourceProperties.class);
    assertTrue(properties.isDeleteRemoteFiles());
}
项目:spring-cloud-stream-app-starters    文件:FtpSourcePropertiesTests.java   
@Test
public void autoCreateLocalDirCanBeDisabled() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(context, "ftp.autoCreateLocalDir:false");
    context.register(Conf.class);
    context.refresh();
    FtpSourceProperties properties = context.getBean(FtpSourceProperties.class);
    assertTrue(!properties.isAutoCreateLocalDir());
}
项目:spring-cloud-stream-app-starters    文件:FtpSourcePropertiesTests.java   
@Test
public void tmpFileSuffixCanBeCustomized() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(context, "ftp.tmpFileSuffix:.foo");
    context.register(Conf.class);
    context.refresh();
    FtpSourceProperties properties = context.getBean(FtpSourceProperties.class);
    assertThat(properties.getTmpFileSuffix(), equalTo(".foo"));
}
项目:spring-cloud-stream-app-starters    文件:FtpSourcePropertiesTests.java   
@Test
public void filenamePatternCanBeCustomized() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(context, "ftp.filenamePattern:*.foo");
    context.register(Conf.class);
    context.refresh();
    FtpSourceProperties properties = context.getBean(FtpSourceProperties.class);
    assertThat(properties.getFilenamePattern(), equalTo("*.foo"));
}
项目:spring-cloud-stream-app-starters    文件:FtpSourcePropertiesTests.java   
@Test
public void remoteFileSeparatorCanBeCustomized() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(context, "ftp.remoteFileSeparator:\\");
    context.register(Conf.class);
    context.refresh();
    FtpSourceProperties properties = context.getBean(FtpSourceProperties.class);
    assertThat(properties.getRemoteFileSeparator(), equalTo("\\"));
}
项目:spring-cloud-stream-app-starters    文件:FtpSourcePropertiesTests.java   
@Test
public void preserveTimestampDirCanBeDisabled() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(context, "ftp.preserveTimestamp:false");
    context.register(Conf.class);
    context.refresh();
    FtpSourceProperties properties = context.getBean(FtpSourceProperties.class);
    assertTrue(!properties.isPreserveTimestamp());
}
项目:spring-cloud-stream-app-starters    文件:FtpSinkPropertiesTests.java   
@Test
public void remoteDirCanBeCustomized() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(context, "ftp.remoteDir:/remote");
    context.register(Conf.class);
    context.refresh();
    FtpSinkProperties properties = context.getBean(FtpSinkProperties.class);
    assertThat(properties.getRemoteDir(), equalTo("/remote"));
}
项目:spring-cloud-stream-app-starters    文件:FtpSinkPropertiesTests.java   
@Test
public void autoCreateDirCanBeDisabled() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(context, "ftp.autoCreateDir:false");
    context.register(Conf.class);
    context.refresh();
    FtpSinkProperties properties = context.getBean(FtpSinkProperties.class);
    assertTrue(!properties.isAutoCreateDir());
}
项目:spring-cloud-stream-app-starters    文件:FtpSinkPropertiesTests.java   
@Test
public void tmpFileSuffixCanBeCustomized() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(context, "ftp.tmpFileSuffix:.foo");
    context.register(Conf.class);
    context.refresh();
    FtpSinkProperties properties = context.getBean(FtpSinkProperties.class);
    assertThat(properties.getTmpFileSuffix(), equalTo(".foo"));
}
项目:spring-cloud-stream-app-starters    文件:FtpSinkPropertiesTests.java   
@Test
public void tmpFileRemoteDirCanBeCustomized() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(context, "ftp.temporaryRemoteDir:/foo");
    context.register(Conf.class);
    context.refresh();
    FtpSinkProperties properties = context.getBean(FtpSinkProperties.class);
    assertThat(properties.getTemporaryRemoteDir(), equalTo("/foo"));
}
项目:spring-cloud-stream-app-starters    文件:FtpSinkPropertiesTests.java   
@Test
public void remoteFileSeparatorCanBeCustomized() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(context, "ftp.remoteFileSeparator:\\");
    context.register(Conf.class);
    context.refresh();
    FtpSinkProperties properties = context.getBean(FtpSinkProperties.class);
    assertThat(properties.getRemoteFileSeparator(), equalTo("\\"));
}
项目:spring-cloud-stream-app-starters    文件:FtpSinkPropertiesTests.java   
@Test
public void useTemporaryFileNameCanBeCustomized() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(context, "ftp.useTemporaryFilename:false");
    context.register(Conf.class);
    context.refresh();
    FtpSinkProperties properties = context.getBean(FtpSinkProperties.class);
    assertFalse(properties.isUseTemporaryFilename());
}
项目:spring-cloud-stream-app-starters    文件:FtpSinkPropertiesTests.java   
@Test
public void fileExistsModeCanBeCustomized() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(context, "ftp.mode:FAIL");
    context.register(Conf.class);
    context.refresh();
    FtpSinkProperties properties = context.getBean(FtpSinkProperties.class);
    assertThat(properties.getMode(), equalTo(FileExistsMode.FAIL));
}
项目:spring-cloud-stream-app-starters    文件:SftpSinkPropertiesTests.java   
@Test
public void remoteDirCanBeCustomized() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(context, "sftp.remoteDir:/remote");
    context.register(Conf.class);
    context.refresh();
    SftpSinkProperties properties = context.getBean(SftpSinkProperties.class);
    assertThat(properties.getRemoteDir(), equalTo("/remote"));
}
项目:spring-cloud-stream-app-starters    文件:SftpSinkPropertiesTests.java   
@Test
public void autoCreateDirCanBeDisabled() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(context, "sftp.autoCreateDir:false");
    context.register(Conf.class);
    context.refresh();
    SftpSinkProperties properties = context.getBean(SftpSinkProperties.class);
    assertTrue(!properties.isAutoCreateDir());
}
项目:spring-cloud-stream-app-starters    文件:SftpSinkPropertiesTests.java   
@Test
public void tmpFileSuffixCanBeCustomized() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(context, "sftp.tmpFileSuffix:.foo");
    context.register(Conf.class);
    context.refresh();
    SftpSinkProperties properties = context.getBean(SftpSinkProperties.class);
    assertThat(properties.getTmpFileSuffix(), equalTo(".foo"));
}
项目:spring-cloud-stream-app-starters    文件:SftpSinkPropertiesTests.java   
@Test
public void tmpFileRemoteDirCanBeCustomized() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(context, "sftp.temporaryRemoteDir:/foo");
    context.register(Conf.class);
    context.refresh();
    SftpSinkProperties properties = context.getBean(SftpSinkProperties.class);
    assertThat(properties.getTemporaryRemoteDir(), equalTo("/foo"));
}
项目:spring-cloud-stream-app-starters    文件:SftpSinkPropertiesTests.java   
@Test
public void remoteFileSeparatorCanBeCustomized() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(context, "sftp.remoteFileSeparator:\\");
    context.register(Conf.class);
    context.refresh();
    SftpSinkProperties properties = context.getBean(SftpSinkProperties.class);
    assertThat(properties.getRemoteFileSeparator(), equalTo("\\"));
}