use of com.tencent.polaris.configuration.api.core.ConfigFileMetadata in project polaris-java by polarismesh.
the class RemoteConfigFileRepoTest method testPullSuccess.
@Test
public void testPullSuccess() {
ConfigFileMetadata configFileMetadata = ConfigFileTestUtils.assembleDefaultConfigFileMeta();
ConfigFile configFile = new ConfigFile(ConfigFileTestUtils.testNamespace, ConfigFileTestUtils.testGroup, ConfigFileTestUtils.testFileName);
String content = "hello world";
long version = 100;
configFile.setContent(content);
configFile.setVersion(version);
ConfigFileResponse configFileResponse = new ConfigFileResponse(ServerCodes.EXECUTE_SUCCESS, "", configFile);
when(configFileConnector.getConfigFile(any())).thenReturn(configFileResponse);
RemoteConfigFileRepo remoteConfigFileRepo = new RemoteConfigFileRepo(sdkContext, configFileLongPollingService, configFileConnector, configFileMetadata);
verify(configFileConnector).getConfigFile(any());
verify(configFileLongPollingService).addConfigFile(remoteConfigFileRepo);
Assert.assertEquals(content, remoteConfigFileRepo.getContent());
Assert.assertEquals(version, remoteConfigFileRepo.getConfigFileVersion());
}
use of com.tencent.polaris.configuration.api.core.ConfigFileMetadata in project polaris-java by polarismesh.
the class RemoteConfigFileRepoTest method testPullWithRetryException.
@Test
public void testPullWithRetryException() {
ConfigFileMetadata configFileMetadata = ConfigFileTestUtils.assembleDefaultConfigFileMeta();
when(configFileConnector.getConfigFile(any())).thenThrow(new RetriableException(ErrorCode.API_TIMEOUT, ""));
RemoteConfigFileRepo remoteConfigFileRepo = new RemoteConfigFileRepo(sdkContext, configFileLongPollingService, configFileConnector, configFileMetadata);
// 重试三次
verify(configFileConnector, times(3)).getConfigFile(any());
verify(configFileLongPollingService).addConfigFile(remoteConfigFileRepo);
Assert.assertNull(remoteConfigFileRepo.getContent());
Assert.assertEquals(0, remoteConfigFileRepo.getConfigFileVersion());
}
Aggregations