Search in sources :

Example 26 with DefaultSubscriberFactory

use of com.google.cloud.spring.pubsub.support.DefaultSubscriberFactory in project spring-cloud-gcp by GoogleCloudPlatform.

the class GcpPubSubAutoConfigurationTests method createSubscriberStub_flowControlSettings_noPropertiesSet.

@Test
void createSubscriberStub_flowControlSettings_noPropertiesSet() {
    ApplicationContextRunner contextRunner = new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(GcpPubSubAutoConfiguration.class)).withUserConfiguration(TestConfig.class);
    contextRunner.run(ctx -> {
        DefaultSubscriberFactory subscriberFactory = ctx.getBean("defaultSubscriberFactory", DefaultSubscriberFactory.class);
        Subscriber subscriber = subscriberFactory.createSubscriber("subscription-name", (message, consumer) -> {
        });
        assertThat(subscriber.getFlowControlSettings()).isEqualTo(Subscriber.Builder.getDefaultFlowControlSettings());
    });
}
Also used : DefaultSubscriberFactory(com.google.cloud.spring.pubsub.support.DefaultSubscriberFactory) Subscriber(com.google.cloud.pubsub.v1.Subscriber) ApplicationContextRunner(org.springframework.boot.test.context.runner.ApplicationContextRunner) Test(org.junit.jupiter.api.Test)

Aggregations

DefaultSubscriberFactory (com.google.cloud.spring.pubsub.support.DefaultSubscriberFactory)26 Test (org.junit.jupiter.api.Test)25 ApplicationContextRunner (org.springframework.boot.test.context.runner.ApplicationContextRunner)25 GcpProjectIdProvider (com.google.cloud.spring.core.GcpProjectIdProvider)12 PubSubConfiguration (com.google.cloud.spring.pubsub.core.PubSubConfiguration)10 FlowControlSettings (com.google.api.gax.batching.FlowControlSettings)6 RetrySettings (com.google.api.gax.retrying.RetrySettings)6 ExecutorProvider (com.google.api.gax.core.ExecutorProvider)5 Code (com.google.api.gax.rpc.StatusCode.Code)1 Subscriber (com.google.cloud.pubsub.v1.Subscriber)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1