Re: Programmatically add new http connector in Jetty from Karaf

2017-09-12 Thread Nicolas Brasey
Hi Achim,

Yes you are right, not an easy one...I understand.

Or, like you proposed, what about providing an API to configure the virtual
hosts? I believe virtual hosts are supported by all the containers pax web
supports, right ? This should be sufficient for my use case.

But like I said, I have a workaround at the moment, so that's cool :-)

Cheers,
Nicolas




On Tue, Sep 12, 2017 at 6:02 PM, 'Achim Nierbeck' via OPS4J <
ops4j@googlegroups.com> wrote:

> Hi Nicolas,
>
> this would require, that we open an API for every supported Container ...
> still thinking about how to handle that :/
> Please open an issue for your new requirements ...
> but don't know how fast people are to actually get to it.
>
> Regards, Achim
>
>
> 2017-09-12 17:56 GMT+02:00 Nicolas Brasey <nicolas.bra...@gmail.com>:
>
>> Hi Achim,
>>
>> Thanks a lot for your answer. Yes I think it would be good to be able to
>> access directly the lower http server for deeper customization. Do you
>> think this would be possible to have it scheduled for the future releases ?
>> Let me know if I should create a new story for that...
>>
>> In the mean time, we will manage our own jetty server in the application
>> directly to serve our angular and react applications which are only static
>> resources apps. And keep the existing karaf jetty server for our backend
>> rest resources.
>>
>> Thanks again!
>>
>> Best regards,
>> Nicolas
>>
>>
>>
>> On Sun, Sep 10, 2017 at 8:20 AM, 'Achim Nierbeck' via OPS4J <
>> ops4j@googlegroups.com> wrote:
>>
>>> Hi Nicolas,
>>>
>>> I fear right now this isn't possible.
>>> As Pax Web doesn't expose a "Jetty service".
>>>
>>> It would need the following changes:
>>> The JettyFactory would also need to listen to Connectors and restart the
>>> jetty instance every time this changes.
>>>
>>> But what you could do:
>>> Configure a bunch of connectors (Virtual Hosts) on Jetty, so they are
>>> available.
>>> Now your webapp-mgmnt application registers each new application with a
>>> new configuration bound to a free instance of your already configured
>>> virtual hosts.
>>>
>>> Take a look at the following sample:
>>> https://github.com/ops4j/org.ops4j.pax.web/blob/master/sampl
>>> es/whiteboard-extended/src/main/java/org/ops4j/pax/web/exten
>>> der/samples/whiteboard/internal/Activator.java
>>>
>>> regards, Achim
>>>
>>>
>>>
>>> 2017-09-07 13:27 GMT+02:00 Nicolas Brasey <nicolas.bra...@gmail.com>:
>>>
>>>> Hi,
>>>>
>>>> With Karaf 4.1.2, I'm trying to programmatically configure Jetty to
>>>> deploy web bundles on different http ports.
>>>>
>>>> For example, I'm trying the achieve the following scenario:
>>>>
>>>> Karaf root instance:
>>>>admin-web-app on port 8181
>>>>
>>>> Karaf instance 1:
>>>>my-web-app-1 on port 10081
>>>>
>>>> Karaf instance 2:
>>>>my-web-app-2 on port 10082
>>>>
>>>> Karaf instance 3:
>>>>my-web-app-1 on port 10083
>>>>my-web-app-3 on port 10084
>>>>
>>>>
>>>> But this scenario is also possible:
>>>>
>>>> Karaf root instance:
>>>>admin-web-app on port 8181
>>>>my-web-app-1 on port 10081
>>>>my-web-app-1 on port 10082
>>>>my-web-app-2 on port 10083
>>>>my-web-app-3 on port 10084
>>>>
>>>>
>>>> My constraints are that the ports and the context path is not known at
>>>> compile time, it will be dynamically resolved at runtime from a deployment
>>>> configuration file.
>>>>
>>>> What would be the best approach to implement such thing ?
>>>>
>>>> My initial idea would be to have a webapp-mgmnt module who listens on
>>>> new web bundle and deploys it properly using the configuration setting
>>>> (ports, instances).
>>>>
>>>> Some initial questions I have:
>>>>
>>>> 1) How to listen on new bundle that have a give meta information in the
>>>> manifest ?
>>>> 2) How to access the Jetty server from the app code ?
>>>>
>>>> Thanks a lot
>>>> Nicolas
>>>>
>>>> --
>>>> --
>>>> --
>

