Author: ningjiang Date: Thu Jul 12 13:47:52 2012 New Revision: 1360679 URL: http://svn.apache.org/viewvc?rev=1360679&view=rev Log: Merged revisions 1360659 via svnmerge from https://svn.apache.org/repos/asf/camel/branches/camel-2.10.x
................ r1360659 | ningjiang | 2012-07-12 20:40:18 +0800 (Thu, 12 Jul 2012) | 9 lines Merged revisions 1360581 via svnmerge from https://svn.apache.org/repos/asf/camel/trunk ........ r1360581 | ningjiang | 2012-07-12 16:49:14 +0800 (Thu, 12 Jul 2012) | 1 line CAMEL-5440 Fixed the issue of mock endpoint expectedHeaderReceived ........ ................ Modified: camel/branches/camel-2.9.x/ (props changed) camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java Propchange: camel/branches/camel-2.9.x/ ------------------------------------------------------------------------------ Merged /camel/trunk:r1360581 Merged /camel/branches/camel-2.10.x:r1360659 Propchange: camel/branches/camel-2.9.x/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java?rev=1360679&r1=1360678&r2=1360679&view=diff ============================================================================== --- camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java (original) +++ camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java Thu Jul 12 13:47:52 2012 @@ -470,32 +470,32 @@ public class MockEndpoint extends Defaul public void expectedHeaderReceived(final String name, final Object value) { if (expectedHeaderValues == null) { expectedHeaderValues = new CaseInsensitiveMap(); - } - expectedHeaderValues.put(name, value); + // we just wants to expects to be called once + expects(new Runnable() { + public void run() { + for (int i = 0; i < getReceivedExchanges().size(); i++) { + Exchange exchange = getReceivedExchanges().get(i); + for (Map.Entry<String, Object> entry : expectedHeaderValues.entrySet()) { + String key = entry.getKey(); + Object expectedValue = entry.getValue(); + + // we accept that an expectedValue of null also means that the header may be absent + if (expectedValue != null) { + assertTrue("Exchange " + i + " has no headers", exchange.getIn().hasHeaders()); + boolean hasKey = exchange.getIn().getHeaders().containsKey(key); + assertTrue("No header with name " + key + " found for message: " + i, hasKey); + } - expects(new Runnable() { - public void run() { - for (int i = 0; i < getReceivedExchanges().size(); i++) { - Exchange exchange = getReceivedExchanges().get(i); - for (Map.Entry<String, Object> entry : expectedHeaderValues.entrySet()) { - String key = entry.getKey(); - Object expectedValue = entry.getValue(); + Object actualValue = exchange.getIn().getHeader(key); + actualValue = extractActualValue(exchange, actualValue, expectedValue); - // we accept that an expectedValue of null also means that the header may be absent - if (expectedValue != null) { - assertTrue("Exchange " + i + " has no headers", exchange.getIn().hasHeaders()); - boolean hasKey = exchange.getIn().getHeaders().containsKey(key); - assertTrue("No header with name " + key + " found for message: " + i, hasKey); + assertEquals("Header with name " + key + " for message: " + i, expectedValue, actualValue); } - - Object actualValue = exchange.getIn().getHeader(key); - actualValue = extractActualValue(exchange, actualValue, expectedValue); - - assertEquals("Header with name " + key + " for message: " + i, expectedValue, actualValue); } } - } - }); + }); + } + expectedHeaderValues.put(name, value); } /**