Search in sources :

Example 1 with ApolloDataSourceFactoryBean

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

the class ApolloDataSourceFactoryBeanTests method testApolloFactoryBean.

@Test
public void testApolloFactoryBean() throws Exception {
    ApolloDataSourceFactoryBean factoryBean = spy(new ApolloDataSourceFactoryBean());
    Converter converter = mock(JsonConverter.class);
    factoryBean.setDefaultFlowRuleValue(defaultFlowValue);
    factoryBean.setFlowRulesKey(flowRuleKey);
    factoryBean.setNamespaceName(namespace);
    factoryBean.setConverter(converter);
    ApolloDataSource apolloDataSource = mock(ApolloDataSource.class);
    when(apolloDataSource.readSource()).thenReturn("{}");
    doReturn(apolloDataSource).when(factoryBean).getObject();
    assertThat(factoryBean.getObject()).isEqualTo(apolloDataSource);
    assertThat(factoryBean.getObject().readSource()).isEqualTo("{}");
    assertThat(factoryBean.getConverter()).isEqualTo(converter);
    assertThat(factoryBean.getFlowRulesKey()).isEqualTo(flowRuleKey);
    assertThat(factoryBean.getNamespaceName()).isEqualTo(namespace);
    assertThat(factoryBean.getDefaultFlowRuleValue()).isEqualTo(defaultFlowValue);
}
Also used : JsonConverter(com.alibaba.cloud.sentinel.datasource.converter.JsonConverter) Converter(com.alibaba.csp.sentinel.datasource.Converter) ApolloDataSource(com.alibaba.csp.sentinel.datasource.apollo.ApolloDataSource) ApolloDataSourceFactoryBean(com.alibaba.cloud.sentinel.datasource.factorybean.ApolloDataSourceFactoryBean) Test(org.junit.Test)

Aggregations

JsonConverter (com.alibaba.cloud.sentinel.datasource.converter.JsonConverter)1 ApolloDataSourceFactoryBean (com.alibaba.cloud.sentinel.datasource.factorybean.ApolloDataSourceFactoryBean)1 Converter (com.alibaba.csp.sentinel.datasource.Converter)1 ApolloDataSource (com.alibaba.csp.sentinel.datasource.apollo.ApolloDataSource)1 Test (org.junit.Test)1