Search in sources :

Example 1 with FileRefreshableDataSourceFactoryBean

use of com.alibaba.cloud.sentinel.datasource.factorybean.FileRefreshableDataSourceFactoryBean in project spring-cloud-alibaba by alibaba.

the class FileRefreshableDataSourceFactoryBeanTests method testFile.

@Test
public void testFile() throws Exception {
    AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext(TestConfig.class);
    assertThat(annotationConfigApplicationContext.getBean("fileBean")).isNotNull();
    FileRefreshableDataSource fileRefreshableDataSource = annotationConfigApplicationContext.getBean("fileBean", FileRefreshableDataSource.class);
    assertThat(((List<FlowRule>) fileRefreshableDataSource.loadConfig()).size()).isEqualTo(1);
    FileRefreshableDataSourceFactoryBean factoryBean = annotationConfigApplicationContext.getBean("&fileBean", FileRefreshableDataSourceFactoryBean.class);
    assertThat(factoryBean.getBufSize()).isEqualTo(1024);
    assertThat(factoryBean.getCharset()).isEqualTo("utf-8");
    assertThat(factoryBean.getRecommendRefreshMs()).isEqualTo(2000);
    assertThat(factoryBean.getFile()).isNotNull();
    assertThat(factoryBean.getConverter()).isNotNull();
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) FileRefreshableDataSourceFactoryBean(com.alibaba.cloud.sentinel.datasource.factorybean.FileRefreshableDataSourceFactoryBean) List(java.util.List) FileRefreshableDataSource(com.alibaba.csp.sentinel.datasource.FileRefreshableDataSource) Test(org.junit.Test)

Aggregations

FileRefreshableDataSourceFactoryBean (com.alibaba.cloud.sentinel.datasource.factorybean.FileRefreshableDataSourceFactoryBean)1 FileRefreshableDataSource (com.alibaba.csp.sentinel.datasource.FileRefreshableDataSource)1 List (java.util.List)1 Test (org.junit.Test)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1