use of com.alibaba.cloud.sentinel.datasource.factorybean.NacosDataSourceFactoryBean in project spring-cloud-alibaba by alibaba.
the class NacosDataSourceFactoryBeanTests method testNacosFactoryBeanServerAddr.
@Test
public void testNacosFactoryBeanServerAddr() throws Exception {
NacosDataSourceFactoryBean factoryBean = spy(new NacosDataSourceFactoryBean());
Converter converter = mock(SentinelConverter.class);
factoryBean.setDataId(dataId);
factoryBean.setGroupId(groupId);
factoryBean.setServerAddr(serverAddr);
factoryBean.setContextPath(contextPath);
factoryBean.setConverter(converter);
NacosDataSource nacosDataSource = mock(NacosDataSource.class);
doReturn(nacosDataSource).when(factoryBean).getObject();
when(nacosDataSource.readSource()).thenReturn("{}");
assertThat(factoryBean.getObject()).isEqualTo(nacosDataSource);
assertThat(factoryBean.getObject().readSource()).isEqualTo("{}");
assertThat(factoryBean.getConverter()).isEqualTo(converter);
assertThat(factoryBean.getDataId()).isEqualTo(dataId);
assertThat(factoryBean.getGroupId()).isEqualTo(groupId);
assertThat(factoryBean.getServerAddr()).isEqualTo(serverAddr);
assertThat(factoryBean.getContextPath()).isEqualTo(contextPath);
}
use of com.alibaba.cloud.sentinel.datasource.factorybean.NacosDataSourceFactoryBean in project spring-cloud-alibaba by alibaba.
the class NacosDataSourceFactoryBeanTests method testNacosFactoryBeanProperties.
@Test
public void testNacosFactoryBeanProperties() throws Exception {
NacosDataSourceFactoryBean factoryBean = spy(new NacosDataSourceFactoryBean());
Converter converter = mock(SentinelConverter.class);
factoryBean.setDataId(dataId);
factoryBean.setGroupId(groupId);
factoryBean.setAccessKey(accessKey);
factoryBean.setSecretKey(secretKey);
factoryBean.setEndpoint(endpoint);
factoryBean.setNamespace(namespace);
factoryBean.setConverter(converter);
NacosDataSource nacosDataSource = mock(NacosDataSource.class);
doReturn(nacosDataSource).when(factoryBean).getObject();
when(nacosDataSource.readSource()).thenReturn("{}");
assertThat(factoryBean.getObject()).isEqualTo(nacosDataSource);
assertThat(factoryBean.getObject().readSource()).isEqualTo("{}");
assertThat(factoryBean.getConverter()).isEqualTo(converter);
assertThat(factoryBean.getDataId()).isEqualTo(dataId);
assertThat(factoryBean.getGroupId()).isEqualTo(groupId);
assertThat(factoryBean.getNamespace()).isEqualTo(namespace);
assertThat(factoryBean.getEndpoint()).isEqualTo(endpoint);
assertThat(factoryBean.getAccessKey()).isEqualTo(accessKey);
assertThat(factoryBean.getSecretKey()).isEqualTo(secretKey);
}
Aggregations