git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Antwort: Re: Question for CamelSpringDelegatingTestContextLoader'/Java-Config


Hi,

yes we use camel-spring-javaconfig. And the unit tests work with the use 
of CamelSpringDelegatingTestContextLoader. We just wonder why it is 
deprecated, because at the moment there is no other way to get the tests 
running (without xml). Only for xml-configuration there exists the class 
CamelSpringTestContextLoader (CamelTestContextBootstrapper).

Even in the unit tests for camel-spring-javaconfig the 
CamelSpringDelegatingTestContextLoader class ist still in use...(
https://github.com/apache/camel/blob/master/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/BeanJavaConfigTest.java
).

Best regards...
 
 



Von:    Claus Ibsen <claus.ibsen@xxxxxxxxx>
An:     users@xxxxxxxxxxxxxxxx
Datum:  30.07.2018 17:05
Betreff:        Re: Question for 
CamelSpringDelegatingTestContextLoader'/Java-Config



Hi

Are you using camel-spring-javaconfig ?
Have you look in its unit tests what it does to test itself.

Its likely something we would deprecate in the future, to keep the
maintenance low. Also not so many users are using it.

And what problem do you have, if you use the deprecated class does it 
work?


On Fri, Jul 27, 2018 at 2:03 PM,  <bjoern.ohm@xxxxxxxxxxxxx> wrote:
> Hi everyone,
>
> we have updated to Camel 2.21.2. In our unit-tests we don't use
> xml-configuration, just java-configuration. We noticed, that the class
> 'CamelSpringDelegatingTestContextLoader' is marked as deprecated. But at 
the
> moment it is not possible for us to get our java-config-tests running
> without the class. Is there a way? Enclosed an example:
>
> ---------------
>
> package camel.test;
>
> import java.util.Collections;
> import java.util.List;
>
> import org.apache.camel.CamelContext;
> import org.apache.camel.EndpointInject;
> import org.apache.camel.ExchangePattern;
> import org.apache.camel.Produce;
> import org.apache.camel.ProducerTemplate;
> import org.apache.camel.builder.RouteBuilder;
> import org.apache.camel.component.mock.MockEndpoint;
> import org.apache.camel.spring.javaconfig.CamelConfiguration;
> import 
org.apache.camel.test.spring.CamelSpringDelegatingTestContextLoader;
> import org.apache.camel.test.spring.CamelSpringRunner;
> import org.apache.camel.test.spring.MockEndpoints;
> import org.junit.Test;
> import org.junit.runner.RunWith;
> import org.springframework.beans.factory.annotation.Autowired;
> import org.springframework.context.annotation.Configuration;
> import org.springframework.stereotype.Component;
> import org.springframework.test.context.ContextConfiguration;
>
> import camel.test.SimpleTest.SimpleConfiguration;
>
> @RunWith(CamelSpringRunner.class)
> //@BootstrapWith(CamelTestContextBootstrapper.class)
> @ContextConfiguration(classes = { SimpleConfiguration.class }, loader =
> CamelSpringDelegatingTestContextLoader.class)
> @MockEndpoints("seda:*")
> public class SimpleTest {
>
>         @Configuration
>         public static class SimpleConfiguration
>                         extends CamelConfiguration {
>
>                 @Override
>                 public List<RouteBuilder> routes() {
>                         return Collections.singletonList(new 
SimpleRoute());
>                 }
>
>         }
>
>         @Component
>         public static class SimpleRoute
>                         extends RouteBuilder {
>                 @Override
>                 public void configure() throws Exception {
>
> this.from("direct:in").log("log").to(ExchangePattern.InOnly, 
"seda:out");
>                 }
>         }
>
>         @Autowired
>         public CamelContext camelContext;
>
>         @Produce(uri = "direct:in")
>         protected ProducerTemplate testProducer;
>
>         @EndpointInject(uri = "mock:seda:out")
>         protected MockEndpoint sedaMock;
>
>         @Test
>         public void test() throws InterruptedException {
>                 this.sedaMock.expectedMessageCount(1);
>                 this.testProducer.sendBody("Message");
>
>                 MockEndpoint.assertIsSatisfied(this.camelContext);
>
>         }
>
> }
>
>
>




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



 
Diese E-Mail könnte vertrauliche und / oder rechtlich geschützte Informationen enthalten. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.

This e-mail may contain confidential and / or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.