From a0d8ec1f935cf41ebd8d7bbe10cf492f0018f59a Mon Sep 17 00:00:00 2001 From: Christoph Deppisch Date: Mon, 9 Aug 2021 15:45:28 +0200 Subject: [PATCH] fix: Fix bean names for legacy projects Legacy Citrus projects may not receive correct bean names according to XML configuration with id attributes set on bean elements. This is because com.consol.citrus.config.ComponentLifecycleProcessor is not set properly. Users must add ComponentLifecycleProcessor manually or benefit from this fix. --- .../com/consol/citrus/config/xml/AbstractEndpointParser.java | 2 ++ .../com/consol/citrus/http/config/xml/HttpClientParserTest.java | 1 + 2 files changed, 3 insertions(+) diff --git a/core/citrus-spring/src/main/java/com/consol/citrus/config/xml/AbstractEndpointParser.java b/core/citrus-spring/src/main/java/com/consol/citrus/config/xml/AbstractEndpointParser.java index 1cdc5bc2dc..28a3363805 100644 --- a/core/citrus-spring/src/main/java/com/consol/citrus/config/xml/AbstractEndpointParser.java +++ b/core/citrus-spring/src/main/java/com/consol/citrus/config/xml/AbstractEndpointParser.java @@ -43,6 +43,8 @@ protected AbstractBeanDefinition parseInternal(Element element, ParserContext pa BeanDefinitionBuilder configurationBuilder = BeanDefinitionBuilder.genericBeanDefinition(getEndpointConfigurationClass()); parseEndpointConfiguration(configurationBuilder, element, parserContext); + endpointBuilder.addPropertyValue("name", element.getAttribute(ID_ATTRIBUTE)); + String endpointConfigurationId = element.getAttribute(ID_ATTRIBUTE) + "Configuration"; BeanDefinitionParserUtils.registerBean(endpointConfigurationId, configurationBuilder.getBeanDefinition(), parserContext, shouldFireEvents()); diff --git a/endpoints/citrus-http/src/test/java/com/consol/citrus/http/config/xml/HttpClientParserTest.java b/endpoints/citrus-http/src/test/java/com/consol/citrus/http/config/xml/HttpClientParserTest.java index 8efda2c14e..aca14197f1 100644 --- a/endpoints/citrus-http/src/test/java/com/consol/citrus/http/config/xml/HttpClientParserTest.java +++ b/endpoints/citrus-http/src/test/java/com/consol/citrus/http/config/xml/HttpClientParserTest.java @@ -46,6 +46,7 @@ public void testHttpClientParser() { // 1st message sender HttpClient httpClient = clients.get("httpClient1"); + Assert.assertEquals(httpClient.getName(), "httpClient1"); Assert.assertNotNull(httpClient.getEndpointConfiguration().getRestTemplate()); Assert.assertEquals(httpClient.getEndpointConfiguration().getRequestUrl(), "http://localhost:8080/test"); Assert.assertEquals(httpClient.getEndpointConfiguration().getRestTemplate().getRequestFactory().getClass(), InterceptingClientHttpRequestFactory.class);