This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch camel-2.x in repository https://gitbox.apache.org/repos/asf/camel.git
commit 483e833a72cbaf347c1fc32f122310216bf75d3a Author: Andrea Cosentino <[email protected]> AuthorDate: Mon Jul 8 16:41:42 2019 +0200 Fixed Camel-Slack Producer Test --- components/camel-slack/pom.xml | 49 ++++++++++++---------- .../camel/component/slack/SlackProducerTest.java | 21 +++------- 2 files changed, 33 insertions(+), 37 deletions(-) diff --git a/components/camel-slack/pom.xml b/components/camel-slack/pom.xml index 2f57dcb..ba6b821 100644 --- a/components/camel-slack/pom.xml +++ b/components/camel-slack/pom.xml @@ -55,28 +55,33 @@ <artifactId>httpclient</artifactId> </dependency> - <!-- test dependencies --> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-test</artifactId> - <scope>test</scope> - </dependency> - <!-- logging --> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-api</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-slf4j-impl</artifactId> - <scope>test</scope> - </dependency> + <!-- test dependencies --> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-undertow</artifactId> + <scope>test</scope> + </dependency> + <!-- logging --> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-slf4j-impl</artifactId> + <scope>test</scope> + </dependency> </dependencies> </project> diff --git a/components/camel-slack/src/test/java/org/apache/camel/component/slack/SlackProducerTest.java b/components/camel-slack/src/test/java/org/apache/camel/component/slack/SlackProducerTest.java index cfa3ae6..c0cd020 100644 --- a/components/camel-slack/src/test/java/org/apache/camel/component/slack/SlackProducerTest.java +++ b/components/camel-slack/src/test/java/org/apache/camel/component/slack/SlackProducerTest.java @@ -20,6 +20,7 @@ import org.apache.camel.EndpointInject; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.direct.DirectEndpoint; import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.AvailablePortFinder; import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Test; @@ -31,9 +32,8 @@ public class SlackProducerTest extends CamelTestSupport { @EndpointInject(uri = "direct:test") DirectEndpoint test; - - @EndpointInject(uri = "direct:error") - DirectEndpoint error; + + protected static final int UNDERTOW_PORT = AvailablePortFinder.getNextAvailable(); @Test public void testSlackMessage() throws Exception { @@ -44,30 +44,21 @@ public class SlackProducerTest extends CamelTestSupport { assertMockEndpointsSatisfied(); } - @Test - public void testSlackError() throws Exception { - errors.expectedMessageCount(1); - - template.sendBody(error, "Error from Camel!"); - - assertMockEndpointsSatisfied(); - } - @Override protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { @Override public void configure() { SlackComponent slack = new SlackComponent(); - slack.setWebhookUrl(System.getProperty("SLACK_HOOK", "https://hooks.slack.com/services/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")); + slack.setWebhookUrl("http://localhost:" + UNDERTOW_PORT + "/slack/webhook"); context.addComponent("slack", slack); onException(Exception.class).handled(true).to(errors); final String slacUser = System.getProperty("SLACK_USER", "CamelTest"); + from("undertow:http://localhost:" + UNDERTOW_PORT + "/slack/webhook").setBody(constant("{\"ok\": true}")); + from(test).to(String.format("slack:#general?iconEmoji=:camel:&username=%s", slacUser)); - - from(error).to(String.format("slack:#badchannel?iconEmoji=:camel:&username=%s", slack)); } }; }
