You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Nicolas Peltier <pe...@gmail.com> on 2020/12/01 08:53:07 UTC

[mock] best way to mock http(s) endpoint

Hey,

i'd like to "unit" test some code that does http connection & data fetch. I
guess using an external endpoint is not a good idea, do we have already
some stuff to mock an http(s) endpoint, or do i need to spin up a pax
container (with required bundles)?

Nicolas

Re: [mock] best way to mock http(s) endpoint

Posted by Nicolas Peltier <pe...@gmail.com>.
thanks guys, it indeed is cool!

Le mar. 1 déc. 2020 à 12:55, Roy Teeuwen <ro...@teeuwen.be> a écrit :

> Yup, you can also get some inspiration from the aem-stubs from Cognifide:
>
> https://github.com/Cognifide/aem-stubs <
> https://github.com/Cognifide/aem-stubs>
>
> Not sure if there is any actual dependency on AEM for that one
>
>
>
> > On 1 Dec 2020, at 10:39, Bertrand Delacretaz <bd...@apache.org>
> wrote:
> >
> > Hi,
> >
> > On Tue, Dec 1, 2020 at 10:24 AM Stefan Seifert <ss...@pro-vision.de>
> wrote:
> >> ...maybe wiremock? it does real HTTP communication but neatly
> integrated in junit (i've not tried to use it with JUnit 5).
> >> https://github.com/tomakehurst/wiremock ...
> >
> > I've been using wiremock in Sling,
> >
> https://github.com/apache/sling-org-apache-sling-junit-teleporter/blob/master/src/test/java/org/apache/sling/testing/teleporter/client/TeleporterHttpClientTest.java
> > and like it!
> >
> > Note that that code is from 5 years ago, there's probably been
> > improvements in the meantime.
> >
> > -Bertrand
>
>

Re: [mock] best way to mock http(s) endpoint

Posted by Roy Teeuwen <ro...@teeuwen.be>.
Yup, you can also get some inspiration from the aem-stubs from Cognifide:

https://github.com/Cognifide/aem-stubs <https://github.com/Cognifide/aem-stubs>

Not sure if there is any actual dependency on AEM for that one



> On 1 Dec 2020, at 10:39, Bertrand Delacretaz <bd...@apache.org> wrote:
> 
> Hi,
> 
> On Tue, Dec 1, 2020 at 10:24 AM Stefan Seifert <ss...@pro-vision.de> wrote:
>> ...maybe wiremock? it does real HTTP communication but neatly integrated in junit (i've not tried to use it with JUnit 5).
>> https://github.com/tomakehurst/wiremock ...
> 
> I've been using wiremock in Sling,
> https://github.com/apache/sling-org-apache-sling-junit-teleporter/blob/master/src/test/java/org/apache/sling/testing/teleporter/client/TeleporterHttpClientTest.java
> and like it!
> 
> Note that that code is from 5 years ago, there's probably been
> improvements in the meantime.
> 
> -Bertrand


Re: [mock] best way to mock http(s) endpoint

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,

On Tue, Dec 1, 2020 at 10:24 AM Stefan Seifert <ss...@pro-vision.de> wrote:
> ...maybe wiremock? it does real HTTP communication but neatly integrated in junit (i've not tried to use it with JUnit 5).
> https://github.com/tomakehurst/wiremock ...

I've been using wiremock in Sling,
https://github.com/apache/sling-org-apache-sling-junit-teleporter/blob/master/src/test/java/org/apache/sling/testing/teleporter/client/TeleporterHttpClientTest.java
and like it!

Note that that code is from 5 years ago, there's probably been
improvements in the meantime.

-Bertrand

RE: [mock] best way to mock http(s) endpoint

Posted by Stefan Seifert <ss...@pro-vision.de>.
maybe wiremock? it does real HTTP communication but neatly integrated in junit (i've not tried to use it with JUnit 5).
https://github.com/tomakehurst/wiremock

stefan

>-----Original Message-----
>From: Nicolas Peltier <pe...@gmail.com>
>Sent: Tuesday, December 1, 2020 9:53 AM
>To: users@sling.apache.org
>Subject: [mock] best way to mock http(s) endpoint
>
>Hey,
>
>i'd like to "unit" test some code that does http connection & data fetch. I
>guess using an external endpoint is not a good idea, do we have already
>some stuff to mock an http(s) endpoint, or do i need to spin up a pax
>container (with required bundles)?
>
>Nicolas