Re: Programmatically add new http connector in Jetty from Karaf

2017-09-12 Thread Nicolas Brasey
Hi Achim,

Thanks a lot for your answer. Yes I think it would be good to be able to
access directly the lower http server for deeper customization. Do you
think this would be possible to have it scheduled for the future releases ?
Let me know if I should create a new story for that...

In the mean time, we will manage our own jetty server in the application
directly to serve our angular and react applications which are only static
resources apps. And keep the existing karaf jetty server for our backend
rest resources.

Thanks again!

Best regards,
Nicolas



On Sun, Sep 10, 2017 at 8:20 AM, 'Achim Nierbeck' via OPS4J <
ops4j@googlegroups.com> wrote:

> Hi Nicolas,
>
> I fear right now this isn't possible.
> As Pax Web doesn't expose a "Jetty service".
>
> It would need the following changes:
> The JettyFactory would also need to listen to Connectors and restart the
> jetty instance every time this changes.
>
> But what you could do:
> Configure a bunch of connectors (Virtual Hosts) on Jetty, so they are
> available.
> Now your webapp-mgmnt application registers each new application with a
> new configuration bound to a free instance of your already configured
> virtual hosts.
>
> Take a look at the following sample:
> https://github.com/ops4j/org.ops4j.pax.web/blob/master/
> samples/whiteboard-extended/src/main/java/org/ops4j/pax/
> web/extender/samples/whiteboard/internal/Activator.java
>
> regards, Achim
>
>
>
> 2017-09-07 13:27 GMT+02:00 Nicolas Brasey <nicolas.bra...@gmail.com>:
>
>> Hi,
>>
>> With Karaf 4.1.2, I'm trying to programmatically configure Jetty to
>> deploy web bundles on different http ports.
>>
>> For example, I'm trying the achieve the following scenario:
>>
>> Karaf root instance:
>>admin-web-app on port 8181
>>
>> Karaf instance 1:
>>my-web-app-1 on port 10081
>>
>> Karaf instance 2:
>>my-web-app-2 on port 10082
>>
>> Karaf instance 3:
>>my-web-app-1 on port 10083
>>my-web-app-3 on port 10084
>>
>>
>> But this scenario is also possible:
>>
>> Karaf root instance:
>>admin-web-app on port 8181
>>my-web-app-1 on port 10081
>>my-web-app-1 on port 10082
>>my-web-app-2 on port 10083
>>my-web-app-3 on port 10084
>>
>>
>> My constraints are that the ports and the context path is not known at
>> compile time, it will be dynamically resolved at runtime from a deployment
>> configuration file.
>>
>> What would be the best approach to implement such thing ?
>>
>> My initial idea would be to have a webapp-mgmnt module who listens on new
>> web bundle and deploys it properly using the configuration setting (ports,
>> instances).
>>
>> Some initial questions I have:
>>
>> 1) How to listen on new bundle that have a give meta information in the
>> manifest ?
>> 2) How to access the Jetty server from the app code ?
>>
>> Thanks a lot
>> Nicolas
>>
>> --
>> --
>> --
>> OPS4J - http://www.ops4j.org - ops4j@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+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
>
> Apache Member
> Apache Karaf <http://karaf.apache.org/> Committer & PMC
> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
> Project Lead
> blog <http://notizblog.nierbeck.de/>
> Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>
>
> Software Architect / Project Manager / Scrum Master
>
> --
> --
> --
> OPS4J - http://www.ops4j.org - ops4j@googlegroups.com
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "OPS4J" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/ops4j/3Us5goEd9es/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> ops4j+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Programmatically add new http connector in Jetty from Karaf

