Camel integration tests

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Camel integration tests

Jan Bouška
Hi folks,
Recently I was thinking about integration tests in Camel project. Of
course, we have camel-testcontainers component [1] which can help with
integration testing very much using docker containers. But what about
services which does not have docker image? For example we can't have
facebook-docker image.

Most of this third party services are communicating through REST API. I am
working on camel-wiremock-test component [2] [3] which is able to record
REST API responses and playback during the test.

Can you check my PoC with camel-jira [4]? What you think about this
approach? Does it worth it?

Thanks for your input.

Have a nice day.
Jan

[1]
https://github.com/apache/camel/tree/master/components/camel-testcontainers
[2]
https://github.com/bouskaJ/camel/tree/camel-wiremock/components/camel-wiremock-test
[3] http://wiremock.org/
[4]
https://github.com/bouskaJ/camel/blob/camel-wiremock/components/camel-jira/src/test/java/org/apache/camel/component/jira/it/JiraProducerItTest.java
Reply | Threaded
Open this post in threaded view
|

Re: Camel integration tests

omarsmak
Hi Jan,

Pretty interesting, thanks for pulling this together. A question, from here
you define the mocked responses that you will test against
https://github.com/bouskaJ/camel/tree/camel-wiremock/components/camel-jira/src/test/resources/mappings
 ?

Regards,
Omar

On Wed, 9 Oct 2019 at 09:46, Jan Bouška <[hidden email]> wrote:

> Hi folks,
> Recently I was thinking about integration tests in Camel project. Of
> course, we have camel-testcontainers component [1] which can help with
> integration testing very much using docker containers. But what about
> services which does not have docker image? For example we can't have
> facebook-docker image.
>
> Most of this third party services are communicating through REST API. I am
> working on camel-wiremock-test component [2] [3] which is able to record
> REST API responses and playback during the test.
>
> Can you check my PoC with camel-jira [4]? What you think about this
> approach? Does it worth it?
>
> Thanks for your input.
>
> Have a nice day.
> Jan
>
> [1]
> https://github.com/apache/camel/tree/master/components/camel-testcontainers
> [2]
>
> https://github.com/bouskaJ/camel/tree/camel-wiremock/components/camel-wiremock-test
> [3] http://wiremock.org/
> [4]
>
> https://github.com/bouskaJ/camel/blob/camel-wiremock/components/camel-jira/src/test/java/org/apache/camel/component/jira/it/JiraProducerItTest.java
>
Reply | Threaded
Open this post in threaded view
|

Re: Camel integration tests

Zoran Regvart-2
In reply to this post by Jan Bouška
Hi Jan,
I like WireMock I've used it extensively. In general I don't think
test class hierarchies are a good idea, I'd prefer composition instead
of inheritance. Have you seen the Citrus Framework[1]?

zoran

[1] https://citrusframework.org/

On Wed, Oct 9, 2019 at 9:46 AM Jan Bouška <[hidden email]> wrote:

>
> Hi folks,
> Recently I was thinking about integration tests in Camel project. Of
> course, we have camel-testcontainers component [1] which can help with
> integration testing very much using docker containers. But what about
> services which does not have docker image? For example we can't have
> facebook-docker image.
>
> Most of this third party services are communicating through REST API. I am
> working on camel-wiremock-test component [2] [3] which is able to record
> REST API responses and playback during the test.
>
> Can you check my PoC with camel-jira [4]? What you think about this
> approach? Does it worth it?
>
> Thanks for your input.
>
> Have a nice day.
> Jan
>
> [1]
> https://github.com/apache/camel/tree/master/components/camel-testcontainers
> [2]
> https://github.com/bouskaJ/camel/tree/camel-wiremock/components/camel-wiremock-test
> [3] http://wiremock.org/
> [4]
> https://github.com/bouskaJ/camel/blob/camel-wiremock/components/camel-jira/src/test/java/org/apache/camel/component/jira/it/JiraProducerItTest.java



--
Zoran Regvart
Reply | Threaded
Open this post in threaded view
|

Re: Camel integration tests

Jan Bouška
Hi Omar, Zoran

To answer your question Omar. Responses are recorded by wiremock itselves.
In first run it will call real REST API. In second, third... run it will
reuse recorded responses.

Zoran, this is just a PoC. Architecture can be changed. I know Citrus
framework but I haven't use it yet. Does it supports also recording like
the wiremock framework?

Kind regards
Jan.


st 9. 10. 2019 v 11:02 odesílatel Zoran Regvart <[hidden email]> napsal:

