You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Minh Tran <da...@gmail.com> on 2016/10/21 03:15:25 UTC

Spring Boot autoconfiguration

Hi

I’m using Camel 2.18.0 and Spring Boot. I’m trying to write a unit test that excludes any Camel from starting up.

Prior to 2.18.0, I could do this by simply excluding CamelAutoConfiguration. But now in 2.18.0, it looks like a whole bunch of other AutoConfiguration for Camel has been added. So far I’ve added about 20 extra classes to exclude before I gave up. Here is what I have so far

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
public class PlainTest {

	@Configuration
	@EnableAutoConfiguration(exclude = { CamelAutoConfiguration.class, DirectComponentAutoConfiguration.class, DirectVmComponentAutoConfiguration.class,
			LogComponentAutoConfiguration.class, PropertiesComponentAutoConfiguration.class, RestComponentAutoConfiguration.class,
			SchedulerComponentAutoConfiguration.class, SedaComponentAutoConfiguration.class, StubComponentAutoConfiguration.class,
			ValidatorComponentAutoConfiguration.class, VmComponentAutoConfiguration.class, XsltComponentAutoConfiguration.class,
			GzipDataFormatAutoConfiguration.class, SerializationDataFormatAutoConfiguration.class, StringDataFormatAutoConfiguration.class,
			ZipDataFormatAutoConfiguration.class, BeanLanguageAutoConfiguration.class, ConstantLanguageAutoConfiguration.class,
			HeaderLanguageAutoConfiguration.class })
	public static class Config {

	}

	@Test
	public void test() {
		// do something
	}
}


Could someone tell me the proper way of excluding Camel in my unit tests? Thanks.



Re: Spring Boot autoconfiguration

Posted by Claus Ibsen <cl...@gmail.com>.
You can configure camel.springboot.auto-startup=false which wont start
routes etc.

For Camel itself to not start totally, then that would require a new
option to be introduced into camel-spring-boot.

We love contributions so a PR and JIRA is welcome
http://camel.apache.org/contributing.html

On Sat, Oct 22, 2016 at 12:53 PM, Minh Tran <da...@gmail.com> wrote:
> Hi
>
> There are times when running certain unit tests without Camel  is a good thing. For example, testing POJOs. There’s no need to startup all the routes as they’re not being used. Moving them into a different project isn’t very practical.
>
>> On 21 Oct 2016, at 11:39 PM, Mark Nuttall <mk...@gmail.com> wrote:
>>
>> It might be easier and better to move that code to a different project. It
>> sounds like you have non camel specific code you want to test.
>>
>> On Oct 20, 2016 11:15 PM, "Minh Tran" <da...@gmail.com> wrote:
>>
>>> Hi
>>>
>>> I’m using Camel 2.18.0 and Spring Boot. I’m trying to write a unit test
>>> that excludes any Camel from starting up.
>>>
>>> Prior to 2.18.0, I could do this by simply excluding
>>> CamelAutoConfiguration. But now in 2.18.0, it looks like a whole bunch of
>>> other AutoConfiguration for Camel has been added. So far I’ve added about
>>> 20 extra classes to exclude before I gave up. Here is what I have so far
>>>
>>> @RunWith(SpringJUnit4ClassRunner.class)
>>> @SpringBootTest
>>> public class PlainTest {
>>>
>>>        @Configuration
>>>        @EnableAutoConfiguration(exclude = {
>>> CamelAutoConfiguration.class, DirectComponentAutoConfiguration.class,
>>> DirectVmComponentAutoConfiguration.class,
>>>                        LogComponentAutoConfiguration.class,
>>> PropertiesComponentAutoConfiguration.class, RestComponentAutoConfiguration
>>> .class,
>>>                        SchedulerComponentAutoConfiguration.class,
>>> SedaComponentAutoConfiguration.class, StubComponentAutoConfiguration
>>> .class,
>>>                        ValidatorComponentAutoConfiguration.class,
>>> VmComponentAutoConfiguration.class, XsltComponentAutoConfiguration.class,
>>>                        GzipDataFormatAutoConfiguration.class,
>>> SerializationDataFormatAutoConfiguration.class,
>>> StringDataFormatAutoConfiguration.class,
>>>                        ZipDataFormatAutoConfiguration.class,
>>> BeanLanguageAutoConfiguration.class, ConstantLanguageAutoConfigurat
>>> ion.class,
>>>                        HeaderLanguageAutoConfiguration.class })
>>>        public static class Config {
>>>
>>>        }
>>>
>>>        @Test
>>>        public void test() {
>>>                // do something
>>>        }
>>> }
>>>
>>>
>>> Could someone tell me the proper way of excluding Camel in my unit tests?
>>> Thanks.
>>>
>>>
>>>
>



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Spring Boot autoconfiguration

