Skip to content

Commit

Permalink
Test cleanup
Browse files Browse the repository at this point in the history
 * Use `EnableAutoConfiguration` instead of `SpringBootApplication` in tests
  • Loading branch information
sobychacko committed May 16, 2024
1 parent 49b7a80 commit fd9fa80
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2023 the original author or authors.
* Copyright 2015-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -46,7 +46,7 @@
import org.springframework.boot.actuate.amqp.RabbitHealthIndicator;
import org.springframework.boot.actuate.health.CompositeHealthContributor;
import org.springframework.boot.actuate.health.Status;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.Cloud;
import org.springframework.cloud.stream.binder.Binder;
Expand All @@ -69,6 +69,7 @@
import org.springframework.cloud.stream.config.ProducerMessageHandlerCustomizer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.amqp.inbound.AmqpInboundChannelAdapter;
import org.springframework.integration.amqp.inbound.AmqpMessageSource;
import org.springframework.integration.channel.DirectChannel;
Expand Down Expand Up @@ -418,7 +419,8 @@ void extendedProperties() {
assertThat(rabbitConsumerProperties.getMaxConcurrency()).isEqualTo(4);
}

@SpringBootApplication
@EnableAutoConfiguration
@Configuration
public static class SimpleProcessor {

@Bean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2023 the original author or authors.
* Copyright 2021-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,7 +27,7 @@
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.listener.MessageListenerContainer;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.stream.binder.BinderFactory;
import org.springframework.cloud.stream.binder.Binding;
Expand All @@ -43,6 +43,7 @@
import org.springframework.cloud.stream.config.ProducerMessageHandlerCustomizer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.amqp.outbound.RabbitStreamMessageHandler;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.channel.QueueChannel;
Expand All @@ -59,6 +60,7 @@

/**
* @author Gary Russell
* @author Soby Chacko
*/
class RabbitStreamBinderModuleTests {

Expand Down Expand Up @@ -131,7 +133,8 @@ void streamHandler() {
}
}

@SpringBootApplication(proxyBeanMethods = false)
@EnableAutoConfiguration
@Configuration
public static class SimpleProcessor {

@Bean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2023 the original author or authors.
* Copyright 2021-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,6 +16,7 @@

package org.springframework.cloud.stream.binder.rabbit.stream2;


import java.util.Properties;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
Expand All @@ -30,7 +31,7 @@
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.listener.MessageListenerContainer;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.amqp.EnvironmentBuilderCustomizer;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.stream.binder.BinderFactory;
Expand All @@ -43,6 +44,7 @@
import org.springframework.cloud.stream.config.ListenerContainerCustomizer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.messaging.MessageChannel;
Expand All @@ -52,6 +54,7 @@

/**
* @author Gary Russell
* @author Soby Chacko
*/
class RabbitStreamBinderModuleIntegrationTests {

Expand Down Expand Up @@ -89,7 +92,8 @@ void superStreamContainer() throws InterruptedException {
}
}

@SpringBootApplication(proxyBeanMethods = false)
@EnableAutoConfiguration
@Configuration
public static class SimpleProcessor {

final CountDownLatch consumerCountLatch = new CountDownLatch(3);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2023 the original author or authors.
* Copyright 2019-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -24,7 +24,7 @@
import org.junit.jupiter.api.Test;

import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -38,6 +38,7 @@
* is addressed.
*
* @author Oleg Zhurakousky
* @author Soby Chacko
*
*/
class GH1801Test {
Expand All @@ -58,7 +59,7 @@ void verifyNoNPEWhenFactoryMethodNull() throws Exception {
SampleBootApplication.main("--spring.cloud.stream.defaultBinder=integration1");
}

@SpringBootApplication
@EnableAutoConfiguration
public static class SampleBootApplication {
public static void main(String... args) throws Exception {
ClassLoader classLoader = createClassLoader(new String[] { "binder1" });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2023 the original author or authors.
* Copyright 2017-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,7 +40,7 @@
import org.junit.jupiter.api.Test;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cache.support.NoOpCacheManager;
import org.springframework.cloud.stream.schema.registry.EnableSchemaRegistryServer;
Expand All @@ -52,6 +52,7 @@
import org.springframework.cloud.stream.schema.registry.client.DefaultSchemaRegistryClient;
import org.springframework.cloud.stream.schema.registry.client.SchemaRegistryClient;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.support.MutableMessageHeaders;
import org.springframework.messaging.Message;
Expand All @@ -64,6 +65,7 @@
/**
* @author Vinicius Carvalho
* @author Sercan Karaoglu
* @author Soby Chacko
*/
class AvroMessageConverterSerializationTests {

Expand Down Expand Up @@ -222,7 +224,8 @@ private SchemaReference extractSchemaReference(MimeType mimeType) {
return schemaReference;
}

@SpringBootApplication
@EnableAutoConfiguration
@Configuration
@EnableSchemaRegistryServer
public static class ServerApplication {
public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2023 the original author or authors.
* Copyright 2016-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,7 +29,6 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
Expand Down Expand Up @@ -70,11 +69,12 @@
* @author Sercan Karaoglu
* @author James Gee
* @author Christian Tzolov
* @author Soby Chacko
*/
class AvroSchemaRegistryClientMessageConverterTests {


private ConfigurableApplicationContext schemaRegistryServerContext;

private RestTemplateBuilder restTemplateBuilder;

@BeforeEach
Expand Down Expand Up @@ -203,7 +203,8 @@ ServletWebServerFactory servletWebServerFactory() {

}

@SpringBootApplication
@EnableAutoConfiguration
@Configuration
@EnableSchemaRegistryServer
public static class ServerApplication {
public static void main(String[] args) {
Expand Down

0 comments on commit fd9fa80

Please sign in to comment.