use of com.google.cloud.spring.pubsub.support.DefaultSubscriberFactory in project spring-cloud-gcp by GoogleCloudPlatform.
the class GcpPubSubAutoConfigurationTests method retryableCodes_Internal.
@Test
void retryableCodes_Internal() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(GcpPubSubAutoConfiguration.class)).withUserConfiguration(TestConfig.class).withPropertyValues("spring.cloud.gcp.pubsub.subscriber.retryableCodes=INTERNAL");
contextRunner.run(ctx -> {
GcpPubSubProperties properties = ctx.getBean(GcpPubSubProperties.class);
GcpProjectIdProvider projectIdProvider = ctx.getBean(GcpProjectIdProvider.class);
DefaultSubscriberFactory defaultSubscriberFactory = ctx.getBean("defaultSubscriberFactory", DefaultSubscriberFactory.class);
assertThat(properties.getSubscriber().getRetryableCodes()).isEqualTo(new Code[] { Code.INTERNAL });
assertThat(properties.computeRetryableCodes("subscription-name", projectIdProvider.getProjectId())).isEqualTo(new Code[] { Code.INTERNAL });
assertThat(defaultSubscriberFactory.getRetryableCodes("subscription-name")).isEqualTo(new Code[] { Code.INTERNAL });
});
}
use of com.google.cloud.spring.pubsub.support.DefaultSubscriberFactory in project spring-cloud-gcp by GoogleCloudPlatform.
the class GcpPubSubAutoConfigurationTests method retryableCodes_globalAndDifferentSelectiveConfigurationSet_pickGlobal.
@Test
void retryableCodes_globalAndDifferentSelectiveConfigurationSet_pickGlobal() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(GcpPubSubAutoConfiguration.class)).withUserConfiguration(TestConfig.class).withPropertyValues("spring.cloud.gcp.pubsub.subscriber.retryableCodes=INTERNAL", "spring.cloud.gcp.pubsub.subscription.subscription-name.pull-counts=2");
contextRunner.run(ctx -> {
DefaultSubscriberFactory defaultSubscriberFactory = ctx.getBean("defaultSubscriberFactory", DefaultSubscriberFactory.class);
assertThat(defaultSubscriberFactory.getRetryableCodes("subscription-name")).isEqualTo(new Code[] { Code.INTERNAL });
});
}
use of com.google.cloud.spring.pubsub.support.DefaultSubscriberFactory in project spring-cloud-gcp by GoogleCloudPlatform.
the class GcpPubSubAutoConfigurationTests method customFlowControlUsedWhenProvided.
@Test
void customFlowControlUsedWhenProvided() {
FlowControlSettings flowControlSettings = mock(FlowControlSettings.class);
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(GcpPubSubAutoConfiguration.class)).withUserConfiguration(TestConfig.class).withBean("subscriberFlowControlSettings", FlowControlSettings.class, () -> flowControlSettings);
contextRunner.run(ctx -> {
DefaultSubscriberFactory subscriberFactory = ctx.getBean("defaultSubscriberFactory", DefaultSubscriberFactory.class);
assertThat(subscriberFactory.getFlowControlSettings("name")).isSameAs(flowControlSettings);
assertThat(ctx.containsBean("globalSubscriberFlowControlSettings")).isFalse();
});
}
use of com.google.cloud.spring.pubsub.support.DefaultSubscriberFactory in project spring-cloud-gcp by GoogleCloudPlatform.
the class GcpPubSubAutoConfigurationTests method retryableCodes_globalAndSelectiveConfigurationSet_selectiveTakesPrecedence.
@Test
void retryableCodes_globalAndSelectiveConfigurationSet_selectiveTakesPrecedence() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(GcpPubSubAutoConfiguration.class)).withUserConfiguration(TestConfig.class).withPropertyValues("spring.cloud.gcp.pubsub.subscriber.retryableCodes=INTERNAL", "spring.cloud.gcp.pubsub.subscription.subscription-name.retryableCodes=UNKNOWN,ABORTED,UNAVAILABLE");
contextRunner.run(ctx -> {
DefaultSubscriberFactory defaultSubscriberFactory = ctx.getBean("defaultSubscriberFactory", DefaultSubscriberFactory.class);
assertThat(defaultSubscriberFactory.getRetryableCodes("subscription-name")).isEqualTo(new Code[] { Code.UNKNOWN, Code.ABORTED, Code.UNAVAILABLE });
assertThat(defaultSubscriberFactory.getRetryableCodes("other")).isEqualTo(new Code[] { Code.INTERNAL });
});
}
use of com.google.cloud.spring.pubsub.support.DefaultSubscriberFactory in project spring-cloud-gcp by GoogleCloudPlatform.
the class GcpPubSubAutoConfigurationTests method subscriberExecutorProvider_selectiveConfigurationSet.
@Test
void subscriberExecutorProvider_selectiveConfigurationSet() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(GcpPubSubAutoConfiguration.class)).withPropertyValues("spring.cloud.gcp.pubsub.subscription.subscription-name.executor-threads=7").withUserConfiguration(TestConfig.class);
contextRunner.run(ctx -> {
DefaultSubscriberFactory factory = (DefaultSubscriberFactory) ctx.getBean("defaultSubscriberFactory");
ExecutorProvider selectiveExecutorProvider = (ExecutorProvider) ctx.getBean("subscriberExecutorProvider-projects/fake project/subscriptions/subscription-name");
ExecutorProvider globalExecutorProvider = (ExecutorProvider) ctx.getBean("globalSubscriberExecutorProvider");
assertThat(globalExecutorProvider).isNotNull();
assertThat(selectiveExecutorProvider).isNotNull();
assertThat(factory.getExecutorProvider("subscription-name")).isSameAs(selectiveExecutorProvider);
});
}
Aggregations