Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate ServiceNow, Slack, Geocoder & Telegram tests to WireMock #1993

Merged
merged 7 commits into from
Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 10 additions & 6 deletions integration-tests/telegram/README.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
== Camel Quarkus Telegram Integration Tests

By default the Telegram integration tests use WireMock to stub the API interactions.

To run `camel-quarkus-telegram` integration tests against the real remote Telegram API, you must first create
a Telegram bot following this guide:
https://www.nicolaferraro.me/2016/05/27/creating-a-telegram-bot-in-5-minutes-with-apache-camel/
Expand All @@ -8,12 +10,14 @@ Then set the following environment variables:

[source,shell]
----
$ export TELEGRAM_AUTHORIZATION_TOKEN=my-authorization-token
$ export TELEGRAM_CHAT_ID=my-chatId
export TELEGRAM_AUTHORIZATION_TOKEN=my-authorization-token
export TELEGRAM_CHAT_ID=my-chatId
----

If you do not set `TELEGRAM_AUTHORIZATION_TOKEN` environment variable, the test will be run against a mock
Telegram API started on `localhost`.
If the WireMock stub recordings need updating, then remove the existing files from `src/test/resources/mappings` and run tests with either:

System property `-Dwiremock.record=true`

Or

You may want to `export CAMEL_QUARKUS_START_MOCK_BACKEND=false` to avoid starting he the mock Telegram API
to make sure that you test against the real remote Telegram API.
Set environment variable `WIREMOCK_RECORD=true`
9 changes: 5 additions & 4 deletions integration-tests/telegram/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,18 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-attachments</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-test-support-mock-backend</artifactId>
</dependency>
Comment on lines -59 to -62
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The auditing idea was based on the assumption that the number of camel-quarkus-integration-test-support-mock-backend occurrences in poms must be equal to the number of the magic log tokens. Now we are stopping to use camel-quarkus-integration-test-support-mock-backend .

Yes, camel-quarkus-integration-wiremock-support is a replacement, but probably not all mock will be HTTP, so the interested parties (cc @llowinge ) will have to add the number of camel-quarkus-integration-wiremock-support occurrences to the number of camel-quarkus-integration-test-support-mock-backend.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me think about this some more because there are probably other (better) ways of achieving this.


<!-- test dependencies -->
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-test-support</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-wiremock-support</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class TelegramResource {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String getMessages() {
final String messages = consumerTemplate.receiveBodyNoWait("telegram://bots", String.class);
final String messages = consumerTemplate.receiveBody("telegram://bots", 5000L, String.class);
log.infof("Received telegram messages: %s", messages);
return messages;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,15 @@
#
# Quarkus
#
quarkus.log.category."org.apache.camel.support.DefaultComponent".level = TRACE
#quarkus.log.category."org.apache.camel.support.DefaultComponent".level = TRACE
#quarkus.log.category."org.asynchttpclient".level = TRACE
#quarkus.log.category."org.apache.camel.component.telegram.TelegramComponent".level = TRACE
# You can check in this directory what requests the client is sending when you run against the mock Telegram API
quarkus.http.body.uploads-directory=target/uploads

quarkus.native.additional-build-args = -H:IncludeResources=.*mock-messages/.*
#
# Camel :: Telegram
#
# Set the authorization token here or via environment variable TELEGRAM_AUTHORIZATION_TOKEN
#telegram.authorization-token=...

telegram.chatId=${TELEGRAM_CHAT_ID:-1}

# You may want to export CAMEL_QUARKUS_START_MOCK_BACKEND=false to avoid starting he the mock Telegram API
# to make sure that you test against the real remote Telegram API
camel.quarkus.start-mock-backend=true
camel.component.telegram.authorization-token=${TELEGRAM_AUTHORIZATION_TOKEN:fake-token}
telegram.chatId=${TELEGRAM_CHAT_ID:1426416050}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.