Skip to content

Commit

Permalink
INT-2497
Browse files Browse the repository at this point in the history
changed warning message to error in AbstractCorrelatingMessageHandlerParser when both beanRef and expression are present, re-enabled commented out test to verify the error
  • Loading branch information
olegz authored and garyrussell committed May 8, 2012
1 parent 582817d commit e1274f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand All @@ -12,17 +12,15 @@
*/
package org.springframework.integration.config.xml;

import org.w3c.dom.Element;

import org.springframework.beans.BeanMetadataElement;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.aggregator.AbstractCorrelatingMessageHandler;
import org.springframework.util.StringUtils;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Element;

/**
* Base class for parsers that create an instance of {@link AbstractCorrelatingMessageHandler}
*
Expand All @@ -32,8 +30,6 @@
*/
public abstract class AbstractCorrelatingMessageHandlerParser extends AbstractConsumerEndpointParser {

private final Log logger = LogFactory.getLog(this.getClass());

private static final String CORRELATION_STRATEGY_REF_ATTRIBUTE = "correlation-strategy";

private static final String CORRELATION_STRATEGY_METHOD_ATTRIBUTE = "correlation-strategy-method";
Expand Down Expand Up @@ -72,11 +68,8 @@ protected void injectPropertyWithAdapter(String beanRefAttribute, String methodR
final boolean hasExpression = StringUtils.hasText(expression);

if (hasBeanRef && hasExpression) {
this.logger.warn("Exactly one of the '" + beanRefAttribute + "' or '" + expressionAttribute +
"' attribute is allowed. The '" + expressionAttribute +
"' is ignored when both are provided." +
"NOTE: This is a warning message only, to avoid a breaking change in a point release and should " +
"be treated as an error. In a future release this condition will result in the actual exception");
parserContext.getReaderContext().error("Exactly one of the '" + beanRefAttribute + "' or '" + expressionAttribute +
"' attribute is allowed.", element);
}

BeanMetadataElement adapter = null;
Expand Down
Expand Up @@ -27,6 +27,7 @@

import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.Message;
Expand Down Expand Up @@ -236,11 +237,10 @@ public void testAggregationWithExpressionsAndPojoAggregator() {
assertTrue(ExpressionEvaluatingCorrelationStrategy.class.equals(correlationStrategy.getClass()));
}

// should be re-enabled for INT-2497
// @Test(expected=BeanDefinitionParsingException.class)
// public void testAggregatorFailureIfMutuallyExclusivityPresent() {
// this.context = new ClassPathXmlApplicationContext("aggregatorParserFailTests.xml", this.getClass());
// }
@Test(expected=BeanDefinitionParsingException.class)
public void testAggregatorFailureIfMutuallyExclusivityPresent() {
this.context = new ClassPathXmlApplicationContext("aggregatorParserFailTests.xml", this.getClass());
}

private static <T> Message<T> createMessage(T payload, Object correlationId, int sequenceSize, int sequenceNumber,
MessageChannel outputChannel) {
Expand Down

0 comments on commit e1274f3

Please sign in to comment.