2017-09-07 Thread Nicolas Brasey
Hi,

With Karaf 4.1.2, I'm trying to programmatically configure Jetty to deploy 
web bundles on different http ports.

For example, I'm trying the achieve the following scenario:

Karaf root instance:
   admin-web-app on port 8181

Karaf instance 1:
   my-web-app-1 on port 10081

Karaf instance 2:
   my-web-app-2 on port 10082

Karaf instance 3:
   my-web-app-1 on port 10083
   my-web-app-3 on port 10084


But this scenario is also possible:

Karaf root instance:
   admin-web-app on port 8181
   my-web-app-1 on port 10081
   my-web-app-1 on port 10082
   my-web-app-2 on port 10083
   my-web-app-3 on port 10084


My constraints are that the ports and the context path is not known at 
compile time, it will be dynamically resolved at runtime from a deployment 
configuration file.
 
What would be the best approach to implement such thing ? 

My initial idea would be to have a webapp-mgmnt module who listens on new 
web bundle and deploys it properly using the configuration setting (ports, 
instances). 

Some initial questions I have:

1) How to listen on new bundle that have a give meta information in the 
manifest ?
2) How to access the Jetty server from the app code ?

Thanks a lot
Nicolas

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pax-exam] How to simulate beforeClass / afterClass hook *outside* of the OSGi container

2017-08-08 Thread Nicolas Brasey
The server mode is not enough for me, as I would like to be able to write
tests against the OSGi services directly, I don't want to use the external
REST api.

Out of curiosity, and not knowing how exactly pax-exam works in details,
what is the reason the BeforeClass and AfterClass are not implemented ?

For me, the "simplest" would be to introduce certain hooks, for example:

a) BeforeClass (called once before the tests are executed, outside of the
container)
b) Probe bundle Activate (called once before the tests are executed, inside
of the container)
c) Probe bundle Deactivate (called once after the tests, inside the
container)
d) AfterClass (called once after the tests are executed, outside of the
container)

Maybe the same for the before and after hooks. One hook called from
outside, one from inside.

My 2 cents...

Nicolas




On Tue, Aug 8, 2017 at 10:00 AM, Toni Menzel <toni.men...@rebaze.com> wrote:

