use of com.alibaba.cloud.sentinel.datasource.factorybean.ZookeeperDataSourceFactoryBean 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);
}
use of com.alibaba.cloud.sentinel.datasource.factorybean.ZookeeperDataSourceFactoryBean 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);
}
Aggregations