use of com.ctrip.framework.apollo.biz.entity.Release in project apollo by ctripcorp.
the class ReleaseCreationTest method testPublishNormalNamespace.
@Test
@Sql(scripts = "/sql/release-creation-test.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testPublishNormalNamespace() {
long namespaceId = 100;
String clusterName = "only-master";
Namespace namespace = instanceNamespace(namespaceId, clusterName);
releaseService.publish(namespace, "", "", operator, false);
Release latestRelease = releaseService.findLatestActiveRelease(namespace);
Assert.assertNotNull(latestRelease);
Map<String, String> configuration = parseConfiguration(latestRelease.getConfigurations());
Assert.assertEquals(3, configuration.size());
Assert.assertEquals("v1", configuration.get("k1"));
Assert.assertEquals("v2", configuration.get("k2"));
Assert.assertEquals("v3", configuration.get("k3"));
Page<ReleaseHistory> releaseHistories = releaseHistoryService.findReleaseHistoriesByNamespace(testApp, clusterName, testNamespace, pageable);
ReleaseHistory releaseHistory = releaseHistories.getContent().get(0);
Assert.assertEquals(1, releaseHistories.getTotalElements());
Assert.assertEquals(ReleaseOperation.NORMAL_RELEASE, releaseHistory.getOperation());
Assert.assertEquals(latestRelease.getId(), releaseHistory.getReleaseId());
Assert.assertEquals(0, releaseHistory.getPreviousReleaseId());
}
use of com.ctrip.framework.apollo.biz.entity.Release in project apollo by ctripcorp.
the class ConfigControllerTest method testTransformConfigurationToMapFailed.
@Test(expected = JsonSyntaxException.class)
public void testTransformConfigurationToMapFailed() throws Exception {
String someInvalidConfiguration = "xxx";
Release someRelease = new Release();
someRelease.setConfigurations(someInvalidConfiguration);
configController.mergeReleaseConfigurations(Lists.newArrayList(someRelease));
}
use of com.ctrip.framework.apollo.biz.entity.Release in project apollo by ctripcorp.
the class ConfigServiceWithCacheTest method testFindActiveOneWithMultipleIdMultipleTimes.
@Test
public void testFindActiveOneWithMultipleIdMultipleTimes() throws Exception {
long someId = 1;
long anotherId = 2;
Release anotherRelease = mock(Release.class);
when(releaseService.findActiveOne(someId)).thenReturn(someRelease);
when(releaseService.findActiveOne(anotherId)).thenReturn(anotherRelease);
assertEquals(someRelease, configServiceWithCache.findActiveOne(someId, someNotificationMessages));
assertEquals(someRelease, configServiceWithCache.findActiveOne(someId, someNotificationMessages));
assertEquals(anotherRelease, configServiceWithCache.findActiveOne(anotherId, someNotificationMessages));
assertEquals(anotherRelease, configServiceWithCache.findActiveOne(anotherId, someNotificationMessages));
verify(releaseService, times(1)).findActiveOne(someId);
verify(releaseService, times(1)).findActiveOne(anotherId);
}
use of com.ctrip.framework.apollo.biz.entity.Release in project apollo by ctripcorp.
the class ConfigServiceWithCacheTest method testFindLatestActiveRelease.
@Test
public void testFindLatestActiveRelease() throws Exception {
when(releaseMessageService.findLatestReleaseMessageForMessages(Lists.newArrayList(someKey))).thenReturn(someReleaseMessage);
when(releaseService.findLatestActiveRelease(someAppId, someClusterName, someNamespaceName)).thenReturn(someRelease);
when(someReleaseMessage.getId()).thenReturn(someNotificationId);
Release release = configServiceWithCache.findLatestActiveRelease(someAppId, someClusterName, someNamespaceName, someNotificationMessages);
Release anotherRelease = configServiceWithCache.findLatestActiveRelease(someAppId, someClusterName, someNamespaceName, someNotificationMessages);
int retryTimes = 100;
for (int i = 0; i < retryTimes; i++) {
configServiceWithCache.findLatestActiveRelease(someAppId, someClusterName, someNamespaceName, someNotificationMessages);
}
assertEquals(someRelease, release);
assertEquals(someRelease, anotherRelease);
verify(releaseMessageService, times(1)).findLatestReleaseMessageForMessages(Lists.newArrayList(someKey));
verify(releaseService, times(1)).findLatestActiveRelease(someAppId, someClusterName, someNamespaceName);
}
use of com.ctrip.framework.apollo.biz.entity.Release in project apollo by ctripcorp.
the class DefaultConfigServiceTest method testLoadConfig.
@Test
public void testLoadConfig() throws Exception {
when(releaseService.findLatestActiveRelease(someConfigAppId, someClusterName, defaultNamespaceName)).thenReturn(someRelease);
Release release = configService.loadConfig(someClientAppId, someClientIp, someClientLabel, someConfigAppId, someClusterName, defaultNamespaceName, someDataCenter, someNotificationMessages);
verify(releaseService, times(1)).findLatestActiveRelease(someConfigAppId, someClusterName, defaultNamespaceName);
assertEquals(someRelease, release);
}
Aggregations