Posted by Minh Tran <da...@gmail.com>.
Hi

There are times when running certain unit tests without Camel  is a good thing. For example, testing POJOs. There’s no need to startup all the routes as they’re not being used. Moving them into a different project isn’t very practical.

> On 21 Oct 2016, at 11:39 PM, Mark Nuttall <mk...@gmail.com> wrote:
> 
> It might be easier and better to move that code to a different project. It
> sounds like you have non camel specific code you want to test.
> 
> On Oct 20, 2016 11:15 PM, "Minh Tran" <da...@gmail.com> wrote:
> 
>> Hi
>> 
>> I’m using Camel 2.18.0 and Spring Boot. I’m trying to write a unit test
>> that excludes any Camel from starting up.
>> 
>> Prior to 2.18.0, I could do this by simply excluding
>> CamelAutoConfiguration. But now in 2.18.0, it looks like a whole bunch of
>> other AutoConfiguration for Camel has been added. So far I’ve added about
>> 20 extra classes to exclude before I gave up. Here is what I have so far
>> 
>> @RunWith(SpringJUnit4ClassRunner.class)
>> @SpringBootTest
>> public class PlainTest {
>> 
>>        @Configuration
>>        @EnableAutoConfiguration(exclude = {
>> CamelAutoConfiguration.class, DirectComponentAutoConfiguration.class,
>> DirectVmComponentAutoConfiguration.class,
>>                        LogComponentAutoConfiguration.class,
>> PropertiesComponentAutoConfiguration.class, RestComponentAutoConfiguration
>> .class,
>>                        SchedulerComponentAutoConfiguration.class,
>> SedaComponentAutoConfiguration.class, StubComponentAutoConfiguration
>> .class,
>>                        ValidatorComponentAutoConfiguration.class,
>> VmComponentAutoConfiguration.class, XsltComponentAutoConfiguration.class,
>>                        GzipDataFormatAutoConfiguration.class,
>> SerializationDataFormatAutoConfiguration.class,
>> StringDataFormatAutoConfiguration.class,
>>                        ZipDataFormatAutoConfiguration.class,
>> BeanLanguageAutoConfiguration.class, ConstantLanguageAutoConfigurat
>> ion.class,
>>                        HeaderLanguageAutoConfiguration.class })
>>        public static class Config {
>> 
>>        }
>> 
>>        @Test
>>        public void test() {
>>                // do something
>>        }
>> }
>> 
>> 
>> Could someone tell me the proper way of excluding Camel in my unit tests?
>> Thanks.
>> 
>> 
>> 


Re: Spring Boot autoconfiguration

Posted by Mark Nuttall <mk...@gmail.com>.
It might be easier and better to move that code to a different project. It
sounds like you have non camel specific code you want to test.

On Oct 20, 2016 11:15 PM, "Minh Tran" <da...@gmail.com> wrote:

> Hi
>
> I’m using Camel 2.18.0 and Spring Boot. I’m trying to write a unit test
> that excludes any Camel from starting up.
>
> Prior to 2.18.0, I could do this by simply excluding
> CamelAutoConfiguration. But now in 2.18.0, it looks like a whole bunch of
> other AutoConfiguration for Camel has been added. So far I’ve added about
> 20 extra classes to exclude before I gave up. Here is what I have so far
>
> @RunWith(SpringJUnit4ClassRunner.class)
> @SpringBootTest
> public class PlainTest {
>
>         @Configuration
>         @EnableAutoConfiguration(exclude = {
> CamelAutoConfiguration.class, DirectComponentAutoConfiguration.class,
> DirectVmComponentAutoConfiguration.class,
>                         LogComponentAutoConfiguration.class,
> PropertiesComponentAutoConfiguration.class, RestComponentAutoConfiguration
> .class,
>                         SchedulerComponentAutoConfiguration.class,
> SedaComponentAutoConfiguration.class, StubComponentAutoConfiguration
> .class,
>                         ValidatorComponentAutoConfiguration.class,
> VmComponentAutoConfiguration.class, XsltComponentAutoConfiguration.class,
>                         GzipDataFormatAutoConfiguration.class,
> SerializationDataFormatAutoConfiguration.class,
> StringDataFormatAutoConfiguration.class,
>                         ZipDataFormatAutoConfiguration.class,
> BeanLanguageAutoConfiguration.class, ConstantLanguageAutoConfigurat
> ion.class,
>                         HeaderLanguageAutoConfiguration.class })
>         public static class Config {
>
>         }
>
>         @Test
>         public void test() {
>                 // do something
>         }
> }
>
>
> Could someone tell me the proper way of excluding Camel in my unit tests?
> Thanks.
>
>
>