felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mvangeert...@comcast.net
Subject Re: JUnit in Felix OSGI
Date Thu, 27 Jan 2011 20:26:54 GMT


Teemu, 



On my project, we use JUnit to test code outside of Karaf to ensure it works before deploying
into OSGi.  Then we deploy our junit-passed bundles into Karaf and the exercise them using
test-harnesses.  The test harnesses simply write data to whichever camel-endpoints the bundles
consume data from, and then looks on the camel-endpoints the bundles write to for the appropriate
output.  



This works for us because my project is mostly back-end data processing with very little gui
interaction.  If your project is similar to this, you may want to also use this approach. 





----- Original Message ----- 
From: "teemu kanstren" <tkanstren@gmail.com> 
To: users@felix.apache.org 
Sent: Thursday, January 27, 2011 3:06:55 PM 
Subject: Re: JUnit in Felix OSGI 

Yes, my terminology might have been confusing. 

My approach is usually to test using JUnit 
-smaller units (class/method combinations) separate from any bundles, 
-several of my bundles together using a simple mock BundleContext, 
-integration with the environment (Felix, external bundles) using a 
programmatic setup of Felix and programmatic control of Felix/access to 
bundlecontext, etc. 

I never could figure out why I would want to use Pax, it just always seemed 
complex and I could not figure why I would need it. But I think that is up 
to preferences. I understand I am also "stuck in the past" in the sense that 
I strongly prefer Ant over Maven :). I just prefer to understand what is 
going on in my runtime system and build environment and have the tool adapt 
to me rather than the other way around. But enough about that. I guess this 
is to say that different options are available but the choice depends.. 

Teemu 

2011/1/27 Toni Menzel <toni@okidokiteam.com> 

> Well don't confuse unit testing with integration test with system testing. 
> and others. 
> Its a different level of testing. 
> 
> On Thu, Jan 27, 2011 at 3:25 PM, teemu kanstren <tkanstren@gmail.com> 
> wrote: 
> 
> > And why do you wish to run your unit tests inside the container? I find 
> it 
> > much nicer and cleaner to run everything outside it until I really need 
> to 
> > mess with the container.. 
> > 
> > 2011/1/25 Justin Edelson <justin@justinedelson.com> 
> > 
> > > Have you looked at Pax Exam? 
> > > 
> > > On Jan 24, 2011, at 4:50 PM, Bruce Hartman <BHartman@westell.com> 
> wrote: 
> > > 
> > > > Hi, I'm new to OSGI in general.  I have a question, and will 
> appreciate 
> > > any or all of your suggestions.  I realize that I may need answers to 
> > > questions I haven't even asked yet.  Here's the background. 
> > > > 
> > > > I am creating a BundleActivator in Eclipse, adding my own code to it,

> > and 
> > > am exporting as a bundle to the bundle directory in my Felix 
> > installation. 
> > >  I am doing this in Ubuntu Linux.  This is all working well.  I can 
> > install 
> > > and run my bundle.  Just to be complete, here's a list of bundles I am 
> > > running (minus my bundle): 
> > > > 
> > > > g! lb 
> > > > START LEVEL 1 
> > > >   ID|State      |Level|Name 
> > > >    0|Active     |    0|System Bundle (3.0.6) 
> > > >    1|Active     |    1|Apache Felix Bundle Repository (1.6.2) 
> > > >    2|Active     |    1|Apache Felix Configuration Admin Service

> (1.2.8) 
> > > >    3|Active     |    1|Apache Felix Gogo Command (0.6.1) 
> > > >    4|Active     |    1|Apache Felix Gogo Runtime (0.6.1) 
> > > >    5|Active     |    1|Apache Felix Gogo Shell (0.6.1) 
> > > >    6|Active     |    1|Apache Felix Http Bundle (2.0.4) 
> > > >    7|Active     |    1|Apache Felix Http Jetty (2.0.4) 
> > > >    8|Active     |    1|Apache Felix Log Service (1.0.0) 
> > > >    9|Active     |    1|Apache Felix Web Management Console (3.1.6)

> > > >   10|Active     |    1|OSGi R4 Compendium Bundle (4.1.0) 
> > > > 
> > > > Now, I would like to add and run JUnit tests on my bundle. 
> > > > 
> > > > I downloaded the JUnit 4 jar, included it in my Eclipse project, and 
> > > don't have any problems creating and running tests in Eclipse. 
> > > > 
> > > > Here's where I start having a problem.  When I look online to find 
> out 
> > > how to run JUnit tests inside the Felix framework, the only 
> instructions 
> > I 
> > > can find is how to do it with all the IPOJO bundles.  I'm not using the 
> > > IPOJO stuff, and really don't want to include those bundles in my 
> > deployment 
> > > if I can get away with not doing it. 
> > > > 
> > > > Am I missing something?  I imagine that running JUnit tests on my 
> > bundle 
> > > inside the Felix framework would be easy.  Yet, I am having trouble 
> > figuring 
> > > out how to do it. 
> > > > 
> > > > Question 1:  Do I need the IPOJO bundles to run JUnit tests in Felix?

> > > > Question 2:  If not, how do I run JUnit tests on a bundle? 
> > > > Question 3:  If questions #1's answer is I do need the IPOJO stuff, 
> do 
> > > you have any advise as to what I should look at?  I tried adding the 
> > bundles 
> > > I thought I needed, and trying to execute "junit 2", but it says that 
> the 
> > > junit command is not available. 
> > > > 
> > > > Thanks in advance for your answers. 
> > > > 
> > > > 
> > > > 
> > > > 
> > > 
> > 
> ***************************************************************************************

> > > > This e-mail and its attachments are a private communication sent from

> > > Westell Technologies, Inc., 
> > > > a telecommunications company.  Its contents may contain confidential

> > and 
> > > proprietary information that is protected. 
> > > > If you are not the intended recipient, you are hereby notified that 
> any 
> > > disclosure, copying, distribution or use of the 
> > > > information contained in or attached to this message is strictly 
> > > prohibited.  If you have received this e-mail in error, 
> > > > please notify the sender by replying to this message, and then delete

> > it 
> > > from your system.  Thank you. 
> > > 
> > > --------------------------------------------------------------------- 
> > > To unsubscribe, e-mail: users-unsubscribe@felix.apache.org 
> > > For additional commands, e-mail: users-help@felix.apache.org 
> > > 
> > > 
> > 
> 
> 
> 
> -- 
> *Toni Menzel - http://www.okidokiteam.com* 
> 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message