Migrate tests to AssertJ
Mostly thanks to IDEA's plugin: https://plugins.jetbrains.com/plugin/10345-assertions2assertj There is still a lot of work to do when complex and composite matchers are used. * Add `awaitility` dependency and deprecate `EventuallyMatcher` in favor of `awaitility` * Remove Hamcrest from dependencies and disable JUnit & Hamcrest static imports to encourage to use only AssertJ * Migrate JUnit assumptions in rules to AssertJ's assumptions * Deprecate some custom matchers in favor of existing in Hamcrest after upgrading the last to version `2.1` * Replace `ExpectedException` rules with `assertThatThrownBy()` * Mention `MessagePredicate` in the `testing.adoc`
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -16,11 +16,8 @@
|
||||
|
||||
package org.springframework.integration.xml.config;
|
||||
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.util.Properties;
|
||||
@@ -56,8 +53,9 @@ public class ChainElementsTests {
|
||||
"The 'input-channel' attribute isn't allowed for a nested " +
|
||||
"(e.g. inside a <chain/>) endpoint element: 'int-xml:xpath-transformer'.";
|
||||
final String actualMessage = e.getMessage();
|
||||
assertTrue("Error message did not start with '" + expectedMessage +
|
||||
"' but instead returned: '" + actualMessage + "'", actualMessage.startsWith(expectedMessage));
|
||||
assertThat(actualMessage.startsWith(expectedMessage))
|
||||
.as("Error message did not start with '" + expectedMessage +
|
||||
"' but instead returned: '" + actualMessage + "'").isTrue();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -65,7 +63,7 @@ public class ChainElementsTests {
|
||||
@Test
|
||||
public void chainXPathTransformerId() throws Exception {
|
||||
try (ConfigurableApplicationContext ctx = bootStrap("xpath-transformer-id")) {
|
||||
assertNotNull(ctx.getBean(XPathTransformer.class));
|
||||
assertThat(ctx.getBean(XPathTransformer.class)).isNotNull();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,8 +78,9 @@ public class ChainElementsTests {
|
||||
"'int-xml:xpath-router' must not define an 'order' attribute " +
|
||||
"when used within a chain.";
|
||||
final String actualMessage = e.getMessage();
|
||||
assertTrue("Error message did not start with '" + expectedMessage +
|
||||
"' but instead returned: '" + actualMessage + "'", actualMessage.startsWith(expectedMessage));
|
||||
assertThat(actualMessage.startsWith(expectedMessage))
|
||||
.as("Error message did not start with '" + expectedMessage +
|
||||
"' but instead returned: '" + actualMessage + "'").isTrue();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -97,15 +96,15 @@ public class ChainElementsTests {
|
||||
"'int-xml:xpath-transformer' must not define a 'poller' " +
|
||||
"sub-element when used within a chain.";
|
||||
final String actualMessage = e.getMessage();
|
||||
assertThat("Error message did not start with '" + expectedMessage +
|
||||
"' but instead returned: '" + actualMessage + "'", actualMessage, startsWith(expectedMessage));
|
||||
assertThat(actualMessage).as("Error message did not start with '" + expectedMessage +
|
||||
"' but instead returned: '" + actualMessage + "'").startsWith(expectedMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void chainXPathTransformerSuccess() throws Exception {
|
||||
try (ConfigurableApplicationContext ctx = bootStrap("xpath-transformer-success")) {
|
||||
assertNotNull(ctx.getBean(XPathTransformer.class));
|
||||
assertThat(ctx.getBean(XPathTransformer.class)).isNotNull();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -16,9 +16,7 @@
|
||||
|
||||
package org.springframework.integration.xml.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -53,31 +51,31 @@ public class DefaultConfigurationTests {
|
||||
@Test
|
||||
public void verifyErrorChannel() {
|
||||
Object errorChannel = context.getBean("errorChannel");
|
||||
assertNotNull(errorChannel);
|
||||
assertEquals(PublishSubscribeChannel.class, errorChannel.getClass());
|
||||
assertThat(errorChannel).isNotNull();
|
||||
assertThat(errorChannel.getClass()).isEqualTo(PublishSubscribeChannel.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyNullChannel() {
|
||||
Object nullChannel = context.getBean("nullChannel");
|
||||
assertNotNull(nullChannel);
|
||||
assertEquals(NullChannel.class, nullChannel.getClass());
|
||||
assertThat(nullChannel).isNotNull();
|
||||
assertThat(nullChannel.getClass()).isEqualTo(NullChannel.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyTaskScheduler() {
|
||||
Object taskScheduler = context.getBean(IntegrationContextUtils.TASK_SCHEDULER_BEAN_NAME);
|
||||
assertEquals(ThreadPoolTaskScheduler.class, taskScheduler.getClass());
|
||||
assertThat(taskScheduler.getClass()).isEqualTo(ThreadPoolTaskScheduler.class);
|
||||
ErrorHandler errorHandler = TestUtils.getPropertyValue(taskScheduler, "errorHandler", ErrorHandler.class);
|
||||
assertEquals(MessagePublishingErrorHandler.class, errorHandler.getClass());
|
||||
assertThat(errorHandler.getClass()).isEqualTo(MessagePublishingErrorHandler.class);
|
||||
MessageChannel defaultErrorChannel = TestUtils.getPropertyValue(errorHandler,
|
||||
"messagingTemplate.defaultDestination", MessageChannel.class);
|
||||
assertNull(defaultErrorChannel);
|
||||
assertThat(defaultErrorChannel).isNull();
|
||||
errorHandler.handleError(new Throwable());
|
||||
defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "messagingTemplate.defaultDestination",
|
||||
MessageChannel.class);
|
||||
assertNotNull(defaultErrorChannel);
|
||||
assertEquals(context.getBean(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME), defaultErrorChannel);
|
||||
assertThat(defaultErrorChannel).isNotNull();
|
||||
assertThat(defaultErrorChannel).isEqualTo(context.getBean(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -16,17 +16,12 @@
|
||||
|
||||
package org.springframework.integration.xml.config;
|
||||
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.transform.dom.DOMResult;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.w3c.dom.Document;
|
||||
@@ -67,15 +62,15 @@ public class MarshallingTransformerParserTests {
|
||||
@Test
|
||||
public void testParse() throws Exception {
|
||||
EventDrivenConsumer consumer = (EventDrivenConsumer) appContext.getBean("parseOnly");
|
||||
assertEquals(2, TestUtils.getPropertyValue(consumer, "handler.order"));
|
||||
assertEquals(123L, TestUtils.getPropertyValue(consumer, "handler.messagingTemplate.sendTimeout"));
|
||||
assertEquals(-1, TestUtils.getPropertyValue(consumer, "phase"));
|
||||
assertFalse(TestUtils.getPropertyValue(consumer, "autoStartup", Boolean.class));
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "handler.order")).isEqualTo(2);
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "handler.messagingTemplate.sendTimeout")).isEqualTo(123L);
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "phase")).isEqualTo(-1);
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "autoStartup", Boolean.class)).isFalse();
|
||||
SmartLifecycleRoleController roleController = appContext.getBean(SmartLifecycleRoleController.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<SmartLifecycle> list = (List<SmartLifecycle>) TestUtils.getPropertyValue(roleController, "lifecycles",
|
||||
MultiValueMap.class).get("foo");
|
||||
assertThat(list, contains((SmartLifecycle) consumer));
|
||||
assertThat(list).containsExactly((SmartLifecycle) consumer);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -84,9 +79,9 @@ public class MarshallingTransformerParserTests {
|
||||
GenericMessage<Object> message = new GenericMessage<Object>("hello");
|
||||
input.send(message);
|
||||
Message<?> result = output.receive(0);
|
||||
assertTrue("Wrong payload type", result.getPayload() instanceof DOMResult);
|
||||
assertThat(result.getPayload() instanceof DOMResult).as("Wrong payload type").isTrue();
|
||||
Document doc = (Document) ((DOMResult) result.getPayload()).getNode();
|
||||
assertEquals("Wrong payload", "hello", doc.getDocumentElement().getTextContent());
|
||||
assertThat(doc.getDocumentElement().getTextContent()).as("Wrong payload").isEqualTo("hello");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -95,9 +90,9 @@ public class MarshallingTransformerParserTests {
|
||||
GenericMessage<Object> message = new GenericMessage<Object>("hello");
|
||||
input.send(message);
|
||||
Message<?> result = output.receive(0);
|
||||
assertTrue("Wrong payload type", result.getPayload() instanceof String);
|
||||
assertThat(result.getPayload() instanceof String).as("Wrong payload type").isTrue();
|
||||
String resultPayload = (String) result.getPayload();
|
||||
assertEquals("Wrong payload", "testReturn", resultPayload);
|
||||
assertThat(resultPayload).as("Wrong payload").isEqualTo("testReturn");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -106,9 +101,9 @@ public class MarshallingTransformerParserTests {
|
||||
GenericMessage<Object> message = new GenericMessage<Object>("hello");
|
||||
input.send(message);
|
||||
Message<?> result = output.receive(0);
|
||||
assertTrue("Wrong payload type ", result.getPayload() instanceof DOMResult);
|
||||
assertThat(result.getPayload() instanceof DOMResult).as("Wrong payload type ").isTrue();
|
||||
Document doc = (Document) ((DOMResult) result.getPayload()).getNode();
|
||||
assertEquals("Wrong payload", "hello", doc.getDocumentElement().getTextContent());
|
||||
assertThat(doc.getDocumentElement().getTextContent()).as("Wrong payload").isEqualTo("hello");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -117,7 +112,7 @@ public class MarshallingTransformerParserTests {
|
||||
GenericMessage<Object> message = new GenericMessage<Object>("hello");
|
||||
input.send(message);
|
||||
Message<?> result = output.receive(0);
|
||||
assertTrue("Wrong payload type", result.getPayload() instanceof StringResult);
|
||||
assertThat(result.getPayload() instanceof StringResult).as("Wrong payload type").isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -126,7 +121,7 @@ public class MarshallingTransformerParserTests {
|
||||
GenericMessage<Object> message = new GenericMessage<Object>("hello");
|
||||
input.send(message);
|
||||
Message<?> result = output.receive(0);
|
||||
assertTrue("Wrong payload type", result.getPayload() instanceof StubStringResult);
|
||||
assertThat(result.getPayload() instanceof StubStringResult).as("Wrong payload type").isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -135,12 +130,12 @@ public class MarshallingTransformerParserTests {
|
||||
GenericMessage<Object> message = new GenericMessage<Object>("hello");
|
||||
input.send(message);
|
||||
Message<?> result = output.receive(0);
|
||||
assertTrue("Wrong payload type", result.getPayload() instanceof DOMResult);
|
||||
assertThat(result.getPayload() instanceof DOMResult).as("Wrong payload type").isTrue();
|
||||
Document doc = (Document) ((DOMResult) result.getPayload()).getNode();
|
||||
String actual = doc.getDocumentElement().getTextContent();
|
||||
assertThat(actual, Matchers.containsString("[payload"));
|
||||
assertThat(actual, Matchers.containsString("=hello,"));
|
||||
assertThat(actual, Matchers.containsString(", headers="));
|
||||
assertThat(actual).contains("[payload");
|
||||
assertThat(actual).contains("=hello,");
|
||||
assertThat(actual).contains(", headers=");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -16,11 +16,7 @@
|
||||
|
||||
package org.springframework.integration.xml.config;
|
||||
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -67,15 +63,15 @@ public class UnmarshallingTransformerParserTests {
|
||||
@Test
|
||||
public void testParse() throws Exception {
|
||||
EventDrivenConsumer consumer = (EventDrivenConsumer) appContext.getBean("parseOnly");
|
||||
assertEquals(2, TestUtils.getPropertyValue(consumer, "handler.order"));
|
||||
assertEquals(123L, TestUtils.getPropertyValue(consumer, "handler.messagingTemplate.sendTimeout"));
|
||||
assertEquals(-1, TestUtils.getPropertyValue(consumer, "phase"));
|
||||
assertFalse(TestUtils.getPropertyValue(consumer, "autoStartup", Boolean.class));
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "handler.order")).isEqualTo(2);
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "handler.messagingTemplate.sendTimeout")).isEqualTo(123L);
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "phase")).isEqualTo(-1);
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "autoStartup", Boolean.class)).isFalse();
|
||||
SmartLifecycleRoleController roleController = appContext.getBean(SmartLifecycleRoleController.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<SmartLifecycle> list = (List<SmartLifecycle>) TestUtils.getPropertyValue(roleController, "lifecycles",
|
||||
MultiValueMap.class).get("foo");
|
||||
assertThat(list, contains((SmartLifecycle) consumer));
|
||||
assertThat(list).containsExactly((SmartLifecycle) consumer);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -86,8 +82,9 @@ public class UnmarshallingTransformerParserTests {
|
||||
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><order><orderItem>test</orderItem></order>"));
|
||||
input.send(message);
|
||||
Message<?> result = output.receive(0);
|
||||
assertEquals("Wrong payload after unmarshalling", "unmarshalled", result.getPayload());
|
||||
assertTrue("Wrong source passed to unmarshaller", unmarshaller.sourcesPassed.poll() instanceof StringSource);
|
||||
assertThat(result.getPayload()).as("Wrong payload after unmarshalling").isEqualTo("unmarshalled");
|
||||
assertThat(unmarshaller.sourcesPassed.poll() instanceof StringSource).as("Wrong source passed to unmarshaller")
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -98,8 +95,9 @@ public class UnmarshallingTransformerParserTests {
|
||||
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><order><orderItem>test</orderItem></order>");
|
||||
input.send(message);
|
||||
Message<?> result = output.receive(0);
|
||||
assertEquals("Wrong payload after unmarshalling", "unmarshalled", result.getPayload());
|
||||
assertTrue("Wrong source passed to unmarshaller", unmarshaller.sourcesPassed.poll() instanceof StringSource);
|
||||
assertThat(result.getPayload()).as("Wrong payload after unmarshalling").isEqualTo("unmarshalled");
|
||||
assertThat(unmarshaller.sourcesPassed.poll() instanceof StringSource).as("Wrong source passed to unmarshaller")
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -110,8 +108,9 @@ public class UnmarshallingTransformerParserTests {
|
||||
XmlTestUtil.getDocumentForString("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><order><orderItem>test</orderItem></order>"));
|
||||
input.send(message);
|
||||
Message<?> result = output.receive(0);
|
||||
assertEquals("Wrong payload after unmarshalling", "unmarshalled", result.getPayload());
|
||||
assertTrue("Wrong source passed to unmarshaller", unmarshaller.sourcesPassed.poll() instanceof DOMSource);
|
||||
assertThat(result.getPayload()).as("Wrong payload after unmarshalling").isEqualTo("unmarshalled");
|
||||
assertThat(unmarshaller.sourcesPassed.poll() instanceof DOMSource).as("Wrong source passed to unmarshaller")
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -122,8 +121,9 @@ public class UnmarshallingTransformerParserTests {
|
||||
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><order><orderItem>test</orderItem></order>"));
|
||||
input.send(message);
|
||||
Message<?> result = output.receive(5000);
|
||||
assertEquals("Wrong payload after unmarshalling", "unmarshalled", result.getPayload());
|
||||
assertTrue("Wrong source passed to unmarshaller", unmarshaller.sourcesPassed.poll() instanceof StringSource);
|
||||
assertThat(result.getPayload()).as("Wrong payload after unmarshalling").isEqualTo("unmarshalled");
|
||||
assertThat(unmarshaller.sourcesPassed.poll() instanceof StringSource).as("Wrong source passed to unmarshaller")
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -16,9 +16,8 @@
|
||||
|
||||
package org.springframework.integration.xml.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.xml.sax.SAXParseException;
|
||||
@@ -33,15 +32,19 @@ public class XPathExpressionParserTests {
|
||||
public void testSimpleStringExpression() throws Exception {
|
||||
String xmlDoc = "<si-xml:xpath-expression id='xpathExpression' expression='/name' />";
|
||||
XPathExpression xPathExpression = getXPathExpression(xmlDoc);
|
||||
assertEquals("outputOne", xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<name>outputOne</name>")));
|
||||
assertThat(xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<name>outputOne</name>")))
|
||||
.isEqualTo("outputOne");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNamespacedStringExpression() throws Exception {
|
||||
String xmlDoc = "<si-xml:xpath-expression id='xpathExpression' expression='/ns1:name' ns-prefix='ns1' ns-uri='www.example.org' />";
|
||||
XPathExpression xPathExpression = getXPathExpression(xmlDoc);
|
||||
assertEquals("outputOne", xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<ns1:name xmlns:ns1='www.example.org'>outputOne</ns1:name>")));
|
||||
assertEquals("", xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<name>outputOne</name>")));
|
||||
assertThat(xPathExpression.evaluateAsString(XmlTestUtil
|
||||
.getDocumentForString("<ns1:name xmlns:ns1='www.example.org'>outputOne</ns1:name>")))
|
||||
.isEqualTo("outputOne");
|
||||
assertThat(xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<name>outputOne</name>")))
|
||||
.isEqualTo("");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -49,8 +52,11 @@ public class XPathExpressionParserTests {
|
||||
StringBuffer xmlDoc = new StringBuffer("<si-xml:xpath-expression id='xpathExpression' expression='/ns1:name' namespace-map='myNamespaces' />");
|
||||
xmlDoc.append("<util:map id='myNamespaces'><entry key='ns1' value='www.example.org' /></util:map>");
|
||||
XPathExpression xPathExpression = getXPathExpression(xmlDoc.toString());
|
||||
assertEquals("outputOne", xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<ns1:name xmlns:ns1='www.example.org'>outputOne</ns1:name>")));
|
||||
assertEquals("", xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<name>outputOne</name>")));
|
||||
assertThat(xPathExpression.evaluateAsString(XmlTestUtil
|
||||
.getDocumentForString("<ns1:name xmlns:ns1='www.example.org'>outputOne</ns1:name>")))
|
||||
.isEqualTo("outputOne");
|
||||
assertThat(xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<name>outputOne</name>")))
|
||||
.isEqualTo("");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -61,8 +67,11 @@ public class XPathExpressionParserTests {
|
||||
.append("</si-xml:xpath-expression>");
|
||||
|
||||
XPathExpression xPathExpression = getXPathExpression(xmlDoc.toString());
|
||||
assertEquals("outputOne", xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<ns1:name xmlns:ns1='www.example.org'>outputOne</ns1:name>")));
|
||||
assertEquals("", xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<name>outputOne</name>")));
|
||||
assertThat(xPathExpression.evaluateAsString(XmlTestUtil
|
||||
.getDocumentForString("<ns1:name xmlns:ns1='www.example.org'>outputOne</ns1:name>")))
|
||||
.isEqualTo("outputOne");
|
||||
assertThat(xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<name>outputOne</name>")))
|
||||
.isEqualTo("");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,7 +87,7 @@ public class XPathExpressionParserTests {
|
||||
getXPathExpression(xmlDoc.toString());
|
||||
}
|
||||
catch (BeanDefinitionStoreException e) {
|
||||
assertTrue(e.getCause() instanceof SAXParseException);
|
||||
assertThat(e.getCause() instanceof SAXParseException).isTrue();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -90,8 +99,11 @@ public class XPathExpressionParserTests {
|
||||
public void testNamespacePrefixButNoUri() throws Exception {
|
||||
String xmlDoc = "<si-xml:xpath-expression id='xpathExpression' expression='/ns1:name' ns-prefix='ns1' />";
|
||||
XPathExpression xPathExpression = getXPathExpression(xmlDoc);
|
||||
assertEquals("outputOne", xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<ns1:name xmlns:ns1='www.example.org'>outputOne</ns1:name>")));
|
||||
assertEquals("", xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<name>outputOne</name>")));
|
||||
assertThat(xPathExpression.evaluateAsString(XmlTestUtil
|
||||
.getDocumentForString("<ns1:name xmlns:ns1='www.example.org'>outputOne</ns1:name>")))
|
||||
.isEqualTo("outputOne");
|
||||
assertThat(xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<name>outputOne</name>")))
|
||||
.isEqualTo("");
|
||||
|
||||
}
|
||||
|
||||
@@ -104,7 +116,9 @@ public class XPathExpressionParserTests {
|
||||
getXPathExpression(xmlDoc.toString());
|
||||
}
|
||||
catch (BeanDefinitionStoreException e) {
|
||||
assertEquals("It is not valid to specify both, the namespace attributes ('ns-prefix' and 'ns-uri') and the 'namespace-map' attribute.", e.getCause().getMessage());
|
||||
assertThat(e.getCause().getMessage())
|
||||
.isEqualTo("It is not valid to specify both, the namespace attributes ('ns-prefix' and 'ns-uri') " +
|
||||
"and the 'namespace-map' attribute.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -122,7 +136,8 @@ public class XPathExpressionParserTests {
|
||||
getXPathExpression(xmlDoc.toString());
|
||||
}
|
||||
catch (BeanDefinitionStoreException e) {
|
||||
assertEquals("It is not valid to specify both, the namespace attributes ('ns-prefix' and 'ns-uri') and the 'map' sub-element.", e.getCause().getMessage());
|
||||
assertThat(e.getCause().getMessage())
|
||||
.isEqualTo("It is not valid to specify both, the namespace attributes ('ns-prefix' and 'ns-uri') and the 'map' sub-element.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -141,7 +156,8 @@ public class XPathExpressionParserTests {
|
||||
getXPathExpression(xmlDoc.toString());
|
||||
}
|
||||
catch (BeanDefinitionStoreException e) {
|
||||
assertEquals("It is not valid to specify both, the 'namespace-map' attribute and the 'map' sub-element.", e.getCause().getMessage());
|
||||
assertThat(e.getCause().getMessage())
|
||||
.isEqualTo("It is not valid to specify both, the 'namespace-map' attribute and the 'map' sub-element.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -16,11 +16,7 @@
|
||||
|
||||
package org.springframework.integration.xml.config;
|
||||
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -61,15 +57,15 @@ public class XPathFilterParserTests {
|
||||
@Test
|
||||
public void testParse() throws Exception {
|
||||
EventDrivenConsumer consumer = (EventDrivenConsumer) context.getBean("parseOnly");
|
||||
assertEquals(2, TestUtils.getPropertyValue(consumer, "handler.order"));
|
||||
assertEquals(123L, TestUtils.getPropertyValue(consumer, "handler.messagingTemplate.sendTimeout"));
|
||||
assertEquals(-1, TestUtils.getPropertyValue(consumer, "phase"));
|
||||
assertFalse(TestUtils.getPropertyValue(consumer, "autoStartup", Boolean.class));
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "handler.order")).isEqualTo(2);
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "handler.messagingTemplate.sendTimeout")).isEqualTo(123L);
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "phase")).isEqualTo(-1);
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "autoStartup", Boolean.class)).isFalse();
|
||||
SmartLifecycleRoleController roleController = context.getBean(SmartLifecycleRoleController.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<SmartLifecycle> list = (List<SmartLifecycle>) TestUtils.getPropertyValue(roleController, "lifecycles",
|
||||
MultiValueMap.class).get("foo");
|
||||
assertThat(list, contains((SmartLifecycle) consumer));
|
||||
assertThat(list).containsExactly((SmartLifecycle) consumer);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,10 +77,10 @@ public class XPathFilterParserTests {
|
||||
Message<?> shouldBeRejected = MessageBuilder.withPayload("<other>outputOne</other>").setReplyChannel(replyChannel).build();
|
||||
inputChannel.send(shouldBeAccepted);
|
||||
inputChannel.send(shouldBeRejected);
|
||||
assertEquals(shouldBeAccepted, replyChannel.receive(0));
|
||||
assertEquals(shouldBeRejected, discardChannel.receive(0));
|
||||
assertNull(replyChannel.receive(0));
|
||||
assertNull(discardChannel.receive(0));
|
||||
assertThat(replyChannel.receive(0)).isEqualTo(shouldBeAccepted);
|
||||
assertThat(discardChannel.receive(0)).isEqualTo(shouldBeRejected);
|
||||
assertThat(replyChannel.receive(0)).isNull();
|
||||
assertThat(discardChannel.receive(0)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -98,10 +94,10 @@ public class XPathFilterParserTests {
|
||||
Message<?> shouldBeRejected = MessageBuilder.withPayload(docToReject).setReplyChannel(replyChannel).build();
|
||||
inputChannel.send(shouldBeAccepted);
|
||||
inputChannel.send(shouldBeRejected);
|
||||
assertEquals(shouldBeAccepted, replyChannel.receive(0));
|
||||
assertEquals(shouldBeRejected, discardChannel.receive(0));
|
||||
assertNull(replyChannel.receive(0));
|
||||
assertNull(discardChannel.receive(0));
|
||||
assertThat(replyChannel.receive(0)).isEqualTo(shouldBeAccepted);
|
||||
assertThat(discardChannel.receive(0)).isEqualTo(shouldBeRejected);
|
||||
assertThat(replyChannel.receive(0)).isNull();
|
||||
assertThat(discardChannel.receive(0)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -115,10 +111,10 @@ public class XPathFilterParserTests {
|
||||
Message<?> shouldBeRejected = MessageBuilder.withPayload(docToReject).setReplyChannel(replyChannel).build();
|
||||
inputChannel.send(shouldBeAccepted);
|
||||
inputChannel.send(shouldBeRejected);
|
||||
assertEquals(shouldBeAccepted, replyChannel.receive(0));
|
||||
assertEquals(shouldBeRejected, discardChannel.receive(0));
|
||||
assertNull(replyChannel.receive(0));
|
||||
assertNull(discardChannel.receive(0));
|
||||
assertThat(replyChannel.receive(0)).isEqualTo(shouldBeAccepted);
|
||||
assertThat(discardChannel.receive(0)).isEqualTo(shouldBeRejected);
|
||||
assertThat(replyChannel.receive(0)).isNull();
|
||||
assertThat(discardChannel.receive(0)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -132,10 +128,10 @@ public class XPathFilterParserTests {
|
||||
Message<?> shouldBeRejected = MessageBuilder.withPayload(docToReject).setReplyChannel(replyChannel).build();
|
||||
inputChannel.send(shouldBeAccepted);
|
||||
inputChannel.send(shouldBeRejected);
|
||||
assertEquals(shouldBeAccepted, replyChannel.receive(0));
|
||||
assertEquals(shouldBeRejected, discardChannel.receive(0));
|
||||
assertNull(replyChannel.receive(0));
|
||||
assertNull(discardChannel.receive(0));
|
||||
assertThat(replyChannel.receive(0)).isEqualTo(shouldBeAccepted);
|
||||
assertThat(discardChannel.receive(0)).isEqualTo(shouldBeRejected);
|
||||
assertThat(replyChannel.receive(0)).isNull();
|
||||
assertThat(discardChannel.receive(0)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -152,11 +148,11 @@ public class XPathFilterParserTests {
|
||||
inputChannel.send(shouldBeAccepted1);
|
||||
inputChannel.send(shouldBeAccepted2);
|
||||
inputChannel.send(shouldBeRejected);
|
||||
assertEquals(shouldBeAccepted1, replyChannel.receive(0));
|
||||
assertEquals(shouldBeAccepted2, replyChannel.receive(0));
|
||||
assertEquals(shouldBeRejected, discardChannel.receive(0));
|
||||
assertNull(replyChannel.receive(0));
|
||||
assertNull(discardChannel.receive(0));
|
||||
assertThat(replyChannel.receive(0)).isEqualTo(shouldBeAccepted1);
|
||||
assertThat(replyChannel.receive(0)).isEqualTo(shouldBeAccepted2);
|
||||
assertThat(discardChannel.receive(0)).isEqualTo(shouldBeRejected);
|
||||
assertThat(replyChannel.receive(0)).isNull();
|
||||
assertThat(discardChannel.receive(0)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -173,11 +169,11 @@ public class XPathFilterParserTests {
|
||||
inputChannel.send(shouldBeAccepted1);
|
||||
inputChannel.send(shouldBeAccepted2);
|
||||
inputChannel.send(shouldBeRejected);
|
||||
assertEquals(shouldBeAccepted1, replyChannel.receive(0));
|
||||
assertEquals(shouldBeAccepted2, replyChannel.receive(0));
|
||||
assertEquals(shouldBeRejected, discardChannel.receive(0));
|
||||
assertNull(replyChannel.receive(0));
|
||||
assertNull(discardChannel.receive(0));
|
||||
assertThat(replyChannel.receive(0)).isEqualTo(shouldBeAccepted1);
|
||||
assertThat(replyChannel.receive(0)).isEqualTo(shouldBeAccepted2);
|
||||
assertThat(discardChannel.receive(0)).isEqualTo(shouldBeRejected);
|
||||
assertThat(replyChannel.receive(0)).isNull();
|
||||
assertThat(discardChannel.receive(0)).isNull();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,14 +16,7 @@
|
||||
|
||||
package org.springframework.integration.xml.config;
|
||||
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -77,42 +70,42 @@ public class XPathHeaderEnricherParserTests {
|
||||
@Test
|
||||
public void testParse() {
|
||||
EventDrivenConsumer consumer = (EventDrivenConsumer) context.getBean("parseOnly");
|
||||
assertEquals(2, TestUtils.getPropertyValue(consumer, "handler.order"));
|
||||
assertEquals(123L, TestUtils.getPropertyValue(consumer, "handler.messagingTemplate.sendTimeout"));
|
||||
assertEquals(-1, TestUtils.getPropertyValue(consumer, "phase"));
|
||||
assertFalse(TestUtils.getPropertyValue(consumer, "autoStartup", Boolean.class));
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "handler.order")).isEqualTo(2);
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "handler.messagingTemplate.sendTimeout")).isEqualTo(123L);
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "phase")).isEqualTo(-1);
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "autoStartup", Boolean.class)).isFalse();
|
||||
SmartLifecycleRoleController roleController = context.getBean(SmartLifecycleRoleController.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<SmartLifecycle> list = (List<SmartLifecycle>) TestUtils.getPropertyValue(roleController, "lifecycles",
|
||||
MultiValueMap.class).get("foo");
|
||||
assertThat(list, contains((SmartLifecycle) consumer));
|
||||
assertThat(list).containsExactly((SmartLifecycle) consumer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stringResultByDefault() {
|
||||
Message<?> result = this.getResultMessage();
|
||||
assertEquals("John Doe", result.getHeaders().get("name"));
|
||||
assertThat(result.getHeaders().get("name")).isEqualTo("John Doe");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void numberResult() {
|
||||
Message<?> result = this.getResultMessage();
|
||||
assertEquals(42, result.getHeaders().get("age"));
|
||||
assertThat(result.getHeaders().get("age")).isEqualTo(42);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void booleanResult() {
|
||||
Message<?> result = this.getResultMessage();
|
||||
assertEquals(Boolean.TRUE, result.getHeaders().get("married"));
|
||||
assertThat(result.getHeaders().get("married")).isEqualTo(Boolean.TRUE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nodeResult() {
|
||||
Message<?> result = this.getResultMessage();
|
||||
Object header = result.getHeaders().get("node-test");
|
||||
assertTrue(header instanceof Node);
|
||||
assertThat(header instanceof Node).isTrue();
|
||||
Node node = (Node) header;
|
||||
assertEquals("42", node.getTextContent());
|
||||
assertThat(node.getTextContent()).isEqualTo("42");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -120,36 +113,37 @@ public class XPathHeaderEnricherParserTests {
|
||||
public void nodeListResult() {
|
||||
Message<?> result = this.getResultMessage();
|
||||
Object header = result.getHeaders().get("node-list-test");
|
||||
assertThat(header, instanceOf(List.class));
|
||||
assertThat(header).isInstanceOf(List.class);
|
||||
List<Node> nodeList = (List<Node>) header;
|
||||
assertNotNull(nodeList);
|
||||
assertEquals(3, nodeList.size());
|
||||
assertThat(nodeList).isNotNull();
|
||||
assertThat(nodeList.size()).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void expressionRef() {
|
||||
Message<?> result = getResultMessage();
|
||||
assertEquals(84d, result.getHeaders().get("ref-test"));
|
||||
assertThat(result.getHeaders().get("ref-test")).isEqualTo(84d);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultHeaderEnricher() {
|
||||
assertFalse(getEnricherProperty("defaultHeaderEnricher", "defaultOverwrite"));
|
||||
assertTrue(getEnricherProperty("defaultHeaderEnricher", "shouldSkipNulls"));
|
||||
assertThat(getEnricherProperty("defaultHeaderEnricher", "defaultOverwrite")).isFalse();
|
||||
assertThat(getEnricherProperty("defaultHeaderEnricher", "shouldSkipNulls")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testCustomHeaderEnricher() {
|
||||
assertTrue(getEnricherProperty("customHeaderEnricher", "defaultOverwrite"));
|
||||
assertFalse(getEnricherProperty("customHeaderEnricher", "shouldSkipNulls"));
|
||||
assertThat(getEnricherProperty("customHeaderEnricher", "defaultOverwrite")).isTrue();
|
||||
assertThat(getEnricherProperty("customHeaderEnricher", "shouldSkipNulls")).isFalse();
|
||||
Map<String, ? extends HeaderValueMessageProcessor<?>> headersToAdd =
|
||||
TestUtils.getPropertyValue(this.context.getBean("customHeaderEnricher"),
|
||||
"handler.transformer.headersToAdd", Map.class);
|
||||
HeaderValueMessageProcessor<?> headerValueMessageProcessor = headersToAdd.get("foo");
|
||||
assertThat(headerValueMessageProcessor, instanceOf(XPathExpressionEvaluatingHeaderValueMessageProcessor.class));
|
||||
assertSame(this.context.getBean("xmlPayloadConverter"),
|
||||
TestUtils.getPropertyValue(headerValueMessageProcessor, "converter"));
|
||||
assertThat(headerValueMessageProcessor)
|
||||
.isInstanceOf(XPathExpressionEvaluatingHeaderValueMessageProcessor.class);
|
||||
assertThat(TestUtils.getPropertyValue(headerValueMessageProcessor, "converter"))
|
||||
.isSameAs(this.context.getBean("xmlPayloadConverter"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -161,8 +155,8 @@ public class XPathHeaderEnricherParserTests {
|
||||
.build();
|
||||
this.context.getBean("defaultInput", MessageChannel.class).send(request);
|
||||
Message<?> reply = replyChannel.receive();
|
||||
assertNotNull(reply);
|
||||
assertEquals("John Doe", reply.getHeaders().get("foo"));
|
||||
assertThat(reply).isNotNull();
|
||||
assertThat(reply.getHeaders().get("foo")).isEqualTo("John Doe");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -174,8 +168,8 @@ public class XPathHeaderEnricherParserTests {
|
||||
.build();
|
||||
this.context.getBean("customInput", MessageChannel.class).send(request);
|
||||
Message<?> reply = replyChannel.receive();
|
||||
assertNotNull(reply);
|
||||
assertEquals("bar", reply.getHeaders().get("foo"));
|
||||
assertThat(reply).isNotNull();
|
||||
assertThat(reply.getHeaders().get("foo")).isEqualTo("bar");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -16,9 +16,7 @@
|
||||
|
||||
package org.springframework.integration.xml.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
@@ -64,15 +62,15 @@ public class XPathMessageSplitterParserTests {
|
||||
+ "order='2' send-timeout='123' auto-startup='false' phase='-1' "
|
||||
+ "input-channel='test-input' output-channel='test-output'><si-xml:xpath-expression expression='//name'/></si-xml:xpath-splitter>");
|
||||
EventDrivenConsumer consumer = (EventDrivenConsumer) ctx.getBean("splitter");
|
||||
assertEquals(2, TestUtils.getPropertyValue(consumer, "handler.order"));
|
||||
assertEquals(123L, TestUtils.getPropertyValue(consumer, "handler.messagingTemplate.sendTimeout"));
|
||||
assertEquals(-1, TestUtils.getPropertyValue(consumer, "phase"));
|
||||
assertFalse(TestUtils.getPropertyValue(consumer, "autoStartup", Boolean.class));
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "handler.order")).isEqualTo(2);
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "handler.messagingTemplate.sendTimeout")).isEqualTo(123L);
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "phase")).isEqualTo(-1);
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "autoStartup", Boolean.class)).isFalse();
|
||||
consumer.start();
|
||||
ctx.getAutowireCapableBeanFactory().autowireBeanProperties(this, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE,
|
||||
false);
|
||||
inputChannel.send(docMessage);
|
||||
assertEquals("Wrong number of split messages ", 2, outputChannel.getQueueSize());
|
||||
assertThat(outputChannel.getQueueSize()).as("Wrong number of split messages ").isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -87,11 +85,11 @@ public class XPathMessageSplitterParserTests {
|
||||
ctx.getAutowireCapableBeanFactory().autowireBeanProperties(this, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE,
|
||||
false);
|
||||
inputChannel.send(docMessage);
|
||||
assertEquals("Wrong number of split messages ", 2, outputChannel.getQueueSize());
|
||||
assertTrue("Splitter failed to create documents ",
|
||||
((Message<?>) outputChannel.receive(1000)).getPayload() instanceof Document);
|
||||
assertTrue("Splitter failed to create documents ",
|
||||
((Message<?>) outputChannel.receive(1000)).getPayload() instanceof Document);
|
||||
assertThat(outputChannel.getQueueSize()).as("Wrong number of split messages ").isEqualTo(2);
|
||||
assertThat(((Message<?>) outputChannel.receive(1000)).getPayload() instanceof Document)
|
||||
.as("Splitter failed to create documents ").isTrue();
|
||||
assertThat(((Message<?>) outputChannel.receive(1000)).getPayload() instanceof Document)
|
||||
.as("Splitter failed to create documents ").isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -105,7 +103,8 @@ public class XPathMessageSplitterParserTests {
|
||||
Object handler = fieldAccessor.getPropertyValue("handler");
|
||||
fieldAccessor = new DirectFieldAccessor(handler);
|
||||
Object documnetBuilderFactory = fieldAccessor.getPropertyValue("documentBuilderFactory");
|
||||
assertTrue("DocumnetBuilderFactory was not expected stub ", documnetBuilderFactory instanceof DocumentBuilderFactory);
|
||||
assertThat(documnetBuilderFactory instanceof DocumentBuilderFactory)
|
||||
.as("DocumnetBuilderFactory was not expected stub ").isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -120,7 +119,8 @@ public class XPathMessageSplitterParserTests {
|
||||
Object handler = fieldAccessor.getPropertyValue("handler");
|
||||
fieldAccessor = new DirectFieldAccessor(handler);
|
||||
Object documnetBuilderFactory = fieldAccessor.getPropertyValue("documentBuilderFactory");
|
||||
assertTrue("DocumnetBuilderFactory was not expected stub ", documnetBuilderFactory instanceof DocumentBuilderFactory);
|
||||
assertThat(documnetBuilderFactory instanceof DocumentBuilderFactory)
|
||||
.as("DocumnetBuilderFactory was not expected stub ").isTrue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -16,12 +16,7 @@
|
||||
|
||||
package org.springframework.integration.xml.config;
|
||||
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -97,15 +92,15 @@ public class XPathRouterParserTests {
|
||||
ClassPathXmlApplicationContext context =
|
||||
new ClassPathXmlApplicationContext("XPathRouterTests-context.xml", this.getClass());
|
||||
EventDrivenConsumer consumer = (EventDrivenConsumer) context.getBean("parseOnly");
|
||||
assertEquals(2, TestUtils.getPropertyValue(consumer, "handler.order"));
|
||||
assertEquals(123L, TestUtils.getPropertyValue(consumer, "handler.messagingTemplate.sendTimeout"));
|
||||
assertEquals(-1, TestUtils.getPropertyValue(consumer, "phase"));
|
||||
assertFalse(TestUtils.getPropertyValue(consumer, "autoStartup", Boolean.class));
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "handler.order")).isEqualTo(2);
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "handler.messagingTemplate.sendTimeout")).isEqualTo(123L);
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "phase")).isEqualTo(-1);
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "autoStartup", Boolean.class)).isFalse();
|
||||
SmartLifecycleRoleController roleController = context.getBean(SmartLifecycleRoleController.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<SmartLifecycle> list = (List<SmartLifecycle>) TestUtils.getPropertyValue(roleController, "lifecycles",
|
||||
MultiValueMap.class).get("foo");
|
||||
assertThat(list, contains((SmartLifecycle) consumer));
|
||||
assertThat(list).containsExactly((SmartLifecycle) consumer);
|
||||
context.close();
|
||||
}
|
||||
|
||||
@@ -115,7 +110,7 @@ public class XPathRouterParserTests {
|
||||
GenericMessage<Document> docMessage = new GenericMessage<Document>(doc);
|
||||
buildContext("<si-xml:xpath-router id='router' input-channel='test-input'><si-xml:xpath-expression expression='/name'/></si-xml:xpath-router>");
|
||||
inputChannel.send(docMessage);
|
||||
assertEquals("Wrong number of messages", 1, outputChannel.getQueueSize());
|
||||
assertThat(outputChannel.getQueueSize()).as("Wrong number of messages").isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -124,7 +119,7 @@ public class XPathRouterParserTests {
|
||||
GenericMessage<Document> docMessage = new GenericMessage<Document>(doc);
|
||||
buildContext("<si-xml:xpath-router id='router' input-channel='test-input'><si-xml:xpath-expression expression='/ns2:name' ns-prefix='ns2' ns-uri='www.example.org' /></si-xml:xpath-router>");
|
||||
inputChannel.send(docMessage);
|
||||
assertEquals("Wrong number of messages", 1, outputChannel.getQueueSize());
|
||||
assertThat(outputChannel.getQueueSize()).as("Wrong number of messages").isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -138,7 +133,7 @@ public class XPathRouterParserTests {
|
||||
buffer.append("</si-xml:xpath-expression></si-xml:xpath-router>");
|
||||
buildContext(buffer.toString());
|
||||
inputChannel.send(docMessage);
|
||||
assertEquals("Wrong number of messages", 1, outputChannel.getQueueSize());
|
||||
assertThat(outputChannel.getQueueSize()).as("Wrong number of messages").isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -153,7 +148,7 @@ public class XPathRouterParserTests {
|
||||
|
||||
buildContext(buffer.toString());
|
||||
inputChannel.send(docMessage);
|
||||
assertEquals("Wrong number of messages", 1, outputChannel.getQueueSize());
|
||||
assertThat(outputChannel.getQueueSize()).as("Wrong number of messages").isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -165,7 +160,7 @@ public class XPathRouterParserTests {
|
||||
Object handler = accessor.getPropertyValue("handler");
|
||||
accessor = new DirectFieldAccessor(handler);
|
||||
Object resolutionRequired = accessor.getPropertyValue("resolutionRequired");
|
||||
assertEquals("Resolution required not set to false ", false, resolutionRequired);
|
||||
assertThat(resolutionRequired).as("Resolution required not set to false ").isEqualTo(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -177,7 +172,7 @@ public class XPathRouterParserTests {
|
||||
Object handler = accessor.getPropertyValue("handler");
|
||||
accessor = new DirectFieldAccessor(handler);
|
||||
Object resolutionRequired = accessor.getPropertyValue("resolutionRequired");
|
||||
assertEquals("Resolution required not set to true ", true, resolutionRequired);
|
||||
assertThat(resolutionRequired).as("Resolution required not set to true ").isEqualTo(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -189,9 +184,9 @@ public class XPathRouterParserTests {
|
||||
Object handler = accessor.getPropertyValue("handler");
|
||||
accessor = new DirectFieldAccessor(handler);
|
||||
Object defaultOutputChannelValue = accessor.getPropertyValue("defaultOutputChannel");
|
||||
assertEquals("Default output channel not correctly set ", defaultOutput, defaultOutputChannelValue);
|
||||
assertThat(defaultOutputChannelValue).as("Default output channel not correctly set ").isEqualTo(defaultOutput);
|
||||
inputChannel.send(MessageBuilder.withPayload("<unrelated/>").build());
|
||||
assertEquals("Wrong count of messages on default output channel", 1, defaultOutput.getQueueSize());
|
||||
assertThat(defaultOutput.getQueueSize()).as("Wrong count of messages on default output channel").isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -204,15 +199,15 @@ public class XPathRouterParserTests {
|
||||
Document doc = XmlTestUtil.getDocumentForString("<name>channelA</name>");
|
||||
GenericMessage<Document> docMessage = new GenericMessage<Document>(doc);
|
||||
inputChannel.send(docMessage);
|
||||
assertNotNull(channelA.receive(10));
|
||||
assertNull(channelB.receive(10));
|
||||
assertThat(channelA.receive(10)).isNotNull();
|
||||
assertThat(channelB.receive(10)).isNull();
|
||||
|
||||
EventDrivenConsumer routerEndpoint = ac.getBean("xpathRouterEmpty", EventDrivenConsumer.class);
|
||||
AbstractMappingMessageRouter xpathRouter = (AbstractMappingMessageRouter) TestUtils.getPropertyValue(routerEndpoint, "handler");
|
||||
xpathRouter.setChannelMapping("channelA", "channelB");
|
||||
inputChannel.send(docMessage);
|
||||
assertNotNull(channelB.receive(10));
|
||||
assertNull(channelA.receive(10));
|
||||
assertThat(channelB.receive(10)).isNotNull();
|
||||
assertThat(channelA.receive(10)).isNull();
|
||||
ac.close();
|
||||
}
|
||||
|
||||
@@ -226,15 +221,15 @@ public class XPathRouterParserTests {
|
||||
Document doc = XmlTestUtil.getDocumentForString("<name>channelA</name>");
|
||||
GenericMessage<Document> docMessage = new GenericMessage<Document>(doc);
|
||||
inputChannel.send(docMessage);
|
||||
assertNull(channelA.receive(10));
|
||||
assertNotNull(channelB.receive(10));
|
||||
assertThat(channelA.receive(10)).isNull();
|
||||
assertThat(channelB.receive(10)).isNotNull();
|
||||
|
||||
EventDrivenConsumer routerEndpoint = ac.getBean("xpathRouterWithMapping", EventDrivenConsumer.class);
|
||||
AbstractMappingMessageRouter xpathRouter = (AbstractMappingMessageRouter) TestUtils.getPropertyValue(routerEndpoint, "handler");
|
||||
xpathRouter.removeChannelMapping("channelA");
|
||||
inputChannel.send(docMessage);
|
||||
assertNotNull(channelA.receive(10));
|
||||
assertNull(channelB.receive(10));
|
||||
assertThat(channelA.receive(10)).isNotNull();
|
||||
assertThat(channelB.receive(10)).isNull();
|
||||
ac.close();
|
||||
}
|
||||
|
||||
@@ -248,17 +243,17 @@ public class XPathRouterParserTests {
|
||||
Document doc = XmlTestUtil.getDocumentForString("<root><name>channelA</name><name>channelB</name></root>");
|
||||
GenericMessage<Document> docMessage = new GenericMessage<Document>(doc);
|
||||
inputChannel.send(docMessage);
|
||||
assertNotNull(channelA.receive(10));
|
||||
assertNotNull(channelA.receive(10));
|
||||
assertNull(channelB.receive(10));
|
||||
assertThat(channelA.receive(10)).isNotNull();
|
||||
assertThat(channelA.receive(10)).isNotNull();
|
||||
assertThat(channelB.receive(10)).isNull();
|
||||
|
||||
EventDrivenConsumer routerEndpoint = ac.getBean("xpathRouterWithMappingMultiChannel", EventDrivenConsumer.class);
|
||||
AbstractMappingMessageRouter xpathRouter = (AbstractMappingMessageRouter) TestUtils.getPropertyValue(routerEndpoint, "handler");
|
||||
xpathRouter.removeChannelMapping("channelA");
|
||||
xpathRouter.removeChannelMapping("channelB");
|
||||
inputChannel.send(docMessage);
|
||||
assertNotNull(channelA.receive(10));
|
||||
assertNotNull(channelB.receive(10));
|
||||
assertThat(channelA.receive(10)).isNotNull();
|
||||
assertThat(channelB.receive(10)).isNotNull();
|
||||
ac.close();
|
||||
}
|
||||
|
||||
@@ -270,7 +265,7 @@ public class XPathRouterParserTests {
|
||||
Document doc = XmlTestUtil.getDocumentForString("<channelA/>");
|
||||
GenericMessage<Document> docMessage = new GenericMessage<Document>(doc);
|
||||
inputChannel.send(docMessage);
|
||||
assertNotNull(channelA.receive(10));
|
||||
assertThat(channelA.receive(10)).isNotNull();
|
||||
ac.close();
|
||||
}
|
||||
|
||||
@@ -282,8 +277,8 @@ public class XPathRouterParserTests {
|
||||
GenericMessage<String> message = new GenericMessage<String>("<name>channelA</name>");
|
||||
inputChannel.send(message);
|
||||
Message<?> result = channelZ.receive(0);
|
||||
assertNotNull(result);
|
||||
assertEquals("<name>channelA</name>", result.getPayload());
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getPayload()).isEqualTo("<name>channelA</name>");
|
||||
ac.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2019 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.
|
||||
@@ -16,12 +16,7 @@
|
||||
|
||||
package org.springframework.integration.xml.config;
|
||||
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
@@ -64,22 +59,21 @@ public class XPathSplitterParserTests {
|
||||
|
||||
@Test
|
||||
public void testXpathSplitterConfig() {
|
||||
assertTrue(TestUtils.getPropertyValue(this.xpathSplitter, "createDocuments", Boolean.class));
|
||||
assertFalse(TestUtils.getPropertyValue(this.xpathSplitter, "applySequence", Boolean.class));
|
||||
assertFalse(TestUtils.getPropertyValue(this.xpathSplitter, "iterator", Boolean.class));
|
||||
assertSame(this.outputProperties, TestUtils.getPropertyValue(this.xpathSplitter, "outputProperties"));
|
||||
assertEquals("/orders/order",
|
||||
TestUtils.getPropertyValue(this.xpathSplitter,
|
||||
"xpathExpression.xpathExpression.xpath.m_patternString",
|
||||
String.class));
|
||||
assertEquals(2, TestUtils.getPropertyValue(xpathSplitter, "order"));
|
||||
assertEquals(123L, TestUtils.getPropertyValue(xpathSplitter, "messagingTemplate.sendTimeout"));
|
||||
assertEquals(-1, TestUtils.getPropertyValue(consumer, "phase"));
|
||||
assertFalse(TestUtils.getPropertyValue(consumer, "autoStartup", Boolean.class));
|
||||
assertThat(TestUtils.getPropertyValue(this.xpathSplitter, "createDocuments", Boolean.class)).isTrue();
|
||||
assertThat(TestUtils.getPropertyValue(this.xpathSplitter, "applySequence", Boolean.class)).isFalse();
|
||||
assertThat(TestUtils.getPropertyValue(this.xpathSplitter, "iterator", Boolean.class)).isFalse();
|
||||
assertThat(TestUtils.getPropertyValue(this.xpathSplitter, "outputProperties")).isSameAs(this.outputProperties);
|
||||
assertThat(TestUtils.getPropertyValue(this.xpathSplitter,
|
||||
"xpathExpression.xpathExpression.xpath.m_patternString",
|
||||
String.class)).isEqualTo("/orders/order");
|
||||
assertThat(TestUtils.getPropertyValue(xpathSplitter, "order")).isEqualTo(2);
|
||||
assertThat(TestUtils.getPropertyValue(xpathSplitter, "messagingTemplate.sendTimeout")).isEqualTo(123L);
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "phase")).isEqualTo(-1);
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "autoStartup", Boolean.class)).isFalse();
|
||||
@SuppressWarnings("unchecked")
|
||||
List<SmartLifecycle> list = (List<SmartLifecycle>) TestUtils.getPropertyValue(roleController, "lifecycles",
|
||||
MultiValueMap.class).get("foo");
|
||||
assertThat(list, contains((SmartLifecycle) consumer));
|
||||
assertThat(list).containsExactly((SmartLifecycle) consumer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -16,11 +16,7 @@
|
||||
|
||||
package org.springframework.integration.xml.config;
|
||||
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.List;
|
||||
@@ -98,41 +94,41 @@ public class XPathTransformerParserTests {
|
||||
|
||||
@Test
|
||||
public void testParse() throws Exception {
|
||||
assertEquals(2, TestUtils.getPropertyValue(this.parseOnly, "handler.order"));
|
||||
assertEquals(123L, TestUtils.getPropertyValue(this.parseOnly, "handler.messagingTemplate.sendTimeout"));
|
||||
assertEquals(-1, TestUtils.getPropertyValue(this.parseOnly, "phase"));
|
||||
assertFalse(TestUtils.getPropertyValue(this.parseOnly, "autoStartup", Boolean.class));
|
||||
assertThat(TestUtils.getPropertyValue(this.parseOnly, "handler.order")).isEqualTo(2);
|
||||
assertThat(TestUtils.getPropertyValue(this.parseOnly, "handler.messagingTemplate.sendTimeout")).isEqualTo(123L);
|
||||
assertThat(TestUtils.getPropertyValue(this.parseOnly, "phase")).isEqualTo(-1);
|
||||
assertThat(TestUtils.getPropertyValue(this.parseOnly, "autoStartup", Boolean.class)).isFalse();
|
||||
@SuppressWarnings("unchecked")
|
||||
List<SmartLifecycle> list = (List<SmartLifecycle>) TestUtils.getPropertyValue(roleController, "lifecycles",
|
||||
MultiValueMap.class).get("foo");
|
||||
assertThat(list, contains((SmartLifecycle) this.parseOnly));
|
||||
assertThat(list).containsExactly((SmartLifecycle) this.parseOnly);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stringResultByDefault() {
|
||||
this.defaultInput.send(message);
|
||||
assertEquals("John Doe", output.receive(0).getPayload());
|
||||
assertThat(output.receive(0).getPayload()).isEqualTo("John Doe");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void numberResult() {
|
||||
this.numberInput.send(message);
|
||||
assertEquals(new Double(42), output.receive(0).getPayload());
|
||||
assertThat(output.receive(0).getPayload()).isEqualTo(new Double(42));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void booleanResult() {
|
||||
this.booleanInput.send(message);
|
||||
assertEquals(Boolean.TRUE, output.receive(0).getPayload());
|
||||
assertThat(output.receive(0).getPayload()).isEqualTo(Boolean.TRUE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nodeResult() {
|
||||
this.nodeInput.send(message);
|
||||
Object payload = output.receive(0).getPayload();
|
||||
assertTrue(payload instanceof Node);
|
||||
assertThat(payload instanceof Node).isTrue();
|
||||
Node node = (Node) payload;
|
||||
assertEquals("42", node.getTextContent());
|
||||
assertThat(node.getTextContent()).isEqualTo("42");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -140,27 +136,27 @@ public class XPathTransformerParserTests {
|
||||
public void nodeListResult() {
|
||||
this.nodeListInput.send(message);
|
||||
Object payload = output.receive(0).getPayload();
|
||||
assertTrue(List.class.isAssignableFrom(payload.getClass()));
|
||||
assertThat(List.class.isAssignableFrom(payload.getClass())).isTrue();
|
||||
List<Node> nodeList = (List<Node>) payload;
|
||||
assertEquals(3, nodeList.size());
|
||||
assertThat(nodeList.size()).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nodeMapper() {
|
||||
this.nodeMapperInput.send(message);
|
||||
assertEquals("42-mapped", output.receive(0).getPayload());
|
||||
assertThat(output.receive(0).getPayload()).isEqualTo("42-mapped");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customConverter() {
|
||||
this.customConverterInput.send(message);
|
||||
assertEquals("custom", output.receive(0).getPayload());
|
||||
assertThat(output.receive(0).getPayload()).isEqualTo("custom");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void expressionRef() {
|
||||
this.expressionRefInput.send(message);
|
||||
assertEquals(new Double(84), output.receive(0).getPayload());
|
||||
assertThat(output.receive(0).getPayload()).isEqualTo(new Double(84));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -16,20 +16,14 @@
|
||||
|
||||
package org.springframework.integration.xml.config;
|
||||
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.w3c.dom.Document;
|
||||
@@ -83,15 +77,15 @@ public class XmlPayloadValidatingFilterParserTests {
|
||||
@Test
|
||||
public void testParse() throws Exception {
|
||||
EventDrivenConsumer consumer = (EventDrivenConsumer) ac.getBean("parseOnly");
|
||||
assertEquals(2, TestUtils.getPropertyValue(consumer, "handler.order"));
|
||||
assertEquals(123L, TestUtils.getPropertyValue(consumer, "handler.messagingTemplate.sendTimeout"));
|
||||
assertEquals(-1, TestUtils.getPropertyValue(consumer, "phase"));
|
||||
assertFalse(TestUtils.getPropertyValue(consumer, "autoStartup", Boolean.class));
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "handler.order")).isEqualTo(2);
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "handler.messagingTemplate.sendTimeout")).isEqualTo(123L);
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "phase")).isEqualTo(-1);
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "autoStartup", Boolean.class)).isFalse();
|
||||
SmartLifecycleRoleController roleController = ac.getBean(SmartLifecycleRoleController.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<SmartLifecycle> list = (List<SmartLifecycle>) TestUtils.getPropertyValue(roleController, "lifecycles",
|
||||
MultiValueMap.class).get("foo");
|
||||
assertThat(list, contains((SmartLifecycle) consumer));
|
||||
assertThat(list).containsExactly((SmartLifecycle) consumer);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -101,7 +95,7 @@ public class XmlPayloadValidatingFilterParserTests {
|
||||
PollableChannel validChannel = this.ac.getBean("validOutputChannel", PollableChannel.class);
|
||||
MessageChannel inputChannel = this.ac.getBean("inputChannelA", MessageChannel.class);
|
||||
inputChannel.send(docMessage);
|
||||
assertNotNull(validChannel.receive(100));
|
||||
assertThat(validChannel.receive(100)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -112,8 +106,8 @@ public class XmlPayloadValidatingFilterParserTests {
|
||||
PollableChannel invalidChannel = ac.getBean("invalidOutputChannel", PollableChannel.class);
|
||||
MessageChannel inputChannel = ac.getBean("inputChannelA", MessageChannel.class);
|
||||
inputChannel.send(docMessage);
|
||||
assertNotNull(invalidChannel.receive(100));
|
||||
assertNull(validChannel.receive(100));
|
||||
assertThat(invalidChannel.receive(100)).isNotNull();
|
||||
assertThat(validChannel.receive(100)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -126,13 +120,14 @@ public class XmlPayloadValidatingFilterParserTests {
|
||||
fail("MessageRejectedException expected");
|
||||
}
|
||||
catch (Exception e) {
|
||||
assertThat(e, Matchers.instanceOf(MessageRejectedException.class));
|
||||
assertThat(e).isInstanceOf(MessageRejectedException.class);
|
||||
Throwable cause = e.getCause();
|
||||
assertThat(cause, Matchers.instanceOf(AggregatedXmlMessageValidationException.class));
|
||||
assertThat(cause.getMessage(),
|
||||
Matchers.containsString("Element 'greeting' is a simple type, so it must have no element information item [children]."));
|
||||
assertThat(cause.getMessage(),
|
||||
Matchers.containsString("Element 'greeting' is a simple type, so it cannot have attributes,"));
|
||||
assertThat(cause).isInstanceOf(AggregatedXmlMessageValidationException.class);
|
||||
assertThat(cause.getMessage())
|
||||
.contains(
|
||||
"Element 'greeting' is a simple type, so it must have no element information item [children].");
|
||||
assertThat(cause.getMessage())
|
||||
.contains("Element 'greeting' is a simple type, so it cannot have attributes,");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +138,7 @@ public class XmlPayloadValidatingFilterParserTests {
|
||||
PollableChannel validChannel = ac.getBean("validOutputChannel", PollableChannel.class);
|
||||
MessageChannel inputChannel = ac.getBean("inputChannelC", MessageChannel.class);
|
||||
inputChannel.send(docMessage);
|
||||
assertNotNull(validChannel.receive(100));
|
||||
assertThat(validChannel.receive(100)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -153,7 +148,7 @@ public class XmlPayloadValidatingFilterParserTests {
|
||||
PollableChannel invalidChannel = ac.getBean("invalidOutputChannel", PollableChannel.class);
|
||||
MessageChannel inputChannel = ac.getBean("inputChannelC", MessageChannel.class);
|
||||
inputChannel.send(docMessage);
|
||||
assertNotNull(invalidChannel.receive(100));
|
||||
assertThat(invalidChannel.receive(100)).isNotNull();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -16,18 +16,12 @@
|
||||
|
||||
package org.springframework.integration.xml.config;
|
||||
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.transform.dom.DOMResult;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.w3c.dom.Document;
|
||||
@@ -72,15 +66,15 @@ public class XsltPayloadTransformerParserTests {
|
||||
@Test
|
||||
public void testParse() throws Exception {
|
||||
EventDrivenConsumer consumer = (EventDrivenConsumer) applicationContext.getBean("parseOnly");
|
||||
assertEquals(2, TestUtils.getPropertyValue(consumer, "handler.order"));
|
||||
assertEquals(123L, TestUtils.getPropertyValue(consumer, "handler.messagingTemplate.sendTimeout"));
|
||||
assertEquals(-1, TestUtils.getPropertyValue(consumer, "phase"));
|
||||
assertFalse(TestUtils.getPropertyValue(consumer, "autoStartup", Boolean.class));
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "handler.order")).isEqualTo(2);
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "handler.messagingTemplate.sendTimeout")).isEqualTo(123L);
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "phase")).isEqualTo(-1);
|
||||
assertThat(TestUtils.getPropertyValue(consumer, "autoStartup", Boolean.class)).isFalse();
|
||||
SmartLifecycleRoleController roleController = applicationContext.getBean(SmartLifecycleRoleController.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<SmartLifecycle> list = (List<SmartLifecycle>) TestUtils.getPropertyValue(roleController, "lifecycles",
|
||||
MultiValueMap.class).get("foo");
|
||||
assertThat(list, contains((SmartLifecycle) consumer));
|
||||
assertThat(list).containsExactly((SmartLifecycle) consumer);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -89,11 +83,11 @@ public class XsltPayloadTransformerParserTests {
|
||||
GenericMessage<Object> message = new GenericMessage<Object>(XmlTestUtil.getDomSourceForString(doc));
|
||||
input.send(message);
|
||||
Message<?> result = output.receive(0);
|
||||
assertTrue("Payload was not a DOMResult", result.getPayload() instanceof DOMResult);
|
||||
assertThat(result.getPayload() instanceof DOMResult).as("Payload was not a DOMResult").isTrue();
|
||||
Document doc = (Document) ((DOMResult) result.getPayload()).getNode();
|
||||
assertEquals("Wrong payload", "test", doc.getDocumentElement().getTextContent());
|
||||
assertNotNull(TestUtils.getPropertyValue(applicationContext.getBean("xsltTransformerWithResource.handler"),
|
||||
"transformer.evaluationContext.beanResolver"));
|
||||
assertThat(doc.getDocumentElement().getTextContent()).as("Wrong payload").isEqualTo("test");
|
||||
assertThat(TestUtils.getPropertyValue(applicationContext.getBean("xsltTransformerWithResource.handler"),
|
||||
"transformer.evaluationContext.beanResolver")).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -102,9 +96,9 @@ public class XsltPayloadTransformerParserTests {
|
||||
GenericMessage<Object> message = new GenericMessage<Object>(XmlTestUtil.getDomSourceForString(doc));
|
||||
input.send(message);
|
||||
Message<?> result = output.receive(0);
|
||||
assertTrue("Payload was not a DOMResult", result.getPayload() instanceof DOMResult);
|
||||
assertThat(result.getPayload() instanceof DOMResult).as("Payload was not a DOMResult").isTrue();
|
||||
Document doc = (Document) ((DOMResult) result.getPayload()).getNode();
|
||||
assertEquals("Wrong payload", "test", doc.getDocumentElement().getTextContent());
|
||||
assertThat(doc.getDocumentElement().getTextContent()).as("Wrong payload").isEqualTo("test");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -113,9 +107,9 @@ public class XsltPayloadTransformerParserTests {
|
||||
GenericMessage<Object> message = new GenericMessage<Object>(XmlTestUtil.getDomSourceForString(doc));
|
||||
input.send(message);
|
||||
Message<?> result = output.receive(0);
|
||||
assertEquals("Wrong payload type", String.class, result.getPayload().getClass());
|
||||
assertThat(result.getPayload().getClass()).as("Wrong payload type").isEqualTo(String.class);
|
||||
String strResult = (String) result.getPayload();
|
||||
assertEquals("Wrong payload", "testReturn", strResult);
|
||||
assertThat(strResult).as("Wrong payload").isEqualTo("testReturn");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -124,7 +118,7 @@ public class XsltPayloadTransformerParserTests {
|
||||
GenericMessage<Object> message = new GenericMessage<Object>(XmlTestUtil.getDomSourceForString(doc));
|
||||
input.send(message);
|
||||
Message<?> result = output.receive(0);
|
||||
assertTrue("Payload was not a StubStringResult", result.getPayload() instanceof StubStringResult);
|
||||
assertThat(result.getPayload() instanceof StubStringResult).as("Payload was not a StubStringResult").isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -133,7 +127,7 @@ public class XsltPayloadTransformerParserTests {
|
||||
GenericMessage<Object> message = new GenericMessage<Object>(XmlTestUtil.getDomSourceForString(doc));
|
||||
input.send(message);
|
||||
Message<?> result = output.receive(0);
|
||||
assertTrue("Payload was not a StringResult", result.getPayload() instanceof StringResult);
|
||||
assertThat(result.getPayload() instanceof StringResult).as("Payload was not a StringResult").isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -143,9 +137,9 @@ public class XsltPayloadTransformerParserTests {
|
||||
Message<?> message = MessageBuilder.withPayload(XmlTestUtil.getDocumentForString(this.doc)).build();
|
||||
input.send(message);
|
||||
Message<?> resultMessage = output.receive();
|
||||
Assert.assertEquals("Wrong payload type", StringResult.class, resultMessage.getPayload().getClass());
|
||||
assertThat(resultMessage.getPayload().getClass()).as("Wrong payload type").isEqualTo(StringResult.class);
|
||||
String payload = resultMessage.getPayload().toString();
|
||||
Assert.assertTrue(payload.contains("<bob>test</bob>"));
|
||||
assertThat(payload.contains("<bob>test</bob>")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -154,9 +148,9 @@ public class XsltPayloadTransformerParserTests {
|
||||
Message<?> message = MessageBuilder.withPayload(this.doc).build();
|
||||
input.send(message);
|
||||
Message<?> resultMessage = output.receive();
|
||||
Assert.assertEquals("Wrong payload type", DOMResult.class, resultMessage.getPayload().getClass());
|
||||
assertThat(resultMessage.getPayload().getClass()).as("Wrong payload type").isEqualTo(DOMResult.class);
|
||||
Document payload = (Document) ((DOMResult) resultMessage.getPayload()).getNode();
|
||||
Assert.assertTrue(XmlTestUtil.docToString(payload).contains("<bob>test</bob>"));
|
||||
assertThat(XmlTestUtil.docToString(payload).contains("<bob>test</bob>")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -165,10 +159,11 @@ public class XsltPayloadTransformerParserTests {
|
||||
Message<?> message = MessageBuilder.withPayload(XmlTestUtil.getDocumentForString(this.doc)).build();
|
||||
input.send(message);
|
||||
Message<?> resultMessage = output.receive();
|
||||
Assert.assertEquals("Wrong payload type", CustomTestResultFactory.FixedStringResult.class, resultMessage
|
||||
.getPayload().getClass());
|
||||
assertThat(resultMessage
|
||||
.getPayload().getClass()).as("Wrong payload type")
|
||||
.isEqualTo(CustomTestResultFactory.FixedStringResult.class);
|
||||
String payload = resultMessage.getPayload().toString();
|
||||
Assert.assertTrue(payload.contains("fixedStringForTesting"));
|
||||
assertThat(payload.contains("fixedStringForTesting")).isTrue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.xml.router;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -42,8 +42,8 @@ public class XPathRouterTests {
|
||||
XPathExpression expression = XPathExpressionFactory.createXPathExpression("/doc/@type");
|
||||
XPathRouter router = new XPathRouter(expression);
|
||||
Object[] channelNames = router.getChannelKeys(new GenericMessage(doc)).toArray();
|
||||
assertEquals("Wrong number of channels returned", 1, channelNames.length);
|
||||
assertEquals("Wrong channel name", "one", channelNames[0]);
|
||||
assertThat(channelNames.length).as("Wrong number of channels returned").isEqualTo(1);
|
||||
assertThat(channelNames[0]).as("Wrong channel name").isEqualTo("one");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -54,8 +54,8 @@ public class XPathRouterTests {
|
||||
XPathRouter router = new XPathRouter(expression);
|
||||
router.setEvaluateAsString(true);
|
||||
Object[] channelNames = router.getChannelKeys(new GenericMessage(doc)).toArray();
|
||||
assertEquals("Wrong number of channels returned", 1, channelNames.length);
|
||||
assertEquals("Wrong channel name", "one", channelNames[0]);
|
||||
assertThat(channelNames.length).as("Wrong number of channels returned").isEqualTo(1);
|
||||
assertThat(channelNames[0]).as("Wrong channel name").isEqualTo("one");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -66,8 +66,8 @@ public class XPathRouterTests {
|
||||
XPathRouter router = new XPathRouter(expression);
|
||||
router.setEvaluateAsString(true);
|
||||
Object[] channelNames = router.getChannelKeys(new GenericMessage(doc)).toArray();
|
||||
assertEquals("Wrong number of channels returned", 1, channelNames.length);
|
||||
assertEquals("Wrong channel name", "doc", channelNames[0]);
|
||||
assertThat(channelNames.length).as("Wrong number of channels returned").isEqualTo(1);
|
||||
assertThat(channelNames[0]).as("Wrong channel name").isEqualTo("doc");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -77,9 +77,9 @@ public class XPathRouterTests {
|
||||
XPathExpression expression = XPathExpressionFactory.createXPathExpression("/doc/book");
|
||||
XPathRouter router = new XPathRouter(expression);
|
||||
Object[] channelNames = router.getChannelKeys(new GenericMessage(doc)).toArray();
|
||||
assertEquals("Wrong number of channels returned", 2, channelNames.length);
|
||||
assertEquals("Wrong channel name", "bOne", channelNames[0]);
|
||||
assertEquals("Wrong channel name", "bTwo", channelNames[1]);
|
||||
assertThat(channelNames.length).as("Wrong number of channels returned").isEqualTo(2);
|
||||
assertThat(channelNames[0]).as("Wrong channel name").isEqualTo("bOne");
|
||||
assertThat(channelNames[1]).as("Wrong channel name").isEqualTo("bTwo");
|
||||
}
|
||||
|
||||
|
||||
@@ -97,8 +97,8 @@ public class XPathRouterTests {
|
||||
XPathRouter router = new XPathRouter(expression);
|
||||
router.setEvaluateAsString(true);
|
||||
Object[] channelNames = router.getChannelKeys(new GenericMessage("<doc type=\"one\"><book>bOne</book><book>bTwo</book></doc>")).toArray();
|
||||
assertEquals("Wrong number of channels returned", 1, channelNames.length);
|
||||
assertEquals("Wrong channel name", "bOne", channelNames[0]);
|
||||
assertThat(channelNames.length).as("Wrong number of channels returned").isEqualTo(1);
|
||||
assertThat(channelNames[0]).as("Wrong channel name").isEqualTo("bOne");
|
||||
}
|
||||
|
||||
@Test(expected = MessagingException.class)
|
||||
@@ -113,8 +113,8 @@ public class XPathRouterTests {
|
||||
XPathRouter router = new XPathRouter("./three/text()");
|
||||
Document testDocument = XmlTestUtil.getDocumentForString("<one><two><three>bob</three><three>dave</three></two></one>");
|
||||
Object[] channelNames = router.getChannelKeys(new GenericMessage<Node>(testDocument.getElementsByTagName("two").item(0))).toArray();
|
||||
assertEquals("bob", channelNames[0]);
|
||||
assertEquals("dave", channelNames[1]);
|
||||
assertThat(channelNames[0]).isEqualTo("bob");
|
||||
assertThat(channelNames[1]).isEqualTo("dave");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -123,7 +123,7 @@ public class XPathRouterTests {
|
||||
XPathExpression expression = XPathExpressionFactory.createXPathExpression("/doc/@type");
|
||||
XPathRouter router = new XPathRouter(expression);
|
||||
Object channelName = router.getChannelKeys(new GenericMessage<Document>(doc)).toArray()[0];
|
||||
assertEquals("Wrong channel name", "one", channelName);
|
||||
assertThat(channelName).as("Wrong channel name").isEqualTo("one");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -131,7 +131,7 @@ public class XPathRouterTests {
|
||||
XPathExpression expression = XPathExpressionFactory.createXPathExpression("/doc/@type");
|
||||
XPathRouter router = new XPathRouter(expression);
|
||||
Object channelName = router.getChannelKeys(new GenericMessage<String>("<doc type='one' />")).toArray()[0];
|
||||
assertEquals("Wrong channel name", "one", channelName);
|
||||
assertThat(channelName).as("Wrong channel name").isEqualTo("one");
|
||||
}
|
||||
|
||||
@Test(expected = MessagingException.class)
|
||||
@@ -147,7 +147,7 @@ public class XPathRouterTests {
|
||||
Document testDocument = XmlTestUtil.getDocumentForString("<one><two><three>bob</three></two></one>");
|
||||
Object[] channelNames = router.getChannelKeys(new GenericMessage<Node>(testDocument
|
||||
.getElementsByTagName("two").item(0))).toArray();
|
||||
assertEquals("bob", channelNames[0]);
|
||||
assertThat(channelNames[0]).isEqualTo("bob");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -156,7 +156,7 @@ public class XPathRouterTests {
|
||||
XPathExpression expression = XPathExpressionFactory.createXPathExpression("/somethingelse/@type");
|
||||
XPathRouter router = new XPathRouter(expression);
|
||||
List<Object> channelNames = router.getChannelKeys(new GenericMessage<Document>(doc));
|
||||
assertEquals(0, channelNames.size());
|
||||
assertThat(channelNames.size()).isEqualTo(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.integration.xml.selector;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.w3c.dom.Document;
|
||||
@@ -36,31 +35,37 @@ public class BooleanTestXpathMessageSelectorTests {
|
||||
@Test
|
||||
public void testWithSimpleString() {
|
||||
BooleanTestXPathMessageSelector selector = new BooleanTestXPathMessageSelector("boolean(/one/two)");
|
||||
assertTrue(selector.accept(new GenericMessage<String>("<one><two/></one>")));
|
||||
assertFalse(selector.accept(new GenericMessage<String>("<one><three/></one>")));
|
||||
assertThat(selector.accept(new GenericMessage<String>("<one><two/></one>"))).isTrue();
|
||||
assertThat(selector.accept(new GenericMessage<String>("<one><three/></one>"))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithDocument() throws Exception {
|
||||
BooleanTestXPathMessageSelector selector = new BooleanTestXPathMessageSelector("boolean(/one/two)");
|
||||
assertTrue(selector.accept(new GenericMessage<Document>(XmlTestUtil.getDocumentForString("<one><two/></one>"))));
|
||||
assertFalse(selector.accept(new GenericMessage<Document>(XmlTestUtil
|
||||
.getDocumentForString("<one><three/></one>"))));
|
||||
assertThat(selector.accept(new GenericMessage<Document>(XmlTestUtil.getDocumentForString("<one><two/></one>"))))
|
||||
.isTrue();
|
||||
assertThat(selector.accept(new GenericMessage<Document>(XmlTestUtil
|
||||
.getDocumentForString("<one><three/></one>")))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithNamespace() {
|
||||
BooleanTestXPathMessageSelector selector = new BooleanTestXPathMessageSelector("boolean(/ns1:one/ns1:two)", "ns1", "www.example.org");
|
||||
assertTrue(selector.accept(new GenericMessage<String>("<ns1:one xmlns:ns1='www.example.org'><ns1:two/></ns1:one>")));
|
||||
assertFalse(selector.accept(new GenericMessage<String>("<ns2:one xmlns:ns2='www.example2.org'><ns1:two xmlns:ns1='www.example.org' /></ns2:one>")));
|
||||
assertThat(selector
|
||||
.accept(new GenericMessage<String>("<ns1:one xmlns:ns1='www.example.org'><ns1:two/></ns1:one>")))
|
||||
.isTrue();
|
||||
assertThat(selector
|
||||
.accept(new GenericMessage<String>("<ns2:one xmlns:ns2='www.example2.org'><ns1:two xmlns:ns1='www" +
|
||||
".example.org' /></ns2:one>")))
|
||||
.isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringWithXPathExpressionProvided() {
|
||||
XPathExpression xpathExpression = XPathExpressionFactory.createXPathExpression("boolean(/one/two)");
|
||||
BooleanTestXPathMessageSelector selector = new BooleanTestXPathMessageSelector(xpathExpression);
|
||||
assertTrue(selector.accept(new GenericMessage<String>("<one><two/></one>")));
|
||||
assertFalse(selector.accept(new GenericMessage<String>("<one><three/></one>")));
|
||||
assertThat(selector.accept(new GenericMessage<String>("<one><two/></one>"))).isTrue();
|
||||
assertThat(selector.accept(new GenericMessage<String>("<one><three/></one>"))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -68,8 +73,10 @@ public class BooleanTestXpathMessageSelectorTests {
|
||||
XPathExpression xpathExpression = XPathExpressionFactory.createXPathExpression("boolean(./three)");
|
||||
BooleanTestXPathMessageSelector selector = new BooleanTestXPathMessageSelector(xpathExpression);
|
||||
Document testDocument = XmlTestUtil.getDocumentForString("<one><two><three/></two></one>");
|
||||
assertTrue(selector.accept(new GenericMessage<Node>(testDocument.getElementsByTagName("two").item(0))));
|
||||
assertFalse(selector.accept(new GenericMessage<Node>(testDocument.getElementsByTagName("three").item(0))));
|
||||
assertThat(selector.accept(new GenericMessage<Node>(testDocument.getElementsByTagName("two").item(0))))
|
||||
.isTrue();
|
||||
assertThat(selector.accept(new GenericMessage<Node>(testDocument.getElementsByTagName("three").item(0))))
|
||||
.isFalse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.integration.xml.selector;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -31,32 +30,39 @@ public class StringValueTestXPathMessageSelectorTests {
|
||||
@Test
|
||||
public void testMatchWithSimpleString() {
|
||||
StringValueTestXPathMessageSelector selector = new StringValueTestXPathMessageSelector("/one/two", "red");
|
||||
assertTrue(selector.accept(new GenericMessage<String>("<one><two>red</two></one>")));
|
||||
assertThat(selector.accept(new GenericMessage<String>("<one><two>red</two></one>"))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoMatchWithSimpleString() {
|
||||
StringValueTestXPathMessageSelector selector = new StringValueTestXPathMessageSelector("/one/two", "red");
|
||||
assertFalse(selector.accept(new GenericMessage<String>("<one><two>yellow</two></one>")));
|
||||
assertThat(selector.accept(new GenericMessage<String>("<one><two>yellow</two></one>"))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchWithSimpleStringAndNamespace() {
|
||||
StringValueTestXPathMessageSelector selector = new StringValueTestXPathMessageSelector("/ns1:one/ns1:two", "ns1", "www.example.org", "red");
|
||||
assertTrue(selector.accept(new GenericMessage<String>("<ns1:one xmlns:ns1='www.example.org'><ns1:two>red</ns1:two></ns1:one>")));
|
||||
assertThat(selector
|
||||
.accept(new GenericMessage<String>("<ns1:one xmlns:ns1='www.example" +
|
||||
".org'><ns1:two>red</ns1:two></ns1:one>")))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCaseSensitiveByDefault() {
|
||||
StringValueTestXPathMessageSelector selector = new StringValueTestXPathMessageSelector("/ns1:one/ns1:two", "ns1", "www.example.org", "red");
|
||||
assertFalse(selector.accept(new GenericMessage<String>("<ns1:one xmlns:ns1='www.example.org'><ns1:two>RED</ns1:two></ns1:one>")));
|
||||
assertThat(selector
|
||||
.accept(new GenericMessage<String>("<ns1:one xmlns:ns1='www.example.org'><ns1:two>RED</ns1:two></ns1:one>")))
|
||||
.isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotCaseSensitive() {
|
||||
StringValueTestXPathMessageSelector selector = new StringValueTestXPathMessageSelector("/ns1:one/ns1:two", "ns1", "www.example.org", "red");
|
||||
selector.setCaseSensitive(false);
|
||||
assertTrue(selector.accept(new GenericMessage<String>("<ns1:one xmlns:ns1='www.example.org'><ns1:two>RED</ns1:two></ns1:one>")));
|
||||
assertThat(selector
|
||||
.accept(new GenericMessage<String>("<ns1:one xmlns:ns1='www.example.org'><ns1:two>RED</ns1:two></ns1:one>")))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.xml.selector;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class XmlValidatingMessageSelectorTests {
|
||||
context = new ClassPathXmlApplicationContext("XmlValidatingMessageSelectorTests-context.xml", this.getClass());
|
||||
}
|
||||
catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("java.lang.IllegalArgumentException: No enum constant"));
|
||||
assertThat(e.getMessage().contains("java.lang.IllegalArgumentException: No enum constant")).isTrue();
|
||||
}
|
||||
finally {
|
||||
if (context != null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -16,11 +16,7 @@
|
||||
|
||||
package org.springframework.integration.xml.splitter;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -62,11 +58,11 @@ public class XPathMessageSplitterTests {
|
||||
Document doc = XmlTestUtil.getDocumentForString("<orders><order>one</order><order>two</order><order>three</order></orders>");
|
||||
this.splitter.handleMessage(new GenericMessage<>(doc));
|
||||
List<Message<?>> docMessages = this.replyChannel.clear();
|
||||
assertEquals("Wrong number of messages", 3, docMessages.size());
|
||||
assertThat(docMessages.size()).as("Wrong number of messages").isEqualTo(3);
|
||||
for (Message<?> message : docMessages) {
|
||||
assertThat(message.getPayload(), instanceOf(Node.class));
|
||||
assertThat(message.getPayload(), not(instanceOf(Document.class)));
|
||||
assertThat(new IntegrationMessageHeaderAccessor(message).getSequenceSize(), greaterThan(0));
|
||||
assertThat(message.getPayload()).isInstanceOf(Node.class);
|
||||
assertThat(message.getPayload()).isNotInstanceOf(Document.class);
|
||||
assertThat(new IntegrationMessageHeaderAccessor(message).getSequenceSize()).isGreaterThan(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,12 +78,12 @@ public class XPathMessageSplitterTests {
|
||||
Document doc = XmlTestUtil.getDocumentForString("<orders><order>one</order><order>two</order><order>three</order></orders>");
|
||||
this.splitter.handleMessage(new GenericMessage<>(doc));
|
||||
List<Message<?>> docMessages = this.replyChannel.clear();
|
||||
assertEquals("Wrong number of messages", 3, docMessages.size());
|
||||
assertThat(docMessages.size()).as("Wrong number of messages").isEqualTo(3);
|
||||
for (Message<?> message : docMessages) {
|
||||
assertThat(message.getPayload(), instanceOf(Document.class));
|
||||
assertThat(message.getPayload()).isInstanceOf(Document.class);
|
||||
Document docPayload = (Document) message.getPayload();
|
||||
assertEquals("Wrong root element name", "order", docPayload.getDocumentElement().getLocalName());
|
||||
assertThat(new IntegrationMessageHeaderAccessor(message).getSequenceSize(), greaterThan(0));
|
||||
assertThat(docPayload.getDocumentElement().getLocalName()).as("Wrong root element name").isEqualTo("order");
|
||||
assertThat(new IntegrationMessageHeaderAccessor(message).getSequenceSize()).isGreaterThan(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,10 +92,10 @@ public class XPathMessageSplitterTests {
|
||||
String payload = "<orders><order>one</order><order>two</order><order>three</order></orders>";
|
||||
this.splitter.handleMessage(new GenericMessage<>(payload));
|
||||
List<Message<?>> docMessages = this.replyChannel.clear();
|
||||
assertEquals("Wrong number of messages", 3, docMessages.size());
|
||||
assertThat(docMessages.size()).as("Wrong number of messages").isEqualTo(3);
|
||||
for (Message<?> message : docMessages) {
|
||||
assertThat(message.getPayload(), instanceOf(String.class));
|
||||
assertThat(new IntegrationMessageHeaderAccessor(message).getSequenceSize(), greaterThan(0));
|
||||
assertThat(message.getPayload()).isInstanceOf(String.class);
|
||||
assertThat(new IntegrationMessageHeaderAccessor(message).getSequenceSize()).isGreaterThan(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.integration.xml.transformer;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -47,9 +46,9 @@ public class MarshallingTransformerTests {
|
||||
transformer.setResultFactory(new StringResultFactory());
|
||||
Message<?> resultMessage = transformer.transform(new GenericMessage<String>("world"));
|
||||
Object resultPayload = resultMessage.getPayload();
|
||||
assertEquals(StringResult.class, resultPayload.getClass());
|
||||
assertEquals("hello world", resultPayload.toString());
|
||||
assertEquals("world", marshaller.payloads.get(0));
|
||||
assertThat(resultPayload.getClass()).isEqualTo(StringResult.class);
|
||||
assertThat(resultPayload.toString()).isEqualTo("hello world");
|
||||
assertThat(marshaller.payloads.get(0)).isEqualTo("world");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -58,8 +57,8 @@ public class MarshallingTransformerTests {
|
||||
MarshallingTransformer transformer = new MarshallingTransformer(marshaller);
|
||||
Message<?> resultMessage = transformer.transform(new GenericMessage<String>("world"));
|
||||
Object resultPayload = resultMessage.getPayload();
|
||||
assertEquals(DOMResult.class, resultPayload.getClass());
|
||||
assertEquals("world", marshaller.payloads.get(0));
|
||||
assertThat(resultPayload.getClass()).isEqualTo(DOMResult.class);
|
||||
assertThat(marshaller.payloads.get(0)).isEqualTo("world");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -69,9 +68,9 @@ public class MarshallingTransformerTests {
|
||||
transformer.setExtractPayload(false);
|
||||
Message<?> message = new GenericMessage<String>("test");
|
||||
transformer.transform(message);
|
||||
assertEquals(0, marshaller.payloads.size());
|
||||
assertEquals(1, marshaller.messages.size());
|
||||
assertSame(message, marshaller.messages.get(0));
|
||||
assertThat(marshaller.payloads.size()).isEqualTo(0);
|
||||
assertThat(marshaller.messages.size()).isEqualTo(1);
|
||||
assertThat(marshaller.messages.get(0)).isSameAs(message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.integration.xml.transformer;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import javax.xml.transform.dom.DOMResult;
|
||||
import javax.xml.transform.sax.SAXResult;
|
||||
@@ -50,18 +49,18 @@ public class ResultToDocumentTransformerTests {
|
||||
public void testWithDomResult() throws Exception {
|
||||
DOMResult result = XmlTestUtil.getDomResultForString(startDoc);
|
||||
Object transformed = resToDocTransformer.transformResult(result);
|
||||
assertTrue("Wrong transformed type expected Document", transformed instanceof Document);
|
||||
assertThat(transformed instanceof Document).as("Wrong transformed type expected Document").isTrue();
|
||||
Document doc = (Document) transformed;
|
||||
assertEquals("Wrong root element name", "order", doc.getDocumentElement().getNodeName());
|
||||
assertThat(doc.getDocumentElement().getNodeName()).as("Wrong root element name").isEqualTo("order");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithStringResult() throws Exception {
|
||||
StringResult result = XmlTestUtil.getStringResultForString(startDoc);
|
||||
Object transformed = resToDocTransformer.transformResult(result);
|
||||
assertTrue("Wrong transformed type expected Document", transformed instanceof Document);
|
||||
assertThat(transformed instanceof Document).as("Wrong transformed type expected Document").isTrue();
|
||||
Document doc = (Document) transformed;
|
||||
assertEquals("Wrong root element name", "order", doc.getDocumentElement().getNodeName());
|
||||
assertThat(doc.getDocumentElement().getNodeName()).as("Wrong root element name").isEqualTo("order");
|
||||
}
|
||||
|
||||
@Test(expected = MessagingException.class)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.integration.xml.transformer;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -45,8 +44,8 @@ public class UnmarshallingTransformerTests {
|
||||
Unmarshaller unmarshaller = new TestUnmarshaller(false);
|
||||
UnmarshallingTransformer transformer = new UnmarshallingTransformer(unmarshaller);
|
||||
Object transformed = transformer.transformPayload("world".getBytes());
|
||||
assertEquals(String.class, transformed.getClass());
|
||||
assertEquals("hello world", transformed.toString());
|
||||
assertThat(transformed.getClass()).isEqualTo(String.class);
|
||||
assertThat(transformed.toString()).isEqualTo("hello world");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -54,8 +53,8 @@ public class UnmarshallingTransformerTests {
|
||||
Unmarshaller unmarshaller = new TestUnmarshaller(false);
|
||||
UnmarshallingTransformer transformer = new UnmarshallingTransformer(unmarshaller);
|
||||
Object transformed = transformer.transformPayload(new StringSource("world"));
|
||||
assertEquals(String.class, transformed.getClass());
|
||||
assertEquals("hello world", transformed.toString());
|
||||
assertThat(transformed.getClass()).isEqualTo(String.class);
|
||||
assertThat(transformed.toString()).isEqualTo("hello world");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -63,8 +62,8 @@ public class UnmarshallingTransformerTests {
|
||||
Unmarshaller unmarshaller = new TestUnmarshaller(true);
|
||||
UnmarshallingTransformer transformer = new UnmarshallingTransformer(unmarshaller);
|
||||
Object transformed = transformer.transformPayload(new StringSource("foo"));
|
||||
assertEquals(GenericMessage.class, transformed.getClass());
|
||||
assertEquals("message: foo", ((Message<?>) transformed).getPayload());
|
||||
assertThat(transformed.getClass()).isEqualTo(GenericMessage.class);
|
||||
assertThat(((Message<?>) transformed).getPayload()).isEqualTo("message: foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -72,8 +71,8 @@ public class UnmarshallingTransformerTests {
|
||||
Unmarshaller unmarshaller = new TestUnmarshaller(true);
|
||||
UnmarshallingTransformer transformer = new UnmarshallingTransformer(unmarshaller);
|
||||
Message<?> result = transformer.transform(MessageBuilder.withPayload(new StringSource("bar")).build());
|
||||
assertNotNull(result);
|
||||
assertEquals("message: bar", result.getPayload());
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getPayload()).isEqualTo("message: bar");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -16,9 +16,7 @@
|
||||
|
||||
package org.springframework.integration.xml.transformer;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -50,8 +48,8 @@ public class XPathHeaderEnricherTests {
|
||||
XPathHeaderEnricher enricher = new XPathHeaderEnricher(expressionMap);
|
||||
Message<?> result = enricher.transform(MessageBuilder.withPayload(docAsString).build());
|
||||
MessageHeaders headers = result.getHeaders();
|
||||
assertEquals("Wrong value for element one expression", "1", headers.get("one"));
|
||||
assertEquals("Wrong value for element two expression", "2", headers.get("two"));
|
||||
assertThat(headers.get("one")).as("Wrong value for element one expression").isEqualTo("1");
|
||||
assertThat(headers.get("two")).as("Wrong value for element two expression").isEqualTo("2");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -66,7 +64,8 @@ public class XPathHeaderEnricherTests {
|
||||
XPathHeaderEnricher enricher = new XPathHeaderEnricher(expressionMap);
|
||||
Message<?> result = enricher.transform(MessageBuilder.withPayload(docAsString).build());
|
||||
MessageHeaders headers = result.getHeaders();
|
||||
assertEquals("Wrong value for element one expression", TimeZone.getTimeZone("America/New_York"), headers.get("one"));
|
||||
assertThat(headers.get("one")).as("Wrong value for element one expression")
|
||||
.isEqualTo(TimeZone.getTimeZone("America/New_York"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,7 +77,7 @@ public class XPathHeaderEnricherTests {
|
||||
XPathHeaderEnricher enricher = new XPathHeaderEnricher(expressionMap);
|
||||
Message<?> result = enricher.transform(MessageBuilder.withPayload(docAsString).build());
|
||||
MessageHeaders headers = result.getHeaders();
|
||||
assertNull("value set for two when result was null", headers.get("two"));
|
||||
assertThat(headers.get("two")).as("value set for two when result was null").isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -92,8 +91,8 @@ public class XPathHeaderEnricherTests {
|
||||
enricher.setDefaultOverwrite(true);
|
||||
Message<?> result = enricher.transform(MessageBuilder.withPayload(docAsString).setHeader("two", "x").build());
|
||||
MessageHeaders headers = result.getHeaders();
|
||||
assertNull(headers.get("two"));
|
||||
assertFalse(headers.containsKey("two"));
|
||||
assertThat(headers.get("two")).isNull();
|
||||
assertThat(headers.containsKey("two")).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -113,8 +112,8 @@ public class XPathHeaderEnricherTests {
|
||||
XPathHeaderEnricher enricher = new XPathHeaderEnricher(expressionMap);
|
||||
Message<?> result = enricher.transform(MessageBuilder.withPayload(docAsString).build());
|
||||
MessageHeaders headers = result.getHeaders();
|
||||
assertEquals("Wrong value for element one expression", "1", headers.get("one"));
|
||||
assertEquals("Wrong value for element two expression", 2.0, headers.get("two"));
|
||||
assertThat(headers.get("one")).as("Wrong value for element one expression").isEqualTo("1");
|
||||
assertThat(headers.get("two")).as("Wrong value for element two expression").isEqualTo(2.0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.integration.xml.transformer;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.List;
|
||||
@@ -61,7 +60,7 @@ public class XPathTransformerTests {
|
||||
public void stringResultTypeByDefault() throws Exception {
|
||||
XPathTransformer transformer = new XPathTransformer("/parent/child/@name");
|
||||
Object result = transformer.doTransform(message);
|
||||
assertEquals("test", result);
|
||||
assertThat(result).isEqualTo("test");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -69,7 +68,7 @@ public class XPathTransformerTests {
|
||||
XPathExpression expression = XPathExpressionFactory.createXPathExpression("/parent/child/@name");
|
||||
XPathTransformer transformer = new XPathTransformer(expression);
|
||||
Object result = transformer.doTransform(message);
|
||||
assertEquals("test", result);
|
||||
assertThat(result).isEqualTo("test");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -77,7 +76,7 @@ public class XPathTransformerTests {
|
||||
XPathTransformer transformer = new XPathTransformer("/parent/child/@age");
|
||||
transformer.setEvaluationType(XPathEvaluationType.NUMBER_RESULT);
|
||||
Object result = transformer.doTransform(message);
|
||||
assertEquals(new Double(42), result);
|
||||
assertThat(result).isEqualTo(new Double(42));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -85,7 +84,7 @@ public class XPathTransformerTests {
|
||||
XPathTransformer transformer = new XPathTransformer("/parent/child/@married = 'true'");
|
||||
transformer.setEvaluationType(XPathEvaluationType.BOOLEAN_RESULT);
|
||||
Object result = transformer.doTransform(message);
|
||||
assertEquals(Boolean.TRUE, result);
|
||||
assertThat(result).isEqualTo(Boolean.TRUE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -93,12 +92,12 @@ public class XPathTransformerTests {
|
||||
XPathTransformer transformer = new XPathTransformer("/parent/child");
|
||||
transformer.setEvaluationType(XPathEvaluationType.NODE_RESULT);
|
||||
Object result = transformer.doTransform(message);
|
||||
assertTrue(result instanceof Node);
|
||||
assertThat(result instanceof Node).isTrue();
|
||||
Node node = (Node) result;
|
||||
assertEquals("child", node.getLocalName());
|
||||
assertEquals("test", node.getAttributes().getNamedItem("name").getTextContent());
|
||||
assertEquals("42", node.getAttributes().getNamedItem("age").getTextContent());
|
||||
assertEquals("true", node.getAttributes().getNamedItem("married").getTextContent());
|
||||
assertThat(node.getLocalName()).isEqualTo("child");
|
||||
assertThat(node.getAttributes().getNamedItem("name").getTextContent()).isEqualTo("test");
|
||||
assertThat(node.getAttributes().getNamedItem("age").getTextContent()).isEqualTo("42");
|
||||
assertThat(node.getAttributes().getNamedItem("married").getTextContent()).isEqualTo("true");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -109,15 +108,15 @@ public class XPathTransformerTests {
|
||||
Message<?> message = MessageBuilder.withPayload(
|
||||
"<parent><child name='foo'/><child name='bar'/></parent>").build();
|
||||
Object result = transformer.doTransform(message);
|
||||
assertTrue(List.class.isAssignableFrom(result.getClass()));
|
||||
assertThat(List.class.isAssignableFrom(result.getClass())).isTrue();
|
||||
List<Node> nodeList = (List<Node>) result;
|
||||
assertEquals(2, nodeList.size());
|
||||
assertThat(nodeList.size()).isEqualTo(2);
|
||||
Node node1 = nodeList.get(0);
|
||||
Node node2 = nodeList.get(1);
|
||||
assertEquals("child", node1.getLocalName());
|
||||
assertEquals("foo", node1.getAttributes().getNamedItem("name").getTextContent());
|
||||
assertEquals("child", node2.getLocalName());
|
||||
assertEquals("bar", node2.getAttributes().getNamedItem("name").getTextContent());
|
||||
assertThat(node1.getLocalName()).isEqualTo("child");
|
||||
assertThat(node1.getAttributes().getNamedItem("name").getTextContent()).isEqualTo("foo");
|
||||
assertThat(node2.getLocalName()).isEqualTo("child");
|
||||
assertThat(node2.getAttributes().getNamedItem("name").getTextContent()).isEqualTo("bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -125,7 +124,7 @@ public class XPathTransformerTests {
|
||||
XPathTransformer transformer = new XPathTransformer("/parent/child/@name");
|
||||
transformer.setNodeMapper(new TestNodeMapper());
|
||||
Object result = transformer.doTransform(message);
|
||||
assertEquals("test-mapped", result);
|
||||
assertThat(result).isEqualTo("test-mapped");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -133,7 +132,7 @@ public class XPathTransformerTests {
|
||||
XPathTransformer transformer = new XPathTransformer("/test/@type");
|
||||
transformer.setConverter(new TestXmlPayloadConverter());
|
||||
Object result = transformer.doTransform(message);
|
||||
assertEquals("custom", result);
|
||||
assertThat(result).isEqualTo("custom");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -16,10 +16,7 @@
|
||||
|
||||
package org.springframework.integration.xml.transformer;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
@@ -69,13 +66,13 @@ public class XsltTransformerTests {
|
||||
input.send(message);
|
||||
Message<?> resultMessage = output.receive();
|
||||
MessageHistory history = MessageHistory.read(resultMessage);
|
||||
assertNotNull(history);
|
||||
assertThat(history).isNotNull();
|
||||
Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "paramHeadersWithStartWildCharacter", 0);
|
||||
assertNotNull(componentHistoryRecord);
|
||||
assertEquals("xml:xslt-transformer", componentHistoryRecord.get("type"));
|
||||
assertEquals("Wrong payload type", String.class, resultMessage.getPayload().getClass());
|
||||
assertTrue(((String) resultMessage.getPayload()).contains("testParamValue"));
|
||||
assertFalse(((String) resultMessage.getPayload()).contains("FOO"));
|
||||
assertThat(componentHistoryRecord).isNotNull();
|
||||
assertThat(componentHistoryRecord.get("type")).isEqualTo("xml:xslt-transformer");
|
||||
assertThat(resultMessage.getPayload().getClass()).as("Wrong payload type").isEqualTo(String.class);
|
||||
assertThat(((String) resultMessage.getPayload()).contains("testParamValue")).isTrue();
|
||||
assertThat(((String) resultMessage.getPayload()).contains("FOO")).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -87,9 +84,9 @@ public class XsltTransformerTests {
|
||||
build();
|
||||
input.send(message);
|
||||
Message<?> resultMessage = output.receive();
|
||||
assertEquals("Wrong payload type", String.class, resultMessage.getPayload().getClass());
|
||||
assertTrue(((String) resultMessage.getPayload()).contains("testParamValue"));
|
||||
assertTrue(((String) resultMessage.getPayload()).contains("FOO"));
|
||||
assertThat(resultMessage.getPayload().getClass()).as("Wrong payload type").isEqualTo(String.class);
|
||||
assertThat(((String) resultMessage.getPayload()).contains("testParamValue")).isTrue();
|
||||
assertThat(((String) resultMessage.getPayload()).contains("FOO")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -101,10 +98,10 @@ public class XsltTransformerTests {
|
||||
build();
|
||||
input.send(message);
|
||||
Message<?> resultMessage = output.receive();
|
||||
assertEquals("Wrong payload type", String.class, resultMessage.getPayload().getClass());
|
||||
assertTrue(((String) resultMessage.getPayload()).contains("testParamValue"));
|
||||
assertTrue(((String) resultMessage.getPayload()).contains("FOO"));
|
||||
assertTrue(((String) resultMessage.getPayload()).contains("hello"));
|
||||
assertThat(resultMessage.getPayload().getClass()).as("Wrong payload type").isEqualTo(String.class);
|
||||
assertThat(((String) resultMessage.getPayload()).contains("testParamValue")).isTrue();
|
||||
assertThat(((String) resultMessage.getPayload()).contains("FOO")).isTrue();
|
||||
assertThat(((String) resultMessage.getPayload()).contains("hello")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -116,10 +113,10 @@ public class XsltTransformerTests {
|
||||
build();
|
||||
input.send(message);
|
||||
Message<?> resultMessage = output.receive();
|
||||
assertEquals("Wrong payload type", String.class, resultMessage.getPayload().getClass());
|
||||
assertTrue(((String) resultMessage.getPayload()).contains("testParamValue"));
|
||||
assertTrue(((String) resultMessage.getPayload()).contains("FOO"));
|
||||
assertTrue(((String) resultMessage.getPayload()).contains("hello"));
|
||||
assertThat(resultMessage.getPayload().getClass()).as("Wrong payload type").isEqualTo(String.class);
|
||||
assertThat(((String) resultMessage.getPayload()).contains("testParamValue")).isTrue();
|
||||
assertThat(((String) resultMessage.getPayload()).contains("FOO")).isTrue();
|
||||
assertThat(((String) resultMessage.getPayload()).contains("hello")).isTrue();
|
||||
}
|
||||
|
||||
|
||||
@@ -130,9 +127,9 @@ public class XsltTransformerTests {
|
||||
build();
|
||||
input.send(message);
|
||||
Message<?> resultMessage = output.receive();
|
||||
assertEquals("Wrong payload type", String.class, resultMessage.getPayload().getClass());
|
||||
assertThat(resultMessage.getPayload().getClass()).as("Wrong payload type").isEqualTo(String.class);
|
||||
String stringPayload = (String) resultMessage.getPayload();
|
||||
assertEquals("Wrong content of payload", "hello world text", stringPayload.trim());
|
||||
assertThat(stringPayload.trim()).as("Wrong content of payload").isEqualTo("hello world text");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -141,9 +138,9 @@ public class XsltTransformerTests {
|
||||
Message<?> message = MessageBuilder.withPayload(new ClassPathResource("org/springframework/integration/xml/transformer/xsl-text-file.xml").getFile()).build();
|
||||
input.send(message);
|
||||
Message<?> resultMessage = output.receive();
|
||||
assertEquals("Wrong payload type", String.class, resultMessage.getPayload().getClass());
|
||||
assertThat(resultMessage.getPayload().getClass()).as("Wrong payload type").isEqualTo(String.class);
|
||||
String stringPayload = (String) resultMessage.getPayload();
|
||||
assertEquals("Wrong content of payload", "hello world text", stringPayload.trim());
|
||||
assertThat(stringPayload.trim()).as("Wrong content of payload").isEqualTo("hello world text");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -16,9 +16,7 @@
|
||||
|
||||
package org.springframework.integration.xml.transformer.jaxbmarshaling;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import javax.xml.transform.Result;
|
||||
import javax.xml.transform.Source;
|
||||
@@ -62,10 +60,10 @@ public class JaxbMarshallingIntegrationTests extends AbstractJUnit4SpringContext
|
||||
person.setFirstName("john");
|
||||
marshallIn.send(new GenericMessage<Object>(person));
|
||||
GenericMessage<Result> res = (GenericMessage<Result>) marshalledOut.receive(2000);
|
||||
assertNotNull("No response recevied", res);
|
||||
assertTrue("payload was not a DOMResult", res.getPayload() instanceof DOMResult);
|
||||
assertThat(res).as("No response recevied").isNotNull();
|
||||
assertThat(res.getPayload() instanceof DOMResult).as("payload was not a DOMResult").isTrue();
|
||||
Document doc = (Document) ((DOMResult) res.getPayload()).getNode();
|
||||
assertEquals("Wrong name for root element ", "person", doc.getDocumentElement().getLocalName());
|
||||
assertThat(doc.getDocumentElement().getLocalName()).as("Wrong name for root element ").isEqualTo("person");
|
||||
}
|
||||
|
||||
|
||||
@@ -75,10 +73,10 @@ public class JaxbMarshallingIntegrationTests extends AbstractJUnit4SpringContext
|
||||
StringSource source = new StringSource("<person><firstname>bob</firstname></person>");
|
||||
unmarshallIn.send(new GenericMessage<Source>(source));
|
||||
GenericMessage<Object> res = (GenericMessage<Object>) unmarshallOut.receive(2000);
|
||||
assertNotNull("No response", res);
|
||||
assertTrue("Not a Person ", res.getPayload() instanceof JaxbAnnotatedPerson);
|
||||
assertThat(res).as("No response").isNotNull();
|
||||
assertThat(res.getPayload() instanceof JaxbAnnotatedPerson).as("Not a Person ").isTrue();
|
||||
JaxbAnnotatedPerson person = (JaxbAnnotatedPerson) res.getPayload();
|
||||
assertEquals("Worng firstname", "bob", person.getFirstName());
|
||||
assertThat(person.getFirstName()).as("Worng firstname").isEqualTo("bob");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
* Copyright 2013-2019 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.
|
||||
@@ -16,15 +16,12 @@
|
||||
|
||||
package org.springframework.integration.xml.xpath;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.w3c.dom.DOMException;
|
||||
@@ -79,58 +76,58 @@ public class XPathTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testXPathUtils() {
|
||||
Object result = XPathUtils.evaluate(XML, "/parent/child/@name");
|
||||
assertEquals("test", result);
|
||||
assertThat(result).isEqualTo("test");
|
||||
|
||||
result = XPathUtils.evaluate(XML, "/parent/child/@name", "string");
|
||||
assertEquals("test", result);
|
||||
assertThat(result).isEqualTo("test");
|
||||
|
||||
result = XPathUtils.evaluate(XML, "/parent/child/@age", "number");
|
||||
assertEquals((double) 42, result);
|
||||
assertThat(result).isEqualTo((double) 42);
|
||||
|
||||
result = XPathUtils.evaluate(XML, "/parent/child/@married = 'true'", "boolean");
|
||||
assertEquals(Boolean.TRUE, result);
|
||||
assertThat(result).isEqualTo(Boolean.TRUE);
|
||||
|
||||
result = XPathUtils.evaluate(XML, "/parent/child", "node");
|
||||
assertThat(result, Matchers.instanceOf(Node.class));
|
||||
assertThat(result).isInstanceOf(Node.class);
|
||||
Node node = (Node) result;
|
||||
assertEquals("child", node.getLocalName());
|
||||
assertEquals("test", node.getAttributes().getNamedItem("name").getTextContent());
|
||||
assertEquals("42", node.getAttributes().getNamedItem("age").getTextContent());
|
||||
assertEquals("true", node.getAttributes().getNamedItem("married").getTextContent());
|
||||
assertThat(node.getLocalName()).isEqualTo("child");
|
||||
assertThat(node.getAttributes().getNamedItem("name").getTextContent()).isEqualTo("test");
|
||||
assertThat(node.getAttributes().getNamedItem("age").getTextContent()).isEqualTo("42");
|
||||
assertThat(node.getAttributes().getNamedItem("married").getTextContent()).isEqualTo("true");
|
||||
|
||||
result = XPathUtils.evaluate("<parent><child name='foo'/><child name='bar'/></parent>", "/parent/child",
|
||||
"node_list");
|
||||
assertThat(result, Matchers.instanceOf(List.class));
|
||||
assertThat(result).isInstanceOf(List.class);
|
||||
List<Node> nodeList = (List<Node>) result;
|
||||
assertEquals(2, nodeList.size());
|
||||
assertThat(nodeList.size()).isEqualTo(2);
|
||||
Node node1 = nodeList.get(0);
|
||||
Node node2 = nodeList.get(1);
|
||||
assertEquals("child", node1.getLocalName());
|
||||
assertEquals("foo", node1.getAttributes().getNamedItem("name").getTextContent());
|
||||
assertEquals("child", node2.getLocalName());
|
||||
assertEquals("bar", node2.getAttributes().getNamedItem("name").getTextContent());
|
||||
assertThat(node1.getLocalName()).isEqualTo("child");
|
||||
assertThat(node1.getAttributes().getNamedItem("name").getTextContent()).isEqualTo("foo");
|
||||
assertThat(node2.getLocalName()).isEqualTo("child");
|
||||
assertThat(node2.getAttributes().getNamedItem("name").getTextContent()).isEqualTo("bar");
|
||||
|
||||
result = XPathUtils.evaluate("<parent><child name='foo'/><child name='bar'/></parent>", "/parent/child", "document_list");
|
||||
assertThat(result, Matchers.instanceOf(List.class));
|
||||
assertThat(result).isInstanceOf(List.class);
|
||||
List<Document> documentList = (List<Document>) result;
|
||||
assertEquals(2, documentList.size());
|
||||
assertThat(documentList.size()).isEqualTo(2);
|
||||
Node document1 = documentList.get(0);
|
||||
Node document2 = documentList.get(1);
|
||||
assertEquals("child", document1.getFirstChild().getLocalName());
|
||||
assertEquals("foo", document1.getFirstChild().getAttributes().getNamedItem("name").getTextContent());
|
||||
assertEquals("child", document2.getFirstChild().getLocalName());
|
||||
assertEquals("bar", document2.getFirstChild().getAttributes().getNamedItem("name").getTextContent());
|
||||
assertThat(document1.getFirstChild().getLocalName()).isEqualTo("child");
|
||||
assertThat(document1.getFirstChild().getAttributes().getNamedItem("name").getTextContent()).isEqualTo("foo");
|
||||
assertThat(document2.getFirstChild().getLocalName()).isEqualTo("child");
|
||||
assertThat(document2.getFirstChild().getAttributes().getNamedItem("name").getTextContent()).isEqualTo("bar");
|
||||
|
||||
result = XPathUtils.evaluate(XML, "/parent/child/@name", new TestNodeMapper());
|
||||
assertEquals("test-mapped", result);
|
||||
assertThat(result).isEqualTo("test-mapped");
|
||||
|
||||
try {
|
||||
XPathUtils.evaluate(new Date(), "/parent/child");
|
||||
fail("MessagingException expected.");
|
||||
}
|
||||
catch (Exception e) {
|
||||
assertThat(e, Matchers.instanceOf(MessagingException.class));
|
||||
assertThat(e.getMessage(), Matchers.containsString("unsupported payload type"));
|
||||
assertThat(e).isInstanceOf(MessagingException.class);
|
||||
assertThat(e.getMessage()).contains("unsupported payload type");
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -138,8 +135,8 @@ public class XPathTests {
|
||||
fail("MessagingException expected.");
|
||||
}
|
||||
catch (Exception e) {
|
||||
assertThat(e, Matchers.instanceOf(IllegalArgumentException.class));
|
||||
assertEquals("'resultArg' can contains only one element.", e.getMessage());
|
||||
assertThat(e).isInstanceOf(IllegalArgumentException.class);
|
||||
assertThat(e.getMessage()).isEqualTo("'resultArg' can contains only one element.");
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -147,9 +144,9 @@ public class XPathTests {
|
||||
fail("MessagingException expected.");
|
||||
}
|
||||
catch (Exception e) {
|
||||
assertThat(e, Matchers.instanceOf(IllegalArgumentException.class));
|
||||
assertEquals("'resultArg[0]' can be an instance of 'NodeMapper<?>' or " +
|
||||
"one of supported String constants: [string, boolean, number, node, node_list, document_list]", e.getMessage());
|
||||
assertThat(e).isInstanceOf(IllegalArgumentException.class);
|
||||
assertThat(e.getMessage()).isEqualTo("'resultArg[0]' can be an instance of 'NodeMapper<?>' or " +
|
||||
"one of supported String constants: [string, boolean, number, node, node_list, document_list]");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -163,8 +160,8 @@ public class XPathTests {
|
||||
this.xpathTransformerInput.send(message);
|
||||
|
||||
Message<?> receive = this.channelA.receive(1000);
|
||||
assertNotNull(receive);
|
||||
assertEquals("42-mapped", receive.getPayload());
|
||||
assertThat(receive).isNotNull();
|
||||
assertThat(receive.getPayload()).isEqualTo("42-mapped");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -173,12 +170,12 @@ public class XPathTests {
|
||||
this.xpathFilterInput.send(new GenericMessage<Object>("<other>outputOne</other>"));
|
||||
|
||||
Message<?> receive = this.channelA.receive(1000);
|
||||
assertNotNull(receive);
|
||||
assertEquals("<name>outputOne</name>", receive.getPayload());
|
||||
assertThat(receive).isNotNull();
|
||||
assertThat(receive.getPayload()).isEqualTo("<name>outputOne</name>");
|
||||
|
||||
receive = this.channelZ.receive(1000);
|
||||
assertNotNull(receive);
|
||||
assertEquals("<other>outputOne</other>", receive.getPayload());
|
||||
assertThat(receive).isNotNull();
|
||||
assertThat(receive.getPayload()).isEqualTo("<other>outputOne</other>");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -187,12 +184,12 @@ public class XPathTests {
|
||||
this.xpathSplitterInput.send(new GenericMessage<Object>("<books><book>book1</book><book>book2</book></books>"));
|
||||
|
||||
Message<?> receive = this.channelA.receive(1000);
|
||||
assertNotNull(receive);
|
||||
assertThat(stringSourceFactory.createSource(receive.getPayload()).toString(), Matchers.containsString("<book>book1</book>"));
|
||||
assertThat(receive).isNotNull();
|
||||
assertThat(stringSourceFactory.createSource(receive.getPayload()).toString()).contains("<book>book1</book>");
|
||||
|
||||
receive = this.channelA.receive(1000);
|
||||
assertNotNull(receive);
|
||||
assertThat(stringSourceFactory.createSource(receive.getPayload()).toString(), Matchers.containsString("<book>book2</book>"));
|
||||
assertThat(receive).isNotNull();
|
||||
assertThat(stringSourceFactory.createSource(receive.getPayload()).toString()).contains("<book>book2</book>");
|
||||
}
|
||||
|
||||
|
||||
@@ -203,16 +200,16 @@ public class XPathTests {
|
||||
this.xpathRouterInput.send(new GenericMessage<Object>("<name>X</name>"));
|
||||
|
||||
Message<?> receive = this.channelA.receive(1000);
|
||||
assertNotNull(receive);
|
||||
assertEquals("<name>A</name>", receive.getPayload());
|
||||
assertThat(receive).isNotNull();
|
||||
assertThat(receive.getPayload()).isEqualTo("<name>A</name>");
|
||||
|
||||
receive = this.channelB.receive(1000);
|
||||
assertNotNull(receive);
|
||||
assertEquals("<name>B</name>", receive.getPayload());
|
||||
assertThat(receive).isNotNull();
|
||||
assertThat(receive.getPayload()).isEqualTo("<name>B</name>");
|
||||
|
||||
receive = this.channelZ.receive(1000);
|
||||
assertNotNull(receive);
|
||||
assertEquals("<name>X</name>", receive.getPayload());
|
||||
assertThat(receive).isNotNull();
|
||||
assertThat(receive.getPayload()).isEqualTo("<name>X</name>");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user