> Hi Jan,
> I like WireMock I've used it extensively. In general I don't think
> test class hierarchies are a good idea, I'd prefer composition instead
> of inheritance. Have you seen the Citrus Framework[1]?
>
> zoran
>
> [1] https://citrusframework.org/
>
> On Wed, Oct 9, 2019 at 9:46 AM Jan Bouška <[hidden email]> wrote:
> >
> > Hi folks,
> > Recently I was thinking about integration tests in Camel project. Of
> > course, we have camel-testcontainers component [1] which can help with
> > integration testing very much using docker containers. But what about
> > services which does not have docker image? For example we can't have
> > facebook-docker image.
> >
> > Most of this third party services are communicating through REST API. I
> am
> > working on camel-wiremock-test component [2] [3] which is able to record
> > REST API responses and playback during the test.
> >
> > Can you check my PoC with camel-jira [4]? What you think about this
> > approach? Does it worth it?
> >
> > Thanks for your input.
> >
> > Have a nice day.
> > Jan
> >
> > [1]
> >
> https://github.com/apache/camel/tree/master/components/camel-testcontainers
> > [2]
> >
> https://github.com/bouskaJ/camel/tree/camel-wiremock/components/camel-wiremock-test
> > [3] http://wiremock.org/
> > [4]
> >
> https://github.com/bouskaJ/camel/blob/camel-wiremock/components/camel-jira/src/test/java/org/apache/camel/component/jira/it/JiraProducerItTest.java
>
>
>
> --
> Zoran Regvart
>
Reply | Threaded
Open this post in threaded view
|

Re: Camel integration tests

Zoran Regvart-2
Hi Jan,
I don't think Citrus has recording support, it can be configured much
like WireMock using Java DSL or using XML[1]

zoran

[1] https://citrusframework.org/citrus/reference/2.8.0/html/index.html#http-rest-server

On Wed, Oct 9, 2019 at 11:23 AM Jan Bouška <[hidden email]> wrote:

>
> Hi Omar, Zoran
>
> To answer your question Omar. Responses are recorded by wiremock itselves.
> In first run it will call real REST API. In second, third... run it will
> reuse recorded responses.
>
> Zoran, this is just a PoC. Architecture can be changed. I know Citrus
> framework but I haven't use it yet. Does it supports also recording like
> the wiremock framework?
>
> Kind regards
> Jan.
>
>
> st 9. 10. 2019 v 11:02 odesílatel Zoran Regvart <[hidden email]> napsal:
>
> > Hi Jan,
> > I like WireMock I've used it extensively. In general I don't think
> > test class hierarchies are a good idea, I'd prefer composition instead
> > of inheritance. Have you seen the Citrus Framework[1]?
> >
> > zoran
> >
> > [1] https://citrusframework.org/
> >
> > On Wed, Oct 9, 2019 at 9:46 AM Jan Bouška <[hidden email]> wrote:
> > >
> > > Hi folks,
> > > Recently I was thinking about integration tests in Camel project. Of
> > > course, we have camel-testcontainers component [1] which can help with
> > > integration testing very much using docker containers. But what about
> > > services which does not have docker image? For example we can't have
> > > facebook-docker image.
> > >
> > > Most of this third party services are communicating through REST API. I
> > am
> > > working on camel-wiremock-test component [2] [3] which is able to record
> > > REST API responses and playback during the test.
> > >
> > > Can you check my PoC with camel-jira [4]? What you think about this
> > > approach? Does it worth it?
> > >
> > > Thanks for your input.
> > >
> > > Have a nice day.
> > > Jan
> > >
> > > [1]
> > >
> > https://github.com/apache/camel/tree/master/components/camel-testcontainers
> > > [2]
> > >
> > https://github.com/bouskaJ/camel/tree/camel-wiremock/components/camel-wiremock-test
> > > [3] http://wiremock.org/
> > > [4]
> > >
> > https://github.com/bouskaJ/camel/blob/camel-wiremock/components/camel-jira/src/test/java/org/apache/camel/component/jira/it/JiraProducerItTest.java
> >
> >
> >
> > --
> > Zoran Regvart
> >



--
Zoran Regvart
Reply | Threaded
Open this post in threaded view
|

Re: Camel integration tests

Onder SEZGIN
In reply to this post by Jan Bouška
+1

On Wed, Oct 9, 2019 at 10:46 AM Jan Bouška <[hidden email]> wrote:

> Hi folks,
> Recently I was thinking about integration tests in Camel project. Of
> course, we have camel-testcontainers component [1] which can help with
> integration testing very much using docker containers. But what about
> services which does not have docker image? For example we can't have
> facebook-docker image.
>
> Most of this third party services are communicating through REST API. I am
> working on camel-wiremock-test component [2] [3] which is able to record
> REST API responses and playback during the test.
>
> Can you check my PoC with camel-jira [4]? What you think about this
> approach? Does it worth it?
>
> Thanks for your input.
>
> Have a nice day.
> Jan
>
> [1]
> https://github.com/apache/camel/tree/master/components/camel-testcontainers
> [2]
>
> https://github.com/bouskaJ/camel/tree/camel-wiremock/components/camel-wiremock-test
> [3] http://wiremock.org/
> [4]
>
> https://github.com/bouskaJ/camel/blob/camel-wiremock/components/camel-jira/src/test/java/org/apache/camel/component/jira/it/JiraProducerItTest.java
>
Reply | Threaded
Open this post in threaded view
|