> This is the very simple server mode (i did that back then). If it is
> enough for you, sure. No big deal. You don't get any lifecycle integration
> with your test framework and you need to do the configuration for accessing
> your server yourself (sure, if its only rest, you have all the tools of the
> world)
>
>
>
>
> *www.rebaze.de <http://www.rebaze.de/> | www.rebaze.com
> <http://www.rebaze.com/> | @rebazeio <https://twitter.com/rebazeio>*
>
> On Tue, Aug 8, 2017 at 9:54 AM, 'Achim Nierbeck' via OPS4J <
> ops4j@googlegroups.com> wrote:
>
>> Hi Nicolas,
>>
>> then you are looking for this:
>> https://ops4j1.jira.com/wiki/display/PAXEXAM4/Server+Mode
>>
>> @toni, it's already available ;)
>>
>> regards, Achim
>>
>>
>> 2017-08-08 9:38 GMT+02:00 Nicolas Brasey <nicolas.bra...@gmail.com>:
>>
>>> Hi Achim,
>>>
>>> No, I'm not so much interested to test the OSGi mechanics, I want to
>>> have high level business tests on our business layer which is a set of OSGi
>>> services. This requires the database and the messaging system to run as
>>> well.
>>>
>>> In fact, our app provides only rest api's from outside, and we have
>>> already a set of mocha integration tests. Mocha is fine for testing rest
>>> message structure and non-regression at the level but a little cumbersome
>>> and hard to maintain when it comes to test more complicated business
>>> scenarios. That is why I'm looking for a Java API in order to implement
>>> those tests, pax-exam is ideal for me in that context.
>>>
>>> Cheers,
>>> Nicolas
>>>
>>>
>>>
>>>
>>> On Tue, Aug 8, 2017 at 8:29 AM, 'Achim Nierbeck' via OPS4J <
>>> ops4j@googlegroups.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> just one question came to my mind, regarding your scenario.
>>>> For your Integration tests you don't seem to rely on testing the
>>>> internals of the OSGi container, right?
>>>> In that case how about starting the Pax Exam tests as server tests,
>>>> that way you only need to call externally available interfaces and can make
>>>> sure you have neo4j started prior to that.
>>>>
>>>> regards, Achim
>>>>
>>>>
>>>> 2017-08-07 11:14 GMT+02:00 Nicolas Brasey <nicolas.bra...@gmail.com>:
>>>>
>>>>> Hi Christoph,
>>>>>
>>>>> Yes, that is exactly what I tried already, to bundle neo4j and all the
>>>>> dependencies with the maven shade plugin (like the ones in service
>>>>> mix bundles). I realized that this is not really ideal for the
>>>>> following reasons:
>>>>>
>>>>> 1) The build time exploded, to create this huge jar takes more than
>>>>> 1minutes and 30 secs
>>>>> 2) The pom.xml is far from being straight forward to write, you need
>>>>> to have a good understanding of the internal structure of neo4j in order 
>>>>> to
>>>>> maintain it. Also, I'm afraid this is time consuming on the long term and
>>>>> will requires tricky changes for each major release of neo4j.
>>>>> 3) It was not even working! I had issues with neo4j internal way of
>>>>> loading modules with the java 6 ServiceLoader mechanism, which did not 
>>>>> find
>>>>> http services for reasons I still ignore...
>>>>>
>>>>> Anyway, I finally gave up fighting with it ;-)
>>>>>
>>>>>
>>>>>
>>>>>
>>

Re: [pax-exam] How to simulate beforeClass / afterClass hook *outside* of the OSGi container

2017-08-08 Thread Nicolas Brasey
Hi Achim,

No, I'm not so much interested to test the OSGi mechanics, I want to have
high level business tests on our business layer which is a set of OSGi
services. This requires the database and the messaging system to run as
well.

In fact, our app provides only rest api's from outside, and we have already
a set of mocha integration tests. Mocha is fine for testing rest message
structure and non-regression at the level but a little cumbersome and hard
to maintain when it comes to test more complicated business scenarios. That
is why I'm looking for a Java API in order to implement those tests,
pax-exam is ideal for me in that context.

Cheers,
Nicolas




On Tue, Aug 8, 2017 at 8:29 AM, 'Achim Nierbeck' via OPS4J <
ops4j@googlegroups.com> wrote:

