[pax exam] Running code outside the OSGi container

20 views
Skip to first unread message

Christian Schneider

unread,
May 4, 2018, 11:22:54 AM5/4/18
to op...@googlegroups.com
I would like to have code executed outside of the OSGi container in the process where junit runs.

This used to work with @BeforeClass in older versions of pax exam. Now these methods are also run in OSGi.

Is there some way to run my code outside in a generic way?

What I did until now is to extend pax exam an override the run method. Is there maybe a built in way that avoids this?

Christian

--
--
Christian Schneider

http://www.liquid-reality.de

Computer Scientist

Christoph Läubrich

unread,
May 4, 2018, 1:42:47 PM5/4/18
to op...@googlegroups.com
What exactly do you want to archive?

e.g. the configure method is run "outside" the container, or you can
simply have an static insitilizer and check there if an active OSGi env
is avaiable (OSGi Phase) or not (configuration phase)...

Beside that, if you are not using the forked mode all code already runns
in the same jvm process...
> --
> --
> ------------------
> OPS4J - http://www.ops4j.org - op...@googlegroups.com
>
> ---
> You received this message because you are subscribed to the Google
> Groups "OPS4J" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to ops4j+un...@googlegroups.com
> <mailto:ops4j+un...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Christian Schneider

unread,
May 5, 2018, 4:04:43 AM5/5/18
to op...@googlegroups.com
One case is to start and stop docker containers. 
Another case is to start additional OSGi containers using  PaxExamRuntime.createContainer.

I have to use forked mode. So it makes some difference.
If there is no predefined way then I will create my own class extending PaxExam that calls my hooks.

Christian

To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+unsubscribe@googlegroups.com <mailto:ops4j+unsubscribe@googlegroups.com>.

For more options, visit https://groups.google.com/d/optout.
--
--
------------------
OPS4J - http://www.ops4j.org - op...@googlegroups.com

--- You received this message because you are subscribed to the Google Groups "OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Thomas Dalton

unread,
Mar 30, 2021, 12:51:36 PM3/30/21
to OPS4J

Christian,

Were you able to figure out a solution to starting/stopping docker containers while using the PaxExam runner? I want to be able to use TestContainers (https://www.testcontainers.org/) to spin up an external DB and verify services can talk to the DB,

Thanks,
Tom
To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+un...@googlegroups.com <mailto:ops4j+un...@googlegroups.com>.

For more options, visit https://groups.google.com/d/optout.
--
--
------------------
OPS4J - http://www.ops4j.org - op...@googlegroups.com

--- You received this message because you are subscribed to the Google Groups "OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+un...@googlegroups.com.

Oliver Lietz

unread,
Mar 31, 2021, 4:41:19 AM3/31/21
to op...@googlegroups.com
On Tuesday, 30 March 2021 18:51:36 CEST Thomas Dalton wrote:
> Christian,

Hi Tom,

> Were you able to figure out a solution to starting/stopping docker
> containers while using the PaxExam runner? I want to be able to use
> TestContainers (https://www.testcontainers.org/) to spin up an external DB
> and verify services can talk to the DB,

There are modules in Apache Sling which start a Docker container during
testing with Pax Exam:

ClamAV:

https://github.com/apache/sling-org-apache-sling-commons-clam/blob/master/src/
test/java/org/apache/sling/commons/clam/it/tests/ClamTestSupport.java

MongoDB:

https://github.com/apache/sling-org-apache-sling-karaf-integration-tests/blob/
master/src/test/java/org/apache/sling/karaf/tests/bootstrap/
SlingQuickstartOakMongoIT.java

HTH,
O.
> >>> Computer Scientist
> >>> http://www.adobe.com
> >>>
> >>>
> >>> ---
> >>> You received this message because you are subscribed to the Google
> >>> Groups "OPS4J" group.
> >>
> >> To unsubscribe from this group and stop receiving emails from it, send an
> >>
> >>> email to ops4j+un...@googlegroups.com <mailto:
> >>> ops4j+un...@googlegroups.com>.
> >>>
> >>>
> >>> For more options, visit https://groups.google.com/d/optout.
> >>
> >> --- You received this message because you are subscribed to the Google
> >> Groups "OPS4J" group.
> >
> > To unsubscribe from this group and stop receiving emails from it, send an
> >
> >> email to ops4j+un...@googlegroups.com.
> >>
> >>
> >> For more options, visit https://groups.google.com/d/optout.
> >
> > Computer Scientist
> > http://www.adobe.com


--

Oliver Lietz | Wintgensweg 29 | 45481 Mülheim an der Ruhr
fon: +49 208 41191263 | fax: +49 208 41191264
email: in...@oliverlietz.de | web: oliverlietz.de


Reply all
Reply to author
Forward
0 new messages