use of com.ctrip.framework.apollo.core.dto.ApolloConfigNotification in project apollo by ctripcorp.
the class NotificationControllerIntegrationTest method testPollNotificationWithDefaultNamespaceWithNotificationIdOutDated.
@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 testPollNotificationWithDefaultNamespaceWithNotificationIdOutDated() throws Exception {
long someOutDatedNotificationId = 1;
ResponseEntity<ApolloConfigNotification> result = restTemplate.getForEntity("http://{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}¬ificationId={notificationId}", ApolloConfigNotification.class, getHostUrl(), someAppId, someCluster, defaultNamespace, someOutDatedNotificationId);
ApolloConfigNotification notification = result.getBody();
assertEquals(HttpStatus.OK, result.getStatusCode());
assertEquals(defaultNamespace, notification.getNamespaceName());
assertEquals(10, notification.getNotificationId());
}
use of com.ctrip.framework.apollo.core.dto.ApolloConfigNotification in project apollo by ctripcorp.
the class NotificationControllerIntegrationTest method testPollNotificationWithDefaultNamespaceWithNotificationIdNull.
@Test(timeout = 5000L)
@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 testPollNotificationWithDefaultNamespaceWithNotificationIdNull() throws Exception {
ResponseEntity<ApolloConfigNotification> result = restTemplate.getForEntity("http://{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}", ApolloConfigNotification.class, getHostUrl(), someAppId, someCluster, defaultNamespace);
ApolloConfigNotification notification = result.getBody();
assertEquals(HttpStatus.OK, result.getStatusCode());
assertEquals(defaultNamespace, notification.getNamespaceName());
assertEquals(10, notification.getNotificationId());
}
use of com.ctrip.framework.apollo.core.dto.ApolloConfigNotification in project apollo by ctripcorp.
the class NotificationControllerIntegrationTest method testPollNotificationWthPublicNamespaceAsFile.
@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 testPollNotificationWthPublicNamespaceAsFile() throws Exception {
String publicAppId = "somePublicAppId";
String someDC = "someDC";
AtomicBoolean stop = new AtomicBoolean();
periodicSendMessage(executorService, assembleKey(publicAppId, someDC, somePublicNamespace), stop);
ResponseEntity<ApolloConfigNotification> result = restTemplate.getForEntity("http://{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}&dataCenter={dataCenter}", ApolloConfigNotification.class, getHostUrl(), someAppId, someCluster, somePublicNamespace + ".properties", someDC);
stop.set(true);
ApolloConfigNotification notification = result.getBody();
assertEquals(HttpStatus.OK, result.getStatusCode());
assertEquals(somePublicNamespace, notification.getNamespaceName());
assertNotEquals(0, notification.getNotificationId());
}
use of com.ctrip.framework.apollo.core.dto.ApolloConfigNotification in project apollo by ctripcorp.
the class RemoteConfigLongPollService method updateNotifications.
private void updateNotifications(List<ApolloConfigNotification> deltaNotifications) {
for (ApolloConfigNotification notification : deltaNotifications) {
if (Strings.isNullOrEmpty(notification.getNamespaceName())) {
continue;
}
String namespaceName = notification.getNamespaceName();
if (m_notifications.containsKey(namespaceName)) {
m_notifications.put(namespaceName, notification.getNotificationId());
}
// since .properties are filtered out by default, so we need to check if there is notification with .properties suffix
String namespaceNameWithPropertiesSuffix = String.format("%s.%s", namespaceName, ConfigFileFormat.Properties.getValue());
if (m_notifications.containsKey(namespaceNameWithPropertiesSuffix)) {
m_notifications.put(namespaceNameWithPropertiesSuffix, notification.getNotificationId());
}
}
}
use of com.ctrip.framework.apollo.core.dto.ApolloConfigNotification in project apollo by ctripcorp.
the class RemoteConfigLongPollService method assembleNotifications.
String assembleNotifications(Map<String, Long> notificationsMap) {
List<ApolloConfigNotification> notifications = Lists.newArrayList();
for (Map.Entry<String, Long> entry : notificationsMap.entrySet()) {
ApolloConfigNotification notification = new ApolloConfigNotification(entry.getKey(), entry.getValue());
notifications.add(notification);
}
return GSON.toJson(notifications);
}
Aggregations