You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Andreas Schaefer <sc...@me.com.INVALID> on 2022/08/14 21:15:16 UTC

Server-Side Testing

Hi

I am working on some sling components and want to IT test them within the server to avoid client-side polling.

It looks like there are two ways to do that:

- Junit Servlet
- Sling Testing Server Setup and Teleporter

Does Sling do any server side testing?
What is the currently support way of doing server side tests?

Thanks - Andy

Re: Server-Side Testing

Posted by Oliver Lietz <ap...@oliverlietz.de>.
On Monday, 26 September 2022 18:21:26 CEST Andreas Schaefer wrote:
> Hi
> 
> As mentioned in my previous email I ran into an issue with Composum as I
> could not open it with the Pax Tests even though I included composum()
> setup.
> 
> I could fix that with this line:
> 
> mavenBundle().groupId("org.apache.geronimo.bundles").artifactId("jstl").vers
> ion("1.2_1"),

Could you please check if it works with 4.0.0-SNAPSHOT? There are some changes 
related to Scripting JSP (Composum option was renamed to composumNodes).

> I have another question regarding uploading a file. I was able to use Jsoup
> to upload a file to create a file node in Sling. I am wondering if there is
> a way with PaxExam to do that with a direct API exam as my tests are not
> there to test the REST Api but rather to make sure my code is working?
> 
> Anyhow Jsoup will work fine if it is the only way.

You could use any Sling or Jackrabbit/Oak service (as Eric already 
highlighted) or Sling Initial Content.

O.


> - Andy
> 
> > On Aug 23, 2022, at 11:03 AM, Eric Norman <en...@apache.org> wrote:
> > 
> > Hi Andy,
> > 
> > What I usually do for debugging/inspecting the pax exam instance is to add
> > optional configuration to enable remote debugging (see [1]).  Then you can
> > set a breakpoint in your test code and it will stop there for you to take
> > a
> > look around.
> > 
> > One example of this is at:
> > 1, AuthFormTestSupport.java#L94
> > <https://github.com/apache/sling-org-apache-sling-auth-form/blob/0040aac8a
> > 3a89a0cfc4727f2802bd560803c4c8a/src/test/java/org/apache/sling/auth/form/i
> > t/AuthFormTestSupport.java#L94>
> > 
> > 
> > Hope that helps.
> > 
> > Regards,
> > Eric
> > 
> > 
> > On Mon, Aug 22, 2022 at 2:14 PM Andreas Schaefer
> > <sc...@me.com.invalid>
> > 
> > wrote:
> >> Hi Oliver
> >> 
> >> I am making good progress but I noticed that I cannot get composum up on
> >> both 3.1.0 or 3.0.0 which is the current version I am using because I am
> >> still running against Sling 11.
> >> 
> >> The issues I see is: 'The absolute uri: http://java.sun.com/jsp/jstl/core
> >> cannot be resolved’
> >> 
> >> Also is there a way to keep the Sling instance running (something like
> >> keep running flag) after the tests were done in case I need to
> >> investigate
> >> an issue with the Sling instance like bundles dependencies etc?
> >> 
> >> Thanks - Andy
> >> 
> >>> On Aug 15, 2022, at 2:20 AM, Oliver Lietz <ap...@oliverlietz.de> wrote:
> >>> 
> >>> On Sunday, 14 August 2022 23:15:16 CEST Andreas Schaefer wrote:
> >>>> Hi
> >>> 
> >>> Hi Andy,
> >>> 
> >>>> I am working on some sling components and want to IT test them within
> >> 
> >> the
> >> 
> >>>> server to avoid client-side polling.
> >>>> 
> >>>> It looks like there are two ways to do that:
> >>>> 
> >>>> - Junit Servlet
> >>>> - Sling Testing Server Setup and Teleporter
> >>>> 
> >>>> Does Sling do any server side testing?
> >>>> What is the currently support way of doing server side tests?
> >>> 
> >>> Running tests inside the OSGi container is the default when using OPS4J
> >> 
> >> Pax
> >> 
> >>> Exam. See the list of Sling modules using Sling's Testing PaxExam and
> >> 
> >> have a
> >> 
> >>> look what the ITs are doing to get some ideas:
> >>> 
> >>> https://sling.apache.org/documentation/development/testing-paxexam.html
> >>> 
> >>> Let me know if more documentation is needed.
> >>> 
> >>> HTH,
> >>> O.
> >>> 
> >>>> Thanks - Andy





Re: Server-Side Testing

Posted by Eric Norman <en...@apache.org>.
The paxexam tests are running inside of the OSGi runtime.

So if you just need to create a file in the repository, then maybe you
could just inject a reference to the SlingRepository service into your test
class and use that to interact with the JCR repository to do the work?

