org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration Java Examples

The following examples show how to use org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EventRegistryAutoConfigurationTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Test
public void eventRegistryWithKafka() {
    contextRunner
        .withConfiguration(AutoConfigurations.of(KafkaAutoConfiguration.class))
        .run(context -> {
            assertThat(context)
                .hasSingleBean(KafkaChannelDefinitionProcessor.class)
                .hasBean("kafkaChannelDefinitionProcessor");
            EventRegistryEngine eventRegistryEngine = context.getBean(EventRegistryEngine.class);
            assertThat(eventRegistryEngine).as("Event registry engine").isNotNull();

            IterableAssert<ChannelModelProcessor> channelModelProcessorAssert = assertThat(
                eventRegistryEngine.getEventRegistryEngineConfiguration().getChannelModelProcessors());

            channelModelProcessorAssert
                .hasSize(5);

            channelModelProcessorAssert
                .element(0)
                .isEqualTo(context.getBean("kafkaChannelDefinitionProcessor", ChannelModelProcessor.class));

            channelModelProcessorAssert
                .element(1)
                .isInstanceOf(DelegateExpressionInboundChannelModelProcessor.class);

            channelModelProcessorAssert
                .element(2)
                .isInstanceOf(DelegateExpressionOutboundChannelModelProcessor.class);

            channelModelProcessorAssert
                .element(3)
                .isInstanceOf(InboundChannelModelProcessor.class);

            channelModelProcessorAssert
                .element(4)
                .isInstanceOf(OutboundChannelModelProcessor.class);
        });
}
 
Example #2
Source File: ZipkinAutoConfigurationTests.java    From spring-cloud-sleuth with Apache License 2.0 5 votes vote down vote up
@Test
public void overrideKafkaTopic() throws Exception {
	this.context = new AnnotationConfigApplicationContext();
	environment().setProperty("spring.zipkin.kafka.topic", "zipkin2");
	environment().setProperty("spring.zipkin.sender.type", "kafka");
	this.context.register(PropertyPlaceholderAutoConfiguration.class,
			KafkaAutoConfiguration.class, ZipkinAutoConfiguration.class,
			TraceAutoConfiguration.class);
	this.context.refresh();

	then(this.context.getBean(Sender.class)).isInstanceOf(KafkaSender.class);

	this.context.close();
}
 
Example #3
Source File: ZipkinAutoConfigurationTests.java    From spring-cloud-sleuth with Apache License 2.0 5 votes vote down vote up
@Test
public void canOverrideBySender() throws Exception {
	this.context = new AnnotationConfigApplicationContext();
	environment().setProperty("spring.zipkin.sender.type", "web");
	this.context.register(PropertyPlaceholderAutoConfiguration.class,
			RabbitAutoConfiguration.class, KafkaAutoConfiguration.class,
			ZipkinAutoConfiguration.class, TraceAutoConfiguration.class);
	this.context.refresh();

	then(this.context.getBean(Sender.class).getClass().getName())
			.contains("RestTemplateSender");

	this.context.close();
}
 
Example #4
Source File: ZipkinAutoConfigurationTests.java    From spring-cloud-sleuth with Apache License 2.0 5 votes vote down vote up
@Test
public void canOverrideBySenderAndIsCaseInsensitive() throws Exception {
	this.context = new AnnotationConfigApplicationContext();
	environment().setProperty("spring.zipkin.sender.type", "WEB");
	this.context.register(PropertyPlaceholderAutoConfiguration.class,
			RabbitAutoConfiguration.class, KafkaAutoConfiguration.class,
			ZipkinAutoConfiguration.class, TraceAutoConfiguration.class);
	this.context.refresh();

	then(this.context.getBean(Sender.class).getClass().getName())
			.contains("RestTemplateSender");

	this.context.close();
}
 
Example #5
Source File: ZipkinAutoConfigurationTests.java    From spring-cloud-sleuth with Apache License 2.0 5 votes vote down vote up
@Test
public void rabbitWinsWhenKafkaPresent() throws Exception {
	this.context = new AnnotationConfigApplicationContext();
	environment().setProperty("spring.zipkin.sender.type", "rabbit");
	this.context.register(PropertyPlaceholderAutoConfiguration.class,
			RabbitAutoConfiguration.class, KafkaAutoConfiguration.class,
			ZipkinAutoConfiguration.class, TraceAutoConfiguration.class);
	this.context.refresh();

	then(this.context.getBean(Sender.class)).isInstanceOf(RabbitMQSender.class);

	this.context.close();
}
 
