git.net

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

Question for CamelSpringDelegatingTestContextLoader'/Java-Config


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);

        }

}


 
Freundliche Grüße
Björn Ohm
 
8105 IT-Architektur / zentrale Entwicklung
Westfälische Provinzial Versicherung Aktiengesellschaft
 
Postanschrift: 24097 Kiel
Tel. +49 431 603-2734
Fax +49 431 603-102734
 
bjoern.ohm@xxxxxxxxxxxxx
 
www.provinzial-online.de
Rund um die Uhr für Sie da: www.meine-provinzial.de
 
Westfälische Provinzial Versicherung Aktiengesellschaft
Hausanschrift: Provinzial-Allee 1, 48159 Münster; Amtsgericht Münster HRB 6144
Vorstand: Dr. Wolfgang Breuer (Vorsitzender), Stefan Richter (stv. Vorsitzender), Frank Neuroth, Dr. Thomas Niemöller, Dr. Ulrich Scholten, Matthew Wilby
Vorsitzender des Aufsichtsrats: Matthias Löb
 
 

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.