For example:

    @Inject
    protected SlingRepository repository;

Regards,
Eric

On Mon, Sep 26, 2022 at 9:21 AM Andreas Schaefer <sc...@me.com.invalid>
wrote:

> Hi
>
> As mentioned in my previous email I ran into an issue with Composum as I
> could not open it with the Pax Tests even though I included composum()
> setup.
>
> I could fix that with this line:
>
>
> mavenBundle().groupId("org.apache.geronimo.bundles").artifactId("jstl").version("1.2_1"),
>
> I have another question regarding uploading a file. I was able to use
> Jsoup to upload a file to create a file node in Sling.
> I am wondering if there is a way with PaxExam to do that with a direct API
> exam as my tests are not there to test the REST Api but rather to make sure
> my code is working?
>
> Anyhow Jsoup will work fine if it is the only way.
>
> - Andy
>
> > On Aug 23, 2022, at 11:03 AM, Eric Norman <en...@apache.org> wrote:
> >
> > Hi Andy,
> >
> > What I usually do for debugging/inspecting the pax exam instance is to
> add
> > optional configuration to enable remote debugging (see [1]).  Then you
> can
> > set a breakpoint in your test code and it will stop there for you to
> take a
> > look around.
> >
> > One example of this is at:
> > 1, AuthFormTestSupport.java#L94
> > <
> https://github.com/apache/sling-org-apache-sling-auth-form/blob/0040aac8a3a89a0cfc4727f2802bd560803c4c8a/src/test/java/org/apache/sling/auth/form/it/AuthFormTestSupport.java#L94
> >
> >
> >
> > Hope that helps.
> >
> > Regards,
> > Eric
> >
> >
> > On Mon, Aug 22, 2022 at 2:14 PM Andreas Schaefer
> <sc...@me.com.invalid>
> > wrote:
> >
> >> Hi Oliver
> >>
> >> I am making good progress but I noticed that I cannot get composum up on
> >> both 3.1.0 or 3.0.0 which is the current version I am using because I am
> >> still running against Sling 11.
> >>
> >> The issues I see is: 'The absolute uri:
> http://java.sun.com/jsp/jstl/core
> >> cannot be resolved’
> >>
> >> Also is there a way to keep the Sling instance running (something like
> >> keep running flag) after the tests were done in case I need to
> investigate
> >> an issue with the Sling instance like bundles dependencies etc?
> >>
> >> Thanks - Andy
> >>
> >>
> >>> On Aug 15, 2022, at 2:20 AM, Oliver Lietz <ap...@oliverlietz.de>
> wrote:
> >>>
> >>> On Sunday, 14 August 2022 23:15:16 CEST Andreas Schaefer wrote:
> >>>> Hi
> >>>
> >>> Hi Andy,
> >>>
> >>>> I am working on some sling components and want to IT test them within
> >> the
> >>>> server to avoid client-side polling.
> >>>>
> >>>> It looks like there are two ways to do that:
> >>>>
> >>>> - Junit Servlet
> >>>> - Sling Testing Server Setup and Teleporter
> >>>>
> >>>> Does Sling do any server side testing?
> >>>> What is the currently support way of doing server side tests?
> >>>
> >>> Running tests inside the OSGi container is the default when using OPS4J
> >> Pax
> >>> Exam. See the list of Sling modules using Sling's Testing PaxExam and
> >> have a
> >>> look what the ITs are doing to get some ideas:
> >>>
> >>>
> https://sling.apache.org/documentation/development/testing-paxexam.html
> >>>
> >>> Let me know if more documentation is needed.
> >>>
> >>> HTH,
> >>> O.
> >>>
> >>>
> >>>> Thanks - Andy
> >>>
> >>>
> >>>
> >>>
> >>
> >>
>
>

Re: Server-Side Testing

Posted by Andreas Schaefer <sc...@me.com.INVALID>.
Hi

As mentioned in my previous email I ran into an issue with Composum as I could not open it with the Pax Tests even though I included composum() setup.

I could fix that with this line:

mavenBundle().groupId("org.apache.geronimo.bundles").artifactId("jstl").version("1.2_1"),

I have another question regarding uploading a file. I was able to use Jsoup to upload a file to create a file node in Sling.
I am wondering if there is a way with PaxExam to do that with a direct API exam as my tests are not there to test the REST Api but rather to make sure my code is working?

Anyhow Jsoup will work fine if it is the only way.

- Andy

