Repository: camel Updated Branches: refs/heads/master dea7ef0e0 -> f647d33ab
Changed disableDataSetIndex URI parameter name to dataSetIndex and type to String with valid values of strict,lenient and off Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f647d33a Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f647d33a Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f647d33a Branch: refs/heads/master Commit: f647d33ab93d404f3b9e23242071ca1d29e48b84 Parents: 4631a04 Author: Quinn Stevenson <qu...@pronoia-solutions.com> Authored: Mon Mar 14 10:51:04 2016 -0600 Committer: Claus Ibsen <davscl...@apache.org> Committed: Mon Mar 14 19:23:15 2016 +0100 ---------------------------------------------------------------------- .../component/dataset/DataSetEndpoint.java | 52 +++-- .../component/dataset/DataSetConsumerTest.java | 40 +++- .../component/dataset/DataSetProducerTest.java | 190 +++++++++++++++---- 3 files changed, 220 insertions(+), 62 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/f647d33a/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetEndpoint.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetEndpoint.java index 70f24c5..b6c7900 100644 --- a/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetEndpoint.java +++ b/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetEndpoint.java @@ -60,8 +60,8 @@ public class DataSetEndpoint extends MockEndpoint implements Service { private long preloadSize; @UriParam(label = "consumer", defaultValue = "1000") private long initialDelay = 1000; - @UriParam(label = "consumer,producer", defaultValue = "null") - private Boolean disableDataSetIndex; + @UriParam(enums = "strict,lenient,off", defaultValue = "lenient") + private String dataSetIndex = "lenient"; @Deprecated public DataSetEndpoint() { @@ -120,9 +120,10 @@ public class DataSetEndpoint extends MockEndpoint implements Service { */ public Exchange createExchange(long messageIndex) throws Exception { Exchange exchange = createExchange(); + getDataSet().populateMessage(exchange, messageIndex); - if (disableDataSetIndex == null || !disableDataSetIndex) { + if (!getDataSetIndex().equals("off")) { Message in = exchange.getIn(); in.setHeader(Exchange.DATASET_INDEX, messageIndex); } @@ -211,21 +212,30 @@ public class DataSetEndpoint extends MockEndpoint implements Service { } /** - * Flag to disable setting the CamelDataSetIndex header. + * Controls the behaviour of the CamelDataSetIndex header. * For Consumers: - * - true => the header will not be set - * - false/null/unset => the header will be set + * - off => the header will not be set + * - strict/lenient => the header will be set * For Producers: - * - true => the header value will not be verified, and will not be set if it is not present - * = false => the header value must be present and will be verified - * = null/unset => the header value will be verified if it is present, and will be set if it is not present + * - off => the header value will not be verified, and will not be set if it is not present + * = strict => the header value must be present and will be verified + * = lenient => the header value will be verified if it is present, and will be set if it is not present */ - public void setDisableDataSetIndex(boolean disableDataSetIndex) { - this.disableDataSetIndex = disableDataSetIndex; + public void setDataSetIndex(String dataSetIndex) { + switch (dataSetIndex) { + case "off": + case "lenient": + case "strict": + this.dataSetIndex = dataSetIndex; + break; + default: + throw new IllegalArgumentException("Invalid value specified for the dataSetIndex URI parameter:" + dataSetIndex + + "Supported values are strict, lenient and off "); + } } - public boolean getDisableDataSetIndex() { - return disableDataSetIndex; + public String getDataSetIndex() { + return dataSetIndex; } // Implementation methods @@ -256,16 +266,24 @@ public class DataSetEndpoint extends MockEndpoint implements Service { } protected void assertMessageExpected(long index, Exchange expected, Exchange actual) throws Exception { - if (disableDataSetIndex == null) { + switch (getDataSetIndex()) { + case "off": + break; + case "strict": + long actualCounter = ExchangeHelper.getMandatoryHeader(actual, Exchange.DATASET_INDEX, Long.class); + assertEquals("Header: " + Exchange.DATASET_INDEX, index, actualCounter, actual); + break; + case "lenient": + default: + // Validate the header value if it is present Long dataSetIndexHeaderValue = actual.getIn().getHeader(Exchange.DATASET_INDEX, Long.class); if (dataSetIndexHeaderValue != null) { assertEquals("Header: " + Exchange.DATASET_INDEX, index, dataSetIndexHeaderValue, actual); } else { + // set the header if it isn't there actual.getIn().setHeader(Exchange.DATASET_INDEX, index); } - } else if (!disableDataSetIndex) { - long actualCounter = ExchangeHelper.getMandatoryHeader(actual, Exchange.DATASET_INDEX, Long.class); - assertEquals("Header: " + Exchange.DATASET_INDEX, index, actualCounter, actual); + break; } getDataSet().assertMessageExpected(this, expected, actual, index); http://git-wip-us.apache.org/repos/asf/camel/blob/f647d33a/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetConsumerTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetConsumerTest.java b/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetConsumerTest.java index 1e9c65b..c98acc8 100644 --- a/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetConsumerTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetConsumerTest.java @@ -32,8 +32,9 @@ public class DataSetConsumerTest extends ContextTestSupport { final String dataSetName = "foo"; final String dataSetUri = "dataset://" + dataSetName; - final String dataSetUriWithDisableDataSetIndexSetToFalse = dataSetUri + "?disableDataSetIndex=false"; - final String dataSetUriWithDisableDataSetIndexSetToTrue = dataSetUri + "?disableDataSetIndex=true"; + final String dataSetUriWithDataSetIndexSetToOff = dataSetUri + "?dataSetIndex=off"; + final String dataSetUriWithDataSetIndexSetToLenient = dataSetUri + "?dataSetIndex=lenient"; + final String dataSetUriWithDataSetIndexSetToStrict = dataSetUri + "?dataSetIndex=strict"; final String resultUri = "mock://result"; @Override @@ -91,9 +92,8 @@ public class DataSetConsumerTest extends ContextTestSupport { assertMockEndpointsSatisfied(); } - // TODO: Add tests for dataSetIndex URI parameters @Test - public void testWithDisableDataSetIndexUriParameterUnset() throws Exception { + public void testWithDataSetIndexUriParameterUnset() throws Exception { context.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { @@ -112,11 +112,29 @@ public class DataSetConsumerTest extends ContextTestSupport { } @Test - public void testWithDisableDataSetIndexUriParameterSetToFalse() throws Exception { + public void testWithDataSetIndexUriParameterSetToOff() throws Exception { context.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { - from(dataSetUriWithDisableDataSetIndexSetToFalse) + from(dataSetUriWithDataSetIndexSetToOff) + .to(resultUri); + } + }); + context.start(); + + MockEndpoint result = getMockEndpoint(resultUri); + result.expectedMessageCount((int) dataSet.getSize()); + result.allMessages().header(Exchange.DATASET_INDEX).isNull(); + + assertMockEndpointsSatisfied(); + } + + @Test + public void testWithDataSetIndexUriParameterSetToLenient() throws Exception { + context.addRoutes(new RouteBuilder() { + @Override + public void configure() throws Exception { + from(dataSetUriWithDataSetIndexSetToLenient) .to(resultUri); } }); @@ -131,11 +149,11 @@ public class DataSetConsumerTest extends ContextTestSupport { } @Test - public void testWithDisableDataSetIndexUriParameterSetToTrue() throws Exception { + public void testWithDataSetIndexUriParameterSetToStrict() throws Exception { context.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { - from(dataSetUriWithDisableDataSetIndexSetToTrue) + from(dataSetUriWithDataSetIndexSetToStrict) .to(resultUri); } }); @@ -143,8 +161,12 @@ public class DataSetConsumerTest extends ContextTestSupport { MockEndpoint result = getMockEndpoint(resultUri); result.expectedMessageCount((int) dataSet.getSize()); - result.allMessages().header(Exchange.DATASET_INDEX).isNull(); + result.allMessages().header(Exchange.DATASET_INDEX).isNotNull(); + result.expectsAscending(header(Exchange.DATASET_INDEX).convertTo(Number.class)); + Thread.sleep(100); assertMockEndpointsSatisfied(); + + System.out.println("Place for Breakpoint"); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/f647d33a/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetProducerTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetProducerTest.java b/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetProducerTest.java index f3d930c..210f7f5 100644 --- a/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetProducerTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetProducerTest.java @@ -33,8 +33,9 @@ public class DataSetProducerTest extends ContextTestSupport { final String dataSetName = "foo"; final String dataSetUri = "dataset://" + dataSetName; - final String dataSetUriWithDisableDataSetIndexSetToFalse = dataSetUri + "?disableDataSetIndex=false"; - final String dataSetUriWithDisableDataSetIndexSetToTrue = dataSetUri + "?disableDataSetIndex=true"; + final String dataSetUriWithDataSetIndexSetToOff = dataSetUri + "?dataSetIndex=off"; + final String dataSetUriWithDataSetIndexSetToLenient = dataSetUri + "?dataSetIndex=lenient"; + final String dataSetUriWithDataSetIndexSetToStrict = dataSetUri + "?dataSetIndex=strict"; final String sourceUri = "direct://source"; final String resultUri = "mock://result"; @@ -46,7 +47,7 @@ public class DataSetProducerTest extends ContextTestSupport { } @Test - public void testSendingMessagesExplicitlyToDataSetEndpoint() throws Exception { + public void testSendingMessagesExplicitlyToDataSetEndpointWithDataSetIndexHeader() throws Exception { long size = dataSet.getSize(); for (long i = 0; i < size; i++) { template.sendBodyAndHeader(dataSetUri, dataSet.getDefaultBody(), Exchange.DATASET_INDEX, i); @@ -56,7 +57,7 @@ public class DataSetProducerTest extends ContextTestSupport { } @Test - public void testSendingMessagesExplicitlyToDataSetEndpointWithoutDataSetIndex() throws Exception { + public void testSendingMessagesExplicitlyToDataSetEndpointWithoutDataSetIndexHeader() throws Exception { long size = dataSet.getSize(); for (long i = 0; i < size; i++) { template.sendBody(dataSetUri, dataSet.getDefaultBody()); @@ -65,11 +66,49 @@ public class DataSetProducerTest extends ContextTestSupport { assertMockEndpointsSatisfied(); } + @Test + public void testSendingMessagesExplicitlyToDataSetEndpointWithoutDataSetIndexAndDataSetIndexUriParameterSetToOff() throws Exception { + long size = dataSet.getSize(); + for (long i = 0; i < size; i++) { + if (0 == i % 2) { + template.sendBodyAndHeader(dataSetUriWithDataSetIndexSetToLenient, dataSet.getDefaultBody(), Exchange.DATASET_INDEX, i); + } else { + template.sendBody(dataSetUriWithDataSetIndexSetToLenient, dataSet.getDefaultBody()); + } + } + + assertMockEndpointsSatisfied(); + } + + @Test + public void testSendingMessagesExplicitlyToDataSetEndpointWithoutDataSetIndexAndDataSetIndexUriParameterSetToLenient() throws Exception { + long size = dataSet.getSize(); + for (long i = 0; i < size; i++) { + if (0 == i % 2) { + template.sendBodyAndHeader(dataSetUriWithDataSetIndexSetToLenient, dataSet.getDefaultBody(), Exchange.DATASET_INDEX, i); + } else { + template.sendBody(dataSetUriWithDataSetIndexSetToLenient, dataSet.getDefaultBody()); + } + } + + assertMockEndpointsSatisfied(); + } + + @Test + public void testSendingMessagesExplicitlyToDataSetEndpointWithoutDataSetIndexAndDataSetIndexUriParameterSetToStrict() throws Exception { + long size = dataSet.getSize(); + for (long i = 0; i < size; i++) { + template.sendBodyAndHeader(dataSetUriWithDataSetIndexSetToStrict, dataSet.getDefaultBody(), Exchange.DATASET_INDEX, i); + } + + assertMockEndpointsSatisfied(); + } + /** - * Verfiy that the CamelDataSetIndex header is optional when the disableDataSetIndex parameter is unset + * Verify that the CamelDataSetIndex header is optional when the dataSetIndex parameter is unset */ @Test - public void testNotSettingDataSetIndexHeaderWhenDisableDataSetIndexUriParameterIsUnset() throws Exception { + public void testNotSettingDataSetIndexHeaderWhenDataSetIndexUriParameterIsUnset() throws Exception { long size = dataSet.getSize(); for (long i = 0; i < size; i++) { if (0 == (size % 2)) { @@ -83,39 +122,54 @@ public class DataSetProducerTest extends ContextTestSupport { } /** - * Verfiy tha the CamelDataSetIndex header is optional when the disableDataSetIndex parameter is true + * Verify that the CamelDataSetIndex header is ignored when the dataSetIndex URI paramter is set to off */ @Test - public void testNotSettingDataSetIndexHeaderWhenDisableDataSetIndexUriParameterSetToTrue() throws Exception { + public void testNotSettingDataSetIndexHeaderWhenDataSetIndexUriParameterSetToOff() throws Exception { long size = dataSet.getSize(); for (long i = 0; i < size; i++) { if (0 == (size % 2)) { - template.sendBodyAndHeader(dataSetUriWithDisableDataSetIndexSetToTrue, dataSet.getDefaultBody(), Exchange.DATASET_INDEX, i); + template.sendBodyAndHeader(dataSetUriWithDataSetIndexSetToOff, dataSet.getDefaultBody(), Exchange.DATASET_INDEX, size - i); } else { - template.sendBody(dataSetUriWithDisableDataSetIndexSetToTrue, dataSet.getDefaultBody()); + template.sendBody(dataSetUriWithDataSetIndexSetToOff, dataSet.getDefaultBody()); } } + + assertMockEndpointsSatisfied(); + } + + /** + * Verify that the CamelDataSetIndex header is optional when the dataSetIndex URI parameter is set to lenient + */ + @Test + public void testNotSettingDataSetIndexHeaderWhenDataSetIndexUriParameterSetToLenient() throws Exception { + long size = dataSet.getSize(); for (long i = 0; i < size; i++) { + if (0 == (size % 2)) { + template.sendBodyAndHeader(dataSetUriWithDataSetIndexSetToLenient, dataSet.getDefaultBody(), Exchange.DATASET_INDEX, i); + } else { + template.sendBody(dataSetUriWithDataSetIndexSetToLenient, dataSet.getDefaultBody()); + } } assertMockEndpointsSatisfied(); } /** - * Verify tha the CamelDataSetIndex header is required when the disableDataSetIndex parameter is false + * Verify that the CamelDataSetIndex header is required when the dataSetIndex URI parameter is set to strict */ @Test - public void testNotSettingDataSetIndexHeaderWhenDisableDataSetIndexUriParameterSetToFalse() throws Exception { + public void testNotSettingDataSetIndexHeaderWhenDataSetIndexUriParameterSetToStrict() throws Exception { long size = dataSet.getSize(); for (long i = 0; i < size; i++) { - template.sendBody(dataSetUriWithDisableDataSetIndexSetToFalse, dataSet.getDefaultBody()); + template.sendBody(dataSetUriWithDataSetIndexSetToStrict, dataSet.getDefaultBody()); } try { - getMockEndpoint(dataSetUriWithDisableDataSetIndexSetToFalse).assertIsSatisfied(); + assertMockEndpointsSatisfied(); } catch (AssertionError assertionError) { // Check as much of the string as possible - but the ExchangeID at the end will be unique - String expectedErrorString = dataSetUriWithDisableDataSetIndexSetToFalse + String expectedErrorString = dataSetUriWithDataSetIndexSetToStrict + " Failed due to caught exception: " + NoSuchHeaderException.class.getName() + ": No '" + Exchange.DATASET_INDEX @@ -133,22 +187,40 @@ public class DataSetProducerTest extends ContextTestSupport { } @Test - public void testSendingMessagesExplicitlyToDataSetEndpointWithoutDataSetIndexAndDisableDataSetIndexUriParameterSetToTrue() throws Exception { + public void testDataSetIndexUriParameterUnset() throws Exception { + context.addRoutes(new RouteBuilder() { + @Override + public void configure() throws Exception { + from(sourceUri) + .to(dataSetUri) + .to(resultUri); + } + }); + context.start(); + long size = dataSet.getSize(); + + MockEndpoint result = getMockEndpoint(resultUri); + result.expectedMessageCount((int) size); + result.allMessages().header(Exchange.DATASET_INDEX).isNotNull(); + result.expectsAscending(header(Exchange.DATASET_INDEX).convertTo(Number.class)); + for (long i = 0; i < size; i++) { - template.sendBody(dataSetUriWithDisableDataSetIndexSetToTrue, dataSet.getDefaultBody()); + template.sendBody(sourceUri, dataSet.getDefaultBody()); } assertMockEndpointsSatisfied(); + + result.assertMessagesAscending(header(Exchange.DATASET_INDEX).convertTo(Number.class)); } @Test - public void testDisableDataSetIndexUriParameterUnset() throws Exception { + public void testDataSetIndexUriParameterSetToOff() throws Exception { context.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from(sourceUri) - .to(dataSetUri) + .to(dataSetUriWithDataSetIndexSetToOff) .to(resultUri); } }); @@ -158,25 +230,24 @@ public class DataSetProducerTest extends ContextTestSupport { MockEndpoint result = getMockEndpoint(resultUri); result.expectedMessageCount((int) size); - result.allMessages().header(Exchange.DATASET_INDEX).isNotNull(); result.expectsAscending(header(Exchange.DATASET_INDEX).convertTo(Number.class)); + result.allMessages().header(Exchange.DATASET_INDEX).isNotNull(); for (long i = 0; i < size; i++) { - template.sendBody(sourceUri, dataSet.getDefaultBody()); + template.sendBodyAndHeader(sourceUri, dataSet.getDefaultBody(), Exchange.DATASET_INDEX, i); } assertMockEndpointsSatisfied(); - - result.assertMessagesAscending(header(Exchange.DATASET_INDEX).convertTo(Number.class)); } + @Test - public void testDisableDataSetIndexUriParameterSetToTrue() throws Exception { + public void testDataSetIndexUriParameterSetToLenient() throws Exception { context.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from(sourceUri) - .to(dataSetUriWithDisableDataSetIndexSetToTrue) + .to(dataSetUriWithDataSetIndexSetToLenient) .to(resultUri); } }); @@ -186,22 +257,24 @@ public class DataSetProducerTest extends ContextTestSupport { MockEndpoint result = getMockEndpoint(resultUri); result.expectedMessageCount((int) size); - result.allMessages().header(Exchange.DATASET_INDEX).isNull(); + result.expectsAscending(header(Exchange.DATASET_INDEX).convertTo(Number.class)); + result.allMessages().header(Exchange.DATASET_INDEX).isNotNull(); for (long i = 0; i < size; i++) { - template.sendBody(sourceUri, dataSet.getDefaultBody()); + template.sendBodyAndHeader(sourceUri, dataSet.getDefaultBody(), Exchange.DATASET_INDEX, i); } assertMockEndpointsSatisfied(); } + @Test - public void testDisableDataSetIndexUriParameterSetToFalse() throws Exception { + public void testDataSetIndexUriParameterSetToStrict() throws Exception { context.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from(sourceUri) - .to(dataSetUriWithDisableDataSetIndexSetToFalse) + .to(dataSetUriWithDataSetIndexSetToStrict) .to(resultUri); } }); @@ -221,9 +294,8 @@ public class DataSetProducerTest extends ContextTestSupport { assertMockEndpointsSatisfied(); } - @Test - public void testInvalidDataSetIndexValueWithDisableDataSetIndexUriParameterUnset() throws Exception { + public void testInvalidDataSetIndexValueWithDataSetIndexUriParameterUnset() throws Exception { context.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { @@ -269,12 +341,12 @@ public class DataSetProducerTest extends ContextTestSupport { } @Test - public void testInvalidDataSetIndexValueWithDisableDataSetIndexUriParameterSetToTrue() throws Exception { + public void testInvalidDataSetIndexValueWithDataSetIndexUriParameterSetToOff() throws Exception { context.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from(sourceUri) - .to(dataSetUriWithDisableDataSetIndexSetToTrue) + .to(dataSetUriWithDataSetIndexSetToOff) .to(resultUri); } }); @@ -297,12 +369,58 @@ public class DataSetProducerTest extends ContextTestSupport { } @Test - public void testInvalidDataSetIndexValueWithDisableDataSetIndexUriParameterSetToFalse() throws Exception { + public void testInvalidDataSetIndexValueWithDataSetIndexUriParameterSetToLenient() throws Exception { + context.addRoutes(new RouteBuilder() { + @Override + public void configure() throws Exception { + from(sourceUri) + .to(dataSetUriWithDataSetIndexSetToLenient) + .to(resultUri); + } + }); + context.start(); + + long size = dataSet.getSize(); + + MockEndpoint result = getMockEndpoint(resultUri); + result.expectedMessageCount((int) size); + result.allMessages().header(Exchange.DATASET_INDEX).isNotNull(); + + for (long i = 0; i < size; i++) { + if (i == (size / 2)) { + template.sendBodyAndHeader(sourceUri, dataSet.getDefaultBody(), Exchange.DATASET_INDEX, i + 10); + } else { + template.sendBody(sourceUri, dataSet.getDefaultBody()); + } + } + + try { + assertMockEndpointsSatisfied(); + } catch (AssertionError assertionError) { + // Check as much of the string as possible - but the ExchangeID at the end will be unique + String expectedErrorString = dataSetUriWithDataSetIndexSetToLenient + " Failed due to caught exception: " + + AssertionError.class.getName() + + ": Header: " + Exchange.DATASET_INDEX + " does not match. Expected: " + + size / 2 + " but was: " + (size / 2 + 10) + " on Exchange"; + String actualErrorString = assertionError.getMessage(); + if (actualErrorString.startsWith(expectedErrorString)) { + // This is what we expect + return; + } else { + throw assertionError; + } + } + + fail("AssertionError should have been generated"); + } + + @Test + public void testInvalidDataSetIndexValueWithDataSetIndexUriParameterSetToStrict() throws Exception { context.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from(sourceUri) - .to(dataSetUriWithDisableDataSetIndexSetToFalse) + .to(dataSetUriWithDataSetIndexSetToStrict) .to(resultUri); } }); @@ -326,7 +444,7 @@ public class DataSetProducerTest extends ContextTestSupport { assertMockEndpointsSatisfied(); } catch (AssertionError assertionError) { // Check as much of the string as possible - but the ExchangeID at the end will be unique - String expectedErrorString = dataSetUriWithDisableDataSetIndexSetToFalse + " Failed due to caught exception: " + String expectedErrorString = dataSetUriWithDataSetIndexSetToStrict + " Failed due to caught exception: " + AssertionError.class.getName() + ": Header: " + Exchange.DATASET_INDEX + " does not match. Expected: " + size / 2 + " but was: " + (size / 2 + 10) + " on Exchange"; String actualErrorString = assertionError.getMessage();