Search in sources :

Example 1 with ZookeeperDataSource

use of com.alibaba.csp.sentinel.datasource.zookeeper.ZookeeperDataSource in project spring-cloud-alibaba by alibaba.

the class ZookeeperDataSourceFactoryBeanTests method testZKWithPathFactoryBean.

@Test
public void testZKWithPathFactoryBean() throws Exception {
    ZookeeperDataSourceFactoryBean factoryBean = spy(ZookeeperDataSourceFactoryBean.class);
    Converter converter = mock(XmlConverter.class);
    ZookeeperDataSource zookeeperDataSource = mock(ZookeeperDataSource.class);
    factoryBean.setConverter(converter);
    factoryBean.setPath(path);
    factoryBean.setServerAddr(serverAddr);
    when(zookeeperDataSource.readSource()).thenReturn("{}");
    doReturn(zookeeperDataSource).when(factoryBean).getObject();
    assertThat(factoryBean.getObject()).isEqualTo(zookeeperDataSource);
    assertThat(factoryBean.getObject().readSource()).isEqualTo("{}");
    assertThat(factoryBean.getConverter()).isEqualTo(converter);
    assertThat(factoryBean.getPath()).isEqualTo(path);
    assertThat(factoryBean.getServerAddr()).isEqualTo(serverAddr);
}
Also used : ZookeeperDataSource(com.alibaba.csp.sentinel.datasource.zookeeper.ZookeeperDataSource) Converter(com.alibaba.csp.sentinel.datasource.Converter) XmlConverter(com.alibaba.cloud.sentinel.datasource.converter.XmlConverter) ZookeeperDataSourceFactoryBean(com.alibaba.cloud.sentinel.datasource.factorybean.ZookeeperDataSourceFactoryBean) Test(org.junit.Test)

Example 2 with ZookeeperDataSource

use of com.alibaba.csp.sentinel.datasource.zookeeper.ZookeeperDataSource in project spring-cloud-alibaba by alibaba.

the class ZookeeperDataSourceFactoryBeanTests method testZKWithoutPathFactoryBean.

@Test
public void testZKWithoutPathFactoryBean() throws Exception {
    ZookeeperDataSourceFactoryBean factoryBean = spy(ZookeeperDataSourceFactoryBean.class);
    Converter converter = mock(XmlConverter.class);
    ZookeeperDataSource zookeeperDataSource = mock(ZookeeperDataSource.class);
    factoryBean.setConverter(converter);
    factoryBean.setDataId(dataId);
    factoryBean.setGroupId(groupId);
    factoryBean.setServerAddr(serverAddr);
    when(zookeeperDataSource.readSource()).thenReturn("{}");
    doReturn(zookeeperDataSource).when(factoryBean).getObject();
    assertThat(factoryBean.getObject()).isEqualTo(zookeeperDataSource);
    assertThat(factoryBean.getObject().readSource()).isEqualTo("{}");
    assertThat(factoryBean.getDataId()).isEqualTo(dataId);
    assertThat(factoryBean.getConverter()).isEqualTo(converter);
    assertThat(factoryBean.getGroupId()).isEqualTo(groupId);
    assertThat(factoryBean.getServerAddr()).isEqualTo(serverAddr);
}
Also used : ZookeeperDataSource(com.alibaba.csp.sentinel.datasource.zookeeper.ZookeeperDataSource) Converter(com.alibaba.csp.sentinel.datasource.Converter) XmlConverter(com.alibaba.cloud.sentinel.datasource.converter.XmlConverter) ZookeeperDataSourceFactoryBean(com.alibaba.cloud.sentinel.datasource.factorybean.ZookeeperDataSourceFactoryBean) Test(org.junit.Test)

Aggregations

XmlConverter (com.alibaba.cloud.sentinel.datasource.converter.XmlConverter)2 ZookeeperDataSourceFactoryBean (com.alibaba.cloud.sentinel.datasource.factorybean.ZookeeperDataSourceFactoryBean)2 Converter (com.alibaba.csp.sentinel.datasource.Converter)2 ZookeeperDataSource (com.alibaba.csp.sentinel.datasource.zookeeper.ZookeeperDataSource)2 Test (org.junit.Test)2