use of com.ctrip.framework.apollo.core.dto.ApolloNotificationMessages in project apollo by ctripcorp.
the class NotificationControllerV2IntegrationTest method testPollNotificationWithMultiplePublicNamespaceWithIncorrectCaseWithNotificationIdOutDated.
@Test(timeout = 5000L)
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/test-release-message.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testPollNotificationWithMultiplePublicNamespaceWithIncorrectCaseWithNotificationIdOutDated() throws Exception {
String publicAppId = "somePublicAppId";
long someOutDatedNotificationId = 1;
long newNotificationId = 20;
String somePublicNameWithIncorrectCase = somePublicNamespace.toUpperCase();
// the same namespace with difference character case, and difference notification id
ResponseEntity<List<ApolloConfigNotification>> result = restTemplate.exchange("http://{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}", HttpMethod.GET, null, typeReference, getHostUrl(), someAppId, someCluster, transformApolloConfigNotificationsToString(somePublicNamespace, newNotificationId, somePublicNameWithIncorrectCase, someOutDatedNotificationId));
List<ApolloConfigNotification> notifications = result.getBody();
assertEquals(HttpStatus.OK, result.getStatusCode());
assertEquals(1, notifications.size());
assertEquals(somePublicNameWithIncorrectCase, notifications.get(0).getNamespaceName());
assertEquals(newNotificationId, notifications.get(0).getNotificationId());
String key = assembleKey(publicAppId, ConfigConsts.CLUSTER_NAME_DEFAULT, somePublicNamespace);
ApolloNotificationMessages messages = result.getBody().get(0).getMessages();
assertEquals(1, messages.getDetails().size());
assertTrue(messages.has(key));
assertEquals(newNotificationId, messages.get(key).longValue());
}
use of com.ctrip.framework.apollo.core.dto.ApolloNotificationMessages in project apollo by ctripcorp.
the class NotificationControllerV2IntegrationTest method testPollNotificationWithPrivateNamespaceAsFile.
@Test(timeout = 5000L)
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testPollNotificationWithPrivateNamespaceAsFile() throws Exception {
String namespace = "someNamespace.xml";
AtomicBoolean stop = new AtomicBoolean();
String key = assembleKey(someAppId, ConfigConsts.CLUSTER_NAME_DEFAULT, namespace);
periodicSendMessage(executorService, key, stop);
ResponseEntity<List<ApolloConfigNotification>> result = restTemplate.exchange("http://{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}", HttpMethod.GET, null, typeReference, getHostUrl(), someAppId, someCluster, transformApolloConfigNotificationsToString(namespace, ConfigConsts.NOTIFICATION_ID_PLACEHOLDER));
stop.set(true);
List<ApolloConfigNotification> notifications = result.getBody();
assertEquals(HttpStatus.OK, result.getStatusCode());
assertEquals(1, notifications.size());
assertEquals(namespace, notifications.get(0).getNamespaceName());
assertNotEquals(0, notifications.get(0).getNotificationId());
ApolloNotificationMessages messages = result.getBody().get(0).getMessages();
assertEquals(1, messages.getDetails().size());
assertTrue(messages.has(key));
assertNotEquals(ConfigConsts.NOTIFICATION_ID_PLACEHOLDER, messages.get(key).longValue());
}
use of com.ctrip.framework.apollo.core.dto.ApolloNotificationMessages in project apollo by ctripcorp.
the class NotificationControllerV2IntegrationTest method testPollNotificationWithMultipleNamespacesAndIncorrectCase.
@Test
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testPollNotificationWithMultipleNamespacesAndIncorrectCase() throws Exception {
AtomicBoolean stop = new AtomicBoolean();
String key = assembleKey(someAppId, someCluster, somePublicNamespace);
periodicSendMessage(executorService, key, stop);
String someDefaultNamespaceWithIncorrectCase = defaultNamespace.toUpperCase();
String somePublicNamespaceWithIncorrectCase = somePublicNamespace.toUpperCase();
ResponseEntity<List<ApolloConfigNotification>> result = restTemplate.exchange("http://{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}", HttpMethod.GET, null, typeReference, getHostUrl(), someAppId, someCluster, transformApolloConfigNotificationsToString(defaultNamespace + ".properties", ConfigConsts.NOTIFICATION_ID_PLACEHOLDER, someDefaultNamespaceWithIncorrectCase, ConfigConsts.NOTIFICATION_ID_PLACEHOLDER, somePublicNamespaceWithIncorrectCase, ConfigConsts.NOTIFICATION_ID_PLACEHOLDER));
stop.set(true);
List<ApolloConfigNotification> notifications = result.getBody();
assertEquals(HttpStatus.OK, result.getStatusCode());
assertEquals(1, notifications.size());
assertEquals(somePublicNamespaceWithIncorrectCase, notifications.get(0).getNamespaceName());
assertNotEquals(0, notifications.get(0).getNotificationId());
ApolloNotificationMessages messages = result.getBody().get(0).getMessages();
assertEquals(1, messages.getDetails().size());
assertTrue(messages.has(key));
assertNotEquals(ConfigConsts.NOTIFICATION_ID_PLACEHOLDER, messages.get(key).longValue());
}
use of com.ctrip.framework.apollo.core.dto.ApolloNotificationMessages in project apollo by ctripcorp.
the class NotificationControllerV2IntegrationTest method testPollNotificationWithMultipleNamespacesAndNotificationIdsOutDated.
@Test(timeout = 5000L)
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/test-release-message.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testPollNotificationWithMultipleNamespacesAndNotificationIdsOutDated() throws Exception {
String publicAppId = "somePublicAppId";
long someOutDatedNotificationId = 1;
long newDefaultNamespaceNotificationId = 10;
long newPublicNamespaceNotification = 20;
ResponseEntity<List<ApolloConfigNotification>> result = restTemplate.exchange("http://{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}¬ifications={notifications}", HttpMethod.GET, null, typeReference, getHostUrl(), someAppId, someCluster, transformApolloConfigNotificationsToString(somePublicNamespace, someOutDatedNotificationId, defaultNamespace, someOutDatedNotificationId));
List<ApolloConfigNotification> notifications = result.getBody();
assertEquals(HttpStatus.OK, result.getStatusCode());
assertEquals(2, notifications.size());
Set<String> outDatedNamespaces = Sets.newHashSet(notifications.get(0).getNamespaceName(), notifications.get(1).getNamespaceName());
assertEquals(Sets.newHashSet(defaultNamespace, somePublicNamespace), outDatedNamespaces);
Set<Long> newNotificationIds = Sets.newHashSet(notifications.get(0).getNotificationId(), notifications.get(1).getNotificationId());
assertEquals(Sets.newHashSet(newDefaultNamespaceNotificationId, newPublicNamespaceNotification), newNotificationIds);
String defaultNamespaceKey = assembleKey(someAppId, ConfigConsts.CLUSTER_NAME_DEFAULT, ConfigConsts.NAMESPACE_APPLICATION);
String publicNamespaceKey = assembleKey(publicAppId, ConfigConsts.CLUSTER_NAME_DEFAULT, somePublicNamespace);
ApolloNotificationMessages firstMessages = notifications.get(0).getMessages();
ApolloNotificationMessages secondMessages = notifications.get(1).getMessages();
assertEquals(1, firstMessages.getDetails().size());
assertEquals(1, secondMessages.getDetails().size());
assertTrue((firstMessages.has(defaultNamespaceKey) && firstMessages.get(defaultNamespaceKey).equals(newDefaultNamespaceNotificationId)) || (firstMessages.has(publicNamespaceKey) && firstMessages.get(publicNamespaceKey).equals(newPublicNamespaceNotification)));
assertTrue((secondMessages.has(defaultNamespaceKey) && secondMessages.get(defaultNamespaceKey).equals(newDefaultNamespaceNotificationId)) || (secondMessages.has(publicNamespaceKey) && secondMessages.get(publicNamespaceKey).equals(newPublicNamespaceNotification)));
}
use of com.ctrip.framework.apollo.core.dto.ApolloNotificationMessages in project apollo by ctripcorp.
the class ConfigServiceWithCacheTest method setUp.
@Before
public void setUp() throws Exception {
configServiceWithCache = new ConfigServiceWithCache();
ReflectionTestUtils.setField(configServiceWithCache, "releaseService", releaseService);
ReflectionTestUtils.setField(configServiceWithCache, "releaseMessageService", releaseMessageService);
configServiceWithCache.initialize();
someAppId = "someAppId";
someClusterName = "someClusterName";
someNamespaceName = "someNamespaceName";
someNotificationId = 1;
someKey = ReleaseMessageKeyGenerator.generate(someAppId, someClusterName, someNamespaceName);
someNotificationMessages = new ApolloNotificationMessages();
}
Aggregations