Return-Path: X-Original-To: apmail-camel-issues-archive@minotaur.apache.org Delivered-To: apmail-camel-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 48CA7CCC5 for ; Thu, 20 Nov 2014 12:48:34 +0000 (UTC) Received: (qmail 74234 invoked by uid 500); 20 Nov 2014 12:48:34 -0000 Delivered-To: apmail-camel-issues-archive@camel.apache.org Received: (qmail 74204 invoked by uid 500); 20 Nov 2014 12:48:34 -0000 Mailing-List: contact issues-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list issues@camel.apache.org Received: (qmail 74195 invoked by uid 99); 20 Nov 2014 12:48:34 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Nov 2014 12:48:34 +0000 Date: Thu, 20 Nov 2014 12:48:33 +0000 (UTC) From: "Gareth Western (JIRA)" To: issues@camel.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (CAMEL-8064) MockEndpointsAndSkip annotation does not resolve property placeholders MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CAMEL-8064?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Gareth Western updated CAMEL-8064: ---------------------------------- Description: We are using property placeholders in our route configuration in order to switch components in our unit tests. For example: {code} from(MyRouteBuilder.ENTRY_ENDPOINT) .routeId("some.route") .process(doSomething()) .to(MyRouteBuilder.EXIT_ENDPOINT); {code} Where ENTRY_ENDPOINT = "{{entry.endpoint.uri}}" and EXIT_ENDPOINT = "{{exit.endpoint.uri}}" Then, in production, the Camel context is initialized with a properties file where the URIs use the "jms" component, while in our unit tests we initialise the context with a 'test' properties file where the URIs use the "direct" component. For example: {code} # test.properties entry.endpoint.uri = direct:myRouteBuilder.entry exit.endpoint.uri = direct:myRouteBuilder.exit {code} A typical RouteBuilder unit test looks something like this: {code} @RunWith(CamelSpringJUnit4ClassRunner.class) @ContextConfiguration( classes = { MyRouteBuilderTest.TestConfig.class }, loader = CamelSpringDelegatingTestContextLoader.class ) @MockEndpointsAndSkip(value = "direct:myRouteBuilder.exit") public class MyRouteBuilderTest { @Produce(uri = MyRouteBuilder.ENTRY_ENDPOINT) private ProducerTemplate myRouteBuilderProducer; @EndpointInject(uri = "mock:" + MyRouteBuilder.EXIT_ENDPOINT) private MockEndpoint mockOutputServiceEndpoint; @Autowired private CamelContext camelContext; @Test public void testSomething() { .... } @Configuration public static class TestConfig extends SingleRouteCamelConfiguration { @Override protected void setupCamelContext(CamelContext camelContext) throws Exception { super.setupCamelContext(camelContext); PropertiesComponent prop = camelContext.getComponent("properties", PropertiesComponent.class); prop.setLocation("myRouteBuilder.test.properties"); } @Override public RouteBuilder route() { return new MyRouteBuilder(); } } {code} The issue we're having is that the @MockEndpointsAndSkip annotation on the test class does not resolve property placeholders, therefore we have to write the resolved value instead of the property placeholder value (which is a public static variable in the RouteBuilder implementation) I.e. we want to use MyRouteBuilder.EXIT_ENDPOINT instead of "direct:myRouteBuilder.exit". It would be nicer to avoid having duplicate extra hard-coded Strings if possible, so that if the endpoint uri value is updated in the property file then all the tests don't also have to be updated. was: We are using property placeholders in our route configuration in order to switch components in our unit tests. For example: {code} from(MyRouteBuilder.ENTRY_ENDPOINT) .routeId("some.route") .process(doSomething()) .to(MyRouteBuilder.EXIT_ENDPOINT); {code} Where ENTRY_ENDPOINT = "{{entry.endpoint.uri}}" and EXIT_ENDPOINT = "{exit.endpoint.uri}}" Then, in production, the Camel context is initialized with a properties file where the URIs use the "jms" component, while in our unit tests we initialise the context with a 'test' properties file where the URIs use the "direct" component. A typical RouteBuilder unit test looks something like this: {code} @RunWith(CamelSpringJUnit4ClassRunner.class) @ContextConfiguration( classes = { MyRouteBuilderTest.TestConfig.class }, loader = CamelSpringDelegatingTestContextLoader.class ) @MockEndpointsAndSkip(value = "direct:myRouteBuilder.exit") public class MyRouteBuilderTest { @Produce(uri = MyRouteBuilder.ENTRY_ENDPOINT) private ProducerTemplate myRouteBuilderProducer; @EndpointInject(uri = "mock:" + MyRouteBuilder.EXIT_ENDPOINT) private MockEndpoint mockOutputServiceEndpoint; @Autowired private CamelContext camelContext; @Test public void testSomething() { .... } @Configuration public static class TestConfig extends SingleRouteCamelConfiguration { @Override protected void setupCamelContext(CamelContext camelContext) throws Exception { super.setupCamelContext(camelContext); PropertiesComponent prop = camelContext.getComponent("properties", PropertiesComponent.class); prop.setLocation("myRouteBuilder.test.properties"); } @Override public RouteBuilder route() { return new MyRouteBuilder(); } } {code} The issue we're having is that the @MockEndpointsAndSkip annotation on the test class does not resolve property placeholders, therefore we have to write the resolved value instead of the property placeholder value (which is a public static variable in the RouteBuilder implementation) I.e. we want to use MyRouteBuilder.EXIT_ENDPOINT instead of "direct:myRouteBuilder.exit". It would be nicer to avoid having duplicate extra hard-coded Strings if possible, so that if the endpoint uri value is updated in the property file then all the tests don't also have to be updated. > MockEndpointsAndSkip annotation does not resolve property placeholders > ---------------------------------------------------------------------- > > Key: CAMEL-8064 > URL: https://issues.apache.org/jira/browse/CAMEL-8064 > Project: Camel > Issue Type: Improvement > Affects Versions: 2.13.2 > Reporter: Gareth Western > Priority: Minor > > We are using property placeholders in our route configuration in order to switch components in our unit tests. For example: > {code} > from(MyRouteBuilder.ENTRY_ENDPOINT) > .routeId("some.route") > .process(doSomething()) > .to(MyRouteBuilder.EXIT_ENDPOINT); > {code} > Where ENTRY_ENDPOINT = "{{entry.endpoint.uri}}" > and EXIT_ENDPOINT = "{{exit.endpoint.uri}}" > Then, in production, the Camel context is initialized with a properties file where the URIs use the "jms" component, while in our unit tests we initialise the context with a 'test' properties file where the URIs use the "direct" component. For example: > {code} > # test.properties > entry.endpoint.uri = direct:myRouteBuilder.entry > exit.endpoint.uri = direct:myRouteBuilder.exit > {code} > A typical RouteBuilder unit test looks something like this: > {code} > @RunWith(CamelSpringJUnit4ClassRunner.class) > @ContextConfiguration( > classes = { MyRouteBuilderTest.TestConfig.class }, > loader = CamelSpringDelegatingTestContextLoader.class > ) > @MockEndpointsAndSkip(value = "direct:myRouteBuilder.exit") > public class MyRouteBuilderTest { > @Produce(uri = MyRouteBuilder.ENTRY_ENDPOINT) > private ProducerTemplate myRouteBuilderProducer; > @EndpointInject(uri = "mock:" + MyRouteBuilder.EXIT_ENDPOINT) > private MockEndpoint mockOutputServiceEndpoint; > @Autowired > private CamelContext camelContext; > @Test > public void testSomething() { > .... > } > @Configuration > public static class TestConfig extends SingleRouteCamelConfiguration { > @Override > protected void setupCamelContext(CamelContext camelContext) throws Exception { > super.setupCamelContext(camelContext); > PropertiesComponent prop = camelContext.getComponent("properties", PropertiesComponent.class); > prop.setLocation("myRouteBuilder.test.properties"); > } > @Override > public RouteBuilder route() { > return new MyRouteBuilder(); > } > } > {code} > The issue we're having is that the @MockEndpointsAndSkip annotation on the test class does not resolve property placeholders, therefore we have to write the resolved value instead of the property placeholder value (which is a public static variable in the RouteBuilder implementation) I.e. we want to use MyRouteBuilder.EXIT_ENDPOINT instead of "direct:myRouteBuilder.exit". > It would be nicer to avoid having duplicate extra hard-coded Strings if possible, so that if the endpoint uri value is updated in the property file then all the tests don't also have to be updated. -- This message was sent by Atlassian JIRA (v6.3.4#6332)