> On Aug 23, 2022, at 11:03 AM, Eric Norman <en...@apache.org> wrote:
> 
> Hi Andy,
> 
> What I usually do for debugging/inspecting the pax exam instance is to add
> optional configuration to enable remote debugging (see [1]).  Then you can
> set a breakpoint in your test code and it will stop there for you to take a
> look around.
> 
> One example of this is at:
> 1, AuthFormTestSupport.java#L94
> <https://github.com/apache/sling-org-apache-sling-auth-form/blob/0040aac8a3a89a0cfc4727f2802bd560803c4c8a/src/test/java/org/apache/sling/auth/form/it/AuthFormTestSupport.java#L94>
> 
> 
> Hope that helps.
> 
> Regards,
> Eric
> 
> 
> On Mon, Aug 22, 2022 at 2:14 PM Andreas Schaefer <sc...@me.com.invalid>
> wrote:
> 
>> Hi Oliver
>> 
>> I am making good progress but I noticed that I cannot get composum up on
>> both 3.1.0 or 3.0.0 which is the current version I am using because I am
>> still running against Sling 11.
>> 
>> The issues I see is: 'The absolute uri: http://java.sun.com/jsp/jstl/core
>> cannot be resolved’
>> 
>> Also is there a way to keep the Sling instance running (something like
>> keep running flag) after the tests were done in case I need to investigate
>> an issue with the Sling instance like bundles dependencies etc?
>> 
>> Thanks - Andy
>> 
>> 
>>> On Aug 15, 2022, at 2:20 AM, Oliver Lietz <ap...@oliverlietz.de> wrote:
>>> 
>>> On Sunday, 14 August 2022 23:15:16 CEST Andreas Schaefer wrote:
>>>> Hi
>>> 
>>> Hi Andy,
>>> 
>>>> I am working on some sling components and want to IT test them within
>> the
>>>> server to avoid client-side polling.
>>>> 
>>>> It looks like there are two ways to do that:
>>>> 
>>>> - Junit Servlet
>>>> - Sling Testing Server Setup and Teleporter
>>>> 
>>>> Does Sling do any server side testing?
>>>> What is the currently support way of doing server side tests?
>>> 
>>> Running tests inside the OSGi container is the default when using OPS4J
>> Pax
>>> Exam. See the list of Sling modules using Sling's Testing PaxExam and
>> have a
>>> look what the ITs are doing to get some ideas:
>>> 
>>> https://sling.apache.org/documentation/development/testing-paxexam.html
>>> 
>>> Let me know if more documentation is needed.
>>> 
>>> HTH,
>>> O.
>>> 
>>> 
>>>> Thanks - Andy
>>> 
>>> 
>>> 
>>> 
>> 
>> 


Re: Server-Side Testing

Posted by Eric Norman <en...@apache.org>.
Hi Andy,

What I usually do for debugging/inspecting the pax exam instance is to add
optional configuration to enable remote debugging (see [1]).  Then you can
set a breakpoint in your test code and it will stop there for you to take a
look around.

One example of this is at:
1, AuthFormTestSupport.java#L94
<https://github.com/apache/sling-org-apache-sling-auth-form/blob/0040aac8a3a89a0cfc4727f2802bd560803c4c8a/src/test/java/org/apache/sling/auth/form/it/AuthFormTestSupport.java#L94>


Hope that helps.

Regards,
Eric


On Mon, Aug 22, 2022 at 2:14 PM Andreas Schaefer <sc...@me.com.invalid>
wrote:

> Hi Oliver
>
> I am making good progress but I noticed that I cannot get composum up on
> both 3.1.0 or 3.0.0 which is the current version I am using because I am
> still running against Sling 11.
>
> The issues I see is: 'The absolute uri: http://java.sun.com/jsp/jstl/core
> cannot be resolved’
>
> Also is there a way to keep the Sling instance running (something like
> keep running flag) after the tests were done in case I need to investigate
> an issue with the Sling instance like bundles dependencies etc?
>
> Thanks - Andy
>
>
> > On Aug 15, 2022, at 2:20 AM, Oliver Lietz <ap...@oliverlietz.de> wrote:
> >
> > On Sunday, 14 August 2022 23:15:16 CEST Andreas Schaefer wrote:
> >> Hi
> >
> > Hi Andy,
> >
> >> I am working on some sling components and want to IT test them within
> the
> >> server to avoid client-side polling.
> >>
> >> It looks like there are two ways to do that:
> >>
> >> - Junit Servlet
> >> - Sling Testing Server Setup and Teleporter
> >>
> >> Does Sling do any server side testing?
> >> What is the currently support way of doing server side tests?
> >
> > Running tests inside the OSGi container is the default when using OPS4J
> Pax
> > Exam. See the list of Sling modules using Sling's Testing PaxExam and
> have a
> > look what the ITs are doing to get some ideas:
> >
> > https://sling.apache.org/documentation/development/testing-paxexam.html
> >
> > Let me know if more documentation is needed.
> >
> > HTH,
> > O.
> >
> >
> >> Thanks - Andy
> >
> >
> >
> >
>
>