> Hi,
>
> just one question came to my mind, regarding your scenario.
> For your Integration tests you don't seem to rely on testing the internals
> of the OSGi container, right?
> In that case how about starting the Pax Exam tests as server tests, that
> way you only need to call externally available interfaces and can make sure
> you have neo4j started prior to that.
>
> regards, Achim
>
>
> 2017-08-07 11:14 GMT+02:00 Nicolas Brasey <nicolas.bra...@gmail.com>:
>
>> Hi Christoph,
>>
>> Yes, that is exactly what I tried already, to bundle neo4j and all the
>> dependencies with the maven shade plugin (like the ones in service mix
>> bundles). I realized that this is not really ideal for the following
>> reasons:
>>
>> 1) The build time exploded, to create this huge jar takes more than
>> 1minutes and 30 secs
>> 2) The pom.xml is far from being straight forward to write, you need to
>> have a good understanding of the internal structure of neo4j in order to
>> maintain it. Also, I'm afraid this is time consuming on the long term and
>> will requires tricky changes for each major release of neo4j.
>> 3) It was not even working! I had issues with neo4j internal way of
>> loading modules with the java 6 ServiceLoader mechanism, which did not find
>> http services for reasons I still ignore...
>>
>> Anyway, I finally gave up fighting with it ;-)
>>
>>
>>
>>
>>
>> On Sat, Aug 5, 2017 at 1:50 PM, 'Christoph Läubrich' via OPS4J <
>> ops4j@googlegroups.com> wrote:
>>
>>> Even though neo4j is not "osgi-friendly" (what ever that means ;-) you
>>> can create abundle that embedds all that neo4j requires, add an Activator
>>> that starts up your db and provide a custom service to trigger
>>> "after-test-checks" in whatever way you need. In your test you can the
>>> collect the service to
>>>
>>> a) make sure the db is up and running
>>> b) fire your checks whenever needed
>>>
>>> Am 04.08.2017 11:59, schrieb Nicolas Brasey:
>>>
>>> Hi,
>>>
>>> Context: I want to use pax-exam for our business integration tests that
>>> needs to have a database (neo4j) that is not OSGi friendly running before
>>> the test are executed. we use maven.
>>>
>>> Also, neo4j provides a embedded server that works extremely well outside
>>> of an OSGi container, but I can't find a way to start this embedded server
>>> with pax-exam outside of the container before the pax-exam machinery is
>>> starting.
>>>
>>> The idea is to start the database in the non-OSGi context when the
>>> pax-runner is starting, something like the beforeClass, and stop the
>>> database after all the tests are finished ala afterClass.
>>>
>>> Does anyone has an idea how to do this ?
>>>
>>> Thanks
>>> Nicolas
>>> --
>>> --
>>> --
>>> OPS4J - http://www.ops4j.org - ops4j@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+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>>> --
>>> --
>>> --
>>> OPS4J - http://www.ops4j.org - ops4j@googlegroups.com
>>>
>>> ---
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "OPS4J" group.
>>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>>> pic/ops4j/RlgwSX04-O8/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to

Re: [pax-exam] How to simulate beforeClass / afterClass hook *outside* of the OSGi container

2017-08-07 Thread Nicolas Brasey
Hi Christoph,

Yes, that is exactly what I tried already, to bundle neo4j and all the
dependencies with the maven shade plugin (like the ones in service mix
bundles). I realized that this is not really ideal for the following
reasons:

1) The build time exploded, to create this huge jar takes more than
1minutes and 30 secs
2) The pom.xml is far from being straight forward to write, you need to
have a good understanding of the internal structure of neo4j in order to
maintain it. Also, I'm afraid this is time consuming on the long term and
will requires tricky changes for each major release of neo4j.
3) It was not even working! I had issues with neo4j internal way of loading
modules with the java 6 ServiceLoader mechanism, which did not find http
services for reasons I still ignore...

Anyway, I finally gave up fighting with it ;-)





On Sat, Aug 5, 2017 at 1:50 PM, 'Christoph Läubrich' via OPS4J <
ops4j@googlegroups.com> wrote:

> Even though neo4j is not "osgi-friendly" (what ever that means ;-) you can
> create abundle that embedds all that neo4j requires, add an Activator that
> starts up your db and provide a custom service to trigger
> "after-test-checks" in whatever way you need. In your test you can the
> collect the service to
>
> a) make sure the db is up and running
> b) fire your checks whenever needed
>
> Am 04.08.2017 11:59, schrieb Nicolas Brasey:
>
> Hi,
>
> Context: I want to use pax-exam for our business integration tests that
> needs to have a database (neo4j) that is not OSGi friendly running before
> the test are executed. we use maven.
>
> Also, neo4j provides a embedded server that works extremely well outside
> of an OSGi container, but I can't find a way to start this embedded server
> with pax-exam outside of the container before the pax-exam machinery is
> starting.
>
> The idea is to start the database in the non-OSGi context when the
> pax-runner is starting, something like the beforeClass, and stop the
> database after all the tests are finished ala afterClass.
>
> Does anyone has an idea how to do this ?
>
> Thanks
> Nicolas
> --
> --
> --
> OPS4J - http://www.ops4j.org - ops4j@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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> --
> --
> OPS4J - http://www.ops4j.org - ops4j@googlegroups.com
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "OPS4J" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/ops4j/RlgwSX04-O8/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> ops4j+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pax-exam] How to simulate beforeClass / afterClass hook *outside* of the OSGi container