Re: Camel integration tests

Willem.Jiang
Administrator
yeah, it sounds good to me by recording the real services
request/response to mock the online services
I think it could still be part of the component level tests instead of
real integration test, because of the real services API could be
changed and we still need to record the services request and response
again in that case.

Willem Jiang

Twitter: willemjiang
Weibo: 姜宁willem

On Fri, Oct 11, 2019 at 4:21 AM Onder SEZGIN <[hidden email]> wrote:

>
> +1
>
> On Wed, Oct 9, 2019 at 10:46 AM Jan Bouška <[hidden email]> wrote:
>
> > Hi folks,
> > Recently I was thinking about integration tests in Camel project. Of
> > course, we have camel-testcontainers component [1] which can help with
> > integration testing very much using docker containers. But what about
> > services which does not have docker image? For example we can't have
> > facebook-docker image.
> >
> > Most of this third party services are communicating through REST API. I am
> > working on camel-wiremock-test component [2] [3] which is able to record
> > REST API responses and playback during the test.
> >
> > Can you check my PoC with camel-jira [4]? What you think about this
> > approach? Does it worth it?
> >
> > Thanks for your input.
> >
> > Have a nice day.
> > Jan
> >
> > [1]
> > https://github.com/apache/camel/tree/master/components/camel-testcontainers
> > [2]
> >
> > https://github.com/bouskaJ/camel/tree/camel-wiremock/components/camel-wiremock-test
> > [3] http://wiremock.org/
> > [4]
> >
> > https://github.com/bouskaJ/camel/blob/camel-wiremock/components/camel-jira/src/test/java/org/apache/camel/component/jira/it/JiraProducerItTest.java
> >
Reply | Threaded
Open this post in threaded view
|

Re: Camel integration tests

Jan Bouška
Zoran,
I chose WireMock because of its recording feature. I would like to avoid
configuring mocked API manually.

With WireMock it is quite easy. You will just set you recorded URL [1] and
run test in record mode. Wiremock can do everything else for you.

Without recording feature it is much more complicated. You will have to
investigate which API endpoints are used by internal clients, collect
responses and configure Citrus accordingly.

As Willem noticed in case of API change, you can run recording against real
API again and your tests are updated.
[1]
https://github.com/bouskaJ/camel/blob/camel-wiremock/components/camel-jira/src/test/java/org/apache/camel/component/jira/it/JiraProducerItTest.java#L74

pá 11. 10. 2019 v 2:04 odesílatel Willem Jiang <[hidden email]>
napsal:

> yeah, it sounds good to me by recording the real services
> request/response to mock the online services
> I think it could still be part of the component level tests instead of
> real integration test, because of the real services API could be
> changed and we still need to record the services request and response
> again in that case.
>
> Willem Jiang
>
> Twitter: willemjiang
> Weibo: 姜宁willem
>
> On Fri, Oct 11, 2019 at 4:21 AM Onder SEZGIN <[hidden email]>
> wrote:
> >
> > +1
> >
> > On Wed, Oct 9, 2019 at 10:46 AM Jan Bouška <[hidden email]> wrote:
> >
> > > Hi folks,
> > > Recently I was thinking about integration tests in Camel project. Of
> > > course, we have camel-testcontainers component [1] which can help with
> > > integration testing very much using docker containers. But what about
> > > services which does not have docker image? For example we can't have
> > > facebook-docker image.
> > >
> > > Most of this third party services are communicating through REST API.
> I am
> > > working on camel-wiremock-test component [2] [3] which is able to
> record
> > > REST API responses and playback during the test.
> > >
> > > Can you check my PoC with camel-jira [4]? What you think about this
> > > approach? Does it worth it?
> > >
> > > Thanks for your input.
> > >
> > > Have a nice day.
> > > Jan
> > >
> > > [1]
> > >
> https://github.com/apache/camel/tree/master/components/camel-testcontainers
> > > [2]
> > >
> > >
> https://github.com/bouskaJ/camel/tree/camel-wiremock/components/camel-wiremock-test
> > > [3] http://wiremock.org/
> > > [4]
> > >
> > >
> https://github.com/bouskaJ/camel/blob/camel-wiremock/components/camel-jira/src/test/java/org/apache/camel/component/jira/it/JiraProducerItTest.java
> > >
>