Example #6
Source File: EventRegistryAutoConfigurationTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Test
public void eventRegistryWithJmsRabbitAndKafka() {
    contextRunner
        .withConfiguration(AutoConfigurations.of(
            ActiveMQAutoConfiguration.class,
            JmsAutoConfiguration.class,
            RabbitAutoConfiguration.class,
            KafkaAutoConfiguration.class
        ))
        .run(context -> {
            assertThat(context)
                .hasSingleBean(JmsChannelModelProcessor.class)
                .hasBean("jmsChannelDefinitionProcessor")
                .hasSingleBean(RabbitChannelDefinitionProcessor.class)
                .hasBean("rabbitChannelDefinitionProcessor")
                .hasSingleBean(KafkaChannelDefinitionProcessor.class)
                .hasBean("kafkaChannelDefinitionProcessor");
            EventRegistryEngine eventRegistryEngine = context.getBean(EventRegistryEngine.class);
            assertThat(eventRegistryEngine).as("Event registry engine").isNotNull();

            EventRegistryEngineConfiguration eventRegistryEngineConfiguration = eventRegistryEngine.getEventRegistryEngineConfiguration();
            IterableAssert<ChannelModelProcessor> channelModelProcessorAssert = assertThat(
                eventRegistryEngineConfiguration.getChannelModelProcessors());
            channelModelProcessorAssert
                .hasSize(7)
                .contains(
                    context.getBean("jmsChannelDefinitionProcessor", JmsChannelModelProcessor.class),
                    context.getBean("rabbitChannelDefinitionProcessor", RabbitChannelDefinitionProcessor.class),
                    context.getBean("kafkaChannelDefinitionProcessor", KafkaChannelDefinitionProcessor.class)
                );

            channelModelProcessorAssert
                .element(3)
                .isInstanceOf(DelegateExpressionInboundChannelModelProcessor.class);

            channelModelProcessorAssert
                .element(4)
                .isInstanceOf(DelegateExpressionOutboundChannelModelProcessor.class);

            channelModelProcessorAssert
                .element(5)
                .isInstanceOf(InboundChannelModelProcessor.class);

            channelModelProcessorAssert
                .element(6)
                .isInstanceOf(OutboundChannelModelProcessor.class);
        });
}
 
Example #7
Source File: EventRegistryAutoConfigurationTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Test
public void eventRegistryWithCustomDefinitionProcessors() {
    contextRunner
        .withConfiguration(AutoConfigurations.of(
            ActiveMQAutoConfiguration.class,
            JmsAutoConfiguration.class,
            RabbitAutoConfiguration.class,
            KafkaAutoConfiguration.class
        ))
        .withUserConfiguration(CustomChannelDefinitionProcessorsConfiguration.class)
        .run(context -> {
            assertThat(context)
                .doesNotHaveBean(JmsChannelModelProcessor.class)
                .hasBean("jmsChannelDefinitionProcessor")
                .doesNotHaveBean(RabbitChannelDefinitionProcessor.class)
                .hasBean("rabbitChannelDefinitionProcessor")
                .doesNotHaveBean(KafkaChannelDefinitionProcessor.class)
                .hasBean("kafkaChannelDefinitionProcessor")
                .hasBean("customChannelDefinitionProcessor");
            EventRegistryEngine eventRegistryEngine = context.getBean(EventRegistryEngine.class);
            assertThat(eventRegistryEngine).as("Event registry engine").isNotNull();

            EventRegistryEngineConfiguration eventRegistryEngineConfiguration = eventRegistryEngine.getEventRegistryEngineConfiguration();
            IterableAssert<ChannelModelProcessor> channelModelProcessorAssert = assertThat(
                eventRegistryEngineConfiguration.getChannelModelProcessors());
            channelModelProcessorAssert
                .hasSize(8);

            channelModelProcessorAssert
                .element(0)
                .isEqualTo(context.getBean("customChannelDefinitionProcessor", ChannelModelProcessor.class));

            channelModelProcessorAssert
                .element(1)
                .isEqualTo(context.getBean("rabbitChannelDefinitionProcessor", ChannelModelProcessor.class));

            channelModelProcessorAssert
                .element(2)
                .isEqualTo(context.getBean("jmsChannelDefinitionProcessor", ChannelModelProcessor.class));

        channelModelProcessorAssert
                .element(3)
                .isEqualTo(context.getBean("kafkaChannelDefinitionProcessor", ChannelModelProcessor.class));

            channelModelProcessorAssert
                .element(4)
                .isInstanceOf(DelegateExpressionInboundChannelModelProcessor.class);

            channelModelProcessorAssert
                .element(5)
                .isInstanceOf(DelegateExpressionOutboundChannelModelProcessor.class);

            channelModelProcessorAssert
                .element(6)
                .isInstanceOf(InboundChannelModelProcessor.class);

            channelModelProcessorAssert
                .element(7)
                .isInstanceOf(OutboundChannelModelProcessor.class);
        });
}