2017-08-04 Thread Nicolas Brasey
On Fri, Aug 4, 2017 at 3:39 PM, Toni Menzel <toni.men...@rebaze.com> wrote:

> So, about the imports: yes, well there used to be an option to let you
> mark all generated imports to be optional for the probe. Have to look at
> this.
>
>
Ok I will look into this option, thanks for the tips.



> About the Acceptance Driver: yes it will work with any Pax Exam Test
> Container. Stay tuned.
>
> Amazing, looking forward!



> About the pre/post hooks: can you try implementing a Junit Rule?
> https://github.com/junit-team/junit4/wiki/Rules (see
> ExternalResourcesRule). This will give you the right amount of control.
> But, I guess you will still get superfluous (and unresolvable) imports for
> that even though they will not be really executed in-container.
> Need to update myself how to overwrite that..
>

So, do you mean the Junit rule as pre/post test is executed outside of the
container ? I thought it was executed in the container



>
>
>
>
>
> *www.rebaze.de <http://www.rebaze.de/> | www.rebaze.com
> <http://www.rebaze.com/> | @rebazeio <https://twitter.com/rebazeio>*
>
> On Fri, Aug 4, 2017 at 2:39 PM, Nicolas Brasey <nicolas.bra...@gmail.com>
> wrote:
>
>> Hi Tony,
>>
>> Thanks a lot for your answer.
>>
>> I think what you are working on is absolutely great, and I think it would
>> also perfectly fit for our needs. Starting the OSGi container from a junit
>> rule makes the tests cleaner. I guess this would also work with Karaf,
>> right ? But, just for the curiosity, how do you plan to access the OSGi
>> service from outside the container ? And when do you plan to push your
>> local branch ? :-)
>>
>> 2) Yes I tried booting neo4j from the @Configuration method, but there 2
>> issues IMHO:
>> a) It provides only a way to start neo4j, obviously no hook to run some
>> post tests code
>> b) since the configure code is also deployed as an OSGi bundle, it forces
>> you to make sure the  does not include the neo4j
>> packages, which cannot be resolved. It is feasible, but this is hard work
>> and I'm not sure about the maintainability of this over the time
>>
>> 3) Not sure I understood your proposal with the RunWith. Do you mean
>> implementing my own Junit runner that wraps the PaxExam runner, and run my
>> tests with it ?
>>
>>
>> Cheers,
>> Nicolas
>>
>>
>> On Fri, Aug 4, 2017 at 12:47 PM, Toni Menzel <toni.men...@rebaze.com>
>> wrote:
>>
>>> Hey Nicolas,
>>>
>>> I think you are looking at something like the (new) acceptance test api
>>> that runs from outside of
>>> osgi: https://github.com/ops4j/org.ops4j.pax.exam2/blob/mast
>>> er/drivers/pax-exam-acceptance/src/test/java/org/ops4j/pax/
>>> exam/acceptance/AcceptanceTestApiTest.java
>>>
>>> This is currently in active development and is lacking some features
>>> like smooth access to OSGi Services from the outside.
>>> Currently, only the rest client is available (using RestAssured), but I
>>> a new one making internal services available to the test automatically is
>>> already on my local branch.
>>>
>>> In any way, we also could think of making out-of-container setup code
>>> available in regular "@RunWith(PaxExam.class)" tests. Did you try booting
>>> Neo4j inside the @Configuration method? that is executed before the OSGi
>>> container is launched, so it does run in plain java.
>>>
>>> Another try: did you try using a Junit Rule with "@RunWith()"? this
>>> should work, too.
>>>
>>> Toni
>>>
>>>
>>>
>>>
>>> *www.rebaze.de <http://www.rebaze.de/> | www.rebaze.com
>>> <http://www.rebaze.com/> | @rebazeio <https://twitter.com/rebazeio>*
>>>
>>> On Fri, Aug 4, 2017 at 11:59 AM, Nicolas Brasey <
>>> nicolas.bra...@gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> Context: I want to use pax-exam for our business integration tests that
>>>> needs to have a database (neo4j) that is not OSGi friendly running before
>>>> the test are executed. we use maven.
>>>>
>>>> Also, neo4j provides a embedded server that works extremely well
>>>> outside of an OSGi container, but I can't find a way to start this embedded
>>>> server with pax-exam outside of the container before the pax-exam machinery
>>>> is starting.
>>>>
>>>> The idea is to start the database in the non-OSGi context w