Re: Server-Side Testing

Posted by Oliver Lietz <ap...@oliverlietz.de>.
On Monday, 22 August 2022 23:14:12 CEST Andreas Schaefer wrote:
> Hi Oliver

Hi Andy,

> I am making good progress but I noticed that I cannot get composum up on
> both 3.1.0 or 3.0.0 which is the current version I am using because I am
> still running against Sling 11.

Testing PaxExam provides an option for Composum - have you checked?

https://github.com/apache/sling-org-apache-sling-testing-paxexam/blob/
9451309852a723aecd3395b72f05f356e4d55baf/src/main/java/org/apache/sling/
testing/paxexam/SlingOptions.java#L1199

> The issues I see is: 'The absolute uri: http://java.sun.com/jsp/jstl/core
> cannot be resolved’
> 
> Also is there a way to keep the Sling instance running (something like keep
> running flag) after the tests were done in case I need to investigate an
> issue with the Sling instance like bundles dependencies etc?

I'm not aware of a feature in Pax Exam and how it could work as multiple 
instances could be started for a single test class (per test method).
If you want to keep an instance up for some time you could reference a non-
existing service via @Inject (with filter incl. timeout). Or debug as described 
by Eric.

Do you have some code to share? Or are you able to discuss on Slack?

Regards,
O.


> Thanks - Andy
> 
> > On Aug 15, 2022, at 2:20 AM, Oliver Lietz <ap...@oliverlietz.de> wrote:
> > 
> > On Sunday, 14 August 2022 23:15:16 CEST Andreas Schaefer wrote:
> >> Hi
> > 
> > Hi Andy,
> > 
> >> I am working on some sling components and want to IT test them within the
> >> server to avoid client-side polling.
> >> 
> >> It looks like there are two ways to do that:
> >> 
> >> - Junit Servlet
> >> - Sling Testing Server Setup and Teleporter
> >> 
> >> Does Sling do any server side testing?
> >> What is the currently support way of doing server side tests?
> > 
> > Running tests inside the OSGi container is the default when using OPS4J
> > Pax
> > Exam. See the list of Sling modules using Sling's Testing PaxExam and have
> > a look what the ITs are doing to get some ideas:
> > 
> > https://sling.apache.org/documentation/development/testing-paxexam.html
> > 
> > Let me know if more documentation is needed.
> > 
> > HTH,
> > O.
> > 
> >> Thanks - Andy





Re: Server-Side Testing

Posted by Andreas Schaefer <sc...@me.com.INVALID>.
Hi Oliver

I am making good progress but I noticed that I cannot get composum up on both 3.1.0 or 3.0.0 which is the current version I am using because I am still running against Sling 11.

The issues I see is: 'The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved’

Also is there a way to keep the Sling instance running (something like keep running flag) after the tests were done in case I need to investigate an issue with the Sling instance like bundles dependencies etc?

Thanks - Andy


> On Aug 15, 2022, at 2:20 AM, Oliver Lietz <ap...@oliverlietz.de> wrote:
> 
> On Sunday, 14 August 2022 23:15:16 CEST Andreas Schaefer wrote:
>> Hi
> 
> Hi Andy,
> 
>> I am working on some sling components and want to IT test them within the
>> server to avoid client-side polling.
>> 
>> It looks like there are two ways to do that:
>> 
>> - Junit Servlet
>> - Sling Testing Server Setup and Teleporter
>> 
>> Does Sling do any server side testing?
>> What is the currently support way of doing server side tests?
> 
> Running tests inside the OSGi container is the default when using OPS4J Pax 
> Exam. See the list of Sling modules using Sling's Testing PaxExam and have a 
> look what the ITs are doing to get some ideas:
> 
> https://sling.apache.org/documentation/development/testing-paxexam.html
> 
> Let me know if more documentation is needed.
> 
> HTH,
> O.
> 
> 
>> Thanks - Andy
> 
> 
> 
> 


Re: Server-Side Testing

Posted by Oliver Lietz <ap...@oliverlietz.de>.
On Sunday, 14 August 2022 23:15:16 CEST Andreas Schaefer wrote:
> Hi

Hi Andy,

> I am working on some sling components and want to IT test them within the
> server to avoid client-side polling.
> 
> It looks like there are two ways to do that:
> 
> - Junit Servlet
> - Sling Testing Server Setup and Teleporter
> 
> Does Sling do any server side testing?
> What is the currently support way of doing server side tests?

Running tests inside the OSGi container is the default when using OPS4J Pax 
Exam. See the list of Sling modules using Sling's Testing PaxExam and have a 
look what the ITs are doing to get some ideas:

https://sling.apache.org/documentation/development/testing-paxexam.html

Let me know if more documentation is needed.

HTH,
O.


> Thanks - Andy