Re: [pax-exam] How to simulate beforeClass / afterClass hook *outside* of the OSGi container

2017-08-04 Thread Nicolas Brasey
Hi Tony,

Thanks a lot for your answer.

I think what you are working on is absolutely great, and I think it would
also perfectly fit for our needs. Starting the OSGi container from a junit
rule makes the tests cleaner. I guess this would also work with Karaf,
right ? But, just for the curiosity, how do you plan to access the OSGi
service from outside the container ? And when do you plan to push your
local branch ? :-)

2) Yes I tried booting neo4j from the @Configuration method, but there 2
issues IMHO:
a) It provides only a way to start neo4j, obviously no hook to run some
post tests code
b) since the configure code is also deployed as an OSGi bundle, it forces
you to make sure the  does not include the neo4j packages,
which cannot be resolved. It is feasible, but this is hard work and I'm not
sure about the maintainability of this over the time

3) Not sure I understood your proposal with the RunWith. Do you mean
implementing my own Junit runner that wraps the PaxExam runner, and run my
tests with it ?


Cheers,
Nicolas


On Fri, Aug 4, 2017 at 12:47 PM, Toni Menzel <toni.men...@rebaze.com> wrote:

> Hey Nicolas,
>
> I think you are looking at something like the (new) acceptance test api
> that runs from outside of
> osgi: https://github.com/ops4j/org.ops4j.pax.exam2/
> blob/master/drivers/pax-exam-acceptance/src/test/java/org/
> ops4j/pax/exam/acceptance/AcceptanceTestApiTest.java
>
> This is currently in active development and is lacking some features like
> smooth access to OSGi Services from the outside.
> Currently, only the rest client is available (using RestAssured), but I a
> new one making internal services available to the test automatically is
> already on my local branch.
>
> In any way, we also could think of making out-of-container setup code
> available in regular "@RunWith(PaxExam.class)" tests. Did you try booting
> Neo4j inside the @Configuration method? that is executed before the OSGi
> container is launched, so it does run in plain java.
>
> Another try: did you try using a Junit Rule with "@RunWith()"? this should
> work, too.
>
> Toni
>
>
>
>
> *www.rebaze.de <http://www.rebaze.de/> | www.rebaze.com
> <http://www.rebaze.com/> | @rebazeio <https://twitter.com/rebazeio>*
>
> On Fri, Aug 4, 2017 at 11:59 AM, Nicolas Brasey <nicolas.bra...@gmail.com>
> wrote:
>
>> Hi,
>>
>> Context: I want to use pax-exam for our business integration tests that
>> needs to have a database (neo4j) that is not OSGi friendly running before
>> the test are executed. we use maven.
>>
>> Also, neo4j provides a embedded server that works extremely well outside
>> of an OSGi container, but I can't find a way to start this embedded server
>> with pax-exam outside of the container before the pax-exam machinery is
>> starting.
>>
>> The idea is to start the database in the non-OSGi context when the
>> pax-runner is starting, something like the beforeClass, and stop the
>> database after all the tests are finished ala afterClass.
>>
>> Does anyone has an idea how to do this ?
>>
>> Thanks
>> Nicolas
>>
>> --
>> --
>> --
>> OPS4J - http://www.ops4j.org - ops4j@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+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> --
> --
> OPS4J - http://www.ops4j.org - ops4j@googlegroups.com
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "OPS4J" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/ops4j/RlgwSX04-O8/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> ops4j+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.