You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Mohamed Nufail <nu...@gmail.com> on 2012/07/31 10:45:44 UTC

Testing Derby OSGi bundle

Hi,

For the next part of my GSoC project I'm focusing on testing the Derby OSGi
bundle.
I believe what's required in this case is to make sure the Derby bundle
operates correctly in an OSGi environment. So what is needed is to install
Derby in an OSGi framework and check if it installs correctly and have its
basic functionality.

I found the Pax Exam framework [1] can be used to achieve this easily.
Using Pax Exam we could write a normal JUnit test and it will start an OSGi
framework and installs a set of bundles we specify (which would include the
Derby bundle in this case) and then the JUnit test will be installed as a
bundle. Then the tests would be invoked.
But the problem is Pax Exam is based on JUnit 4 and Derby uses JUnit 3 I
think.

Any ideas regarding this would be appreciated.

Thanks,
Nufail.

[1] http://team.ops4j.org/wiki/display/paxexam/Pax+Exam

-- 

Mohamed Nufail
Undergraduate,
Department of Computer Science & Engineering,
University of Moratuwa.
Blog: http://www.nufailm.blogspot.com/

Re: Testing Derby OSGi bundle

Posted by Mohamed Nufail <nu...@gmail.com>.
Hi Bryan,

On Sun, Aug 5, 2012 at 10:00 PM, Bryan Pendleton <bpendleton.derby@gmail.com
> wrote:

> Hi Nufail,
>
> This sounds like a very promising approach!
>
> How are your results with this technique? It would be very interesting
> to see what a test like this looks like, even a very simple test.
>
> If you have been able to construct a test in this style, I think it would
> be great if you could attach it to a JIRA issue so that we could better
> understand the approach.
>

Actually it will be no different to a normal JUnit 4 test. We need to
provide @RunWith annotation and specify Pax Exam class and include a method
which does the configuration including, specifying the required bundles and
specifying which framework we need Felix/Equinox/other/combination of
those. Apart from that it would just be JUnit. And it can be run with JUnit
Ant task.
I'm trying out a simple test. I'll attach it to a JIRA.


>
> Do you anticipate that the testing framework would be downloaded (via
> Maven)
> by the test scripts? Or would we reference it from our tools/java
> directory like we do with other external jar files?
>

This is a problem I'm having now. The framework is distributed only via
Maven. It has about 4/5 Maven dependencies in normal use case. I used 'mvn
dependencies:copy-dependencies' command to check for the transitive
dependencies and it has a lot of jars. So not sure how exactly we can get
the jars.
I asked in their mailing list and they said they don't provide an all jars
included combo which they did in older versions due to lack of demand for
non maven based projects but might consider providing it if I opened a JIRA
for it.


> Also, do I understand correctly that the Pax Exam framework is
> Apache-licensed? I found this reference:
> https://github.com/ops4j/org.**ops4j.pax.exam2/blob/master/**LICENSE<https://github.com/ops4j/org.ops4j.pax.exam2/blob/master/LICENSE>
>

yes they have Apache 2.0 license.

>
> thanks,
>
> bryan
>
>


-- 

Mohamed Nufail
Undergraduate,
Department of Computer Science & Engineering,
University of Moratuwa.
Blog: http://www.nufailm.blogspot.com/

Re: Testing Derby OSGi bundle

Posted by Bryan Pendleton <bp...@gmail.com>.
> I found the Pax Exam framework [1] can be used to achieve this easily. Using Pax Exam we could write a normal JUnit test and it
> will start an OSGi framework and installs a set of bundles we specify (which would include the Derby bundle in this case) and
> then the JUnit test will be installed as a bundle. Then the tests would be invoked.

Hi Nufail,

This sounds like a very promising approach!

How are your results with this technique? It would be very interesting
to see what a test like this looks like, even a very simple test.

If you have been able to construct a test in this style, I think it would
be great if you could attach it to a JIRA issue so that we could better
understand the approach.

Do you anticipate that the testing framework would be downloaded (via Maven)
by the test scripts? Or would we reference it from our tools/java
directory like we do with other external jar files?

Also, do I understand correctly that the Pax Exam framework is
Apache-licensed? I found this reference:
https://github.com/ops4j/org.ops4j.pax.exam2/blob/master/LICENSE

thanks,

bryan


Re: Testing Derby OSGi bundle

Posted by Kristian Waagan <kr...@oracle.com>.
On 31.07.2012 10:45, Mohamed Nufail wrote:
> Hi,
>
> For the next part of my GSoC project I'm focusing on testing the Derby 
> OSGi bundle.
> I believe what's required in this case is to make sure the Derby 
> bundle operates correctly in an OSGi environment. So what is needed is 
> to install Derby in an OSGi framework and check if it installs 
> correctly and have its basic functionality.
>
> I found the Pax Exam framework [1] can be used to achieve this easily. 
> Using Pax Exam we could write a normal JUnit test and it will start an 
> OSGi framework and installs a set of bundles we specify (which would 
> include the Derby bundle in this case) and then the JUnit test will be 
> installed as a bundle. Then the tests would be invoked.
> But the problem is Pax Exam is based on JUnit 4 and Derby uses JUnit 3 
> I think.
>
> Any ideas regarding this would be appreciated.

Hi Nufail,

JUnit 3 is pretty old by now, but I think the reason why we're holding 
on to it is because we support JSR 169 / Java ME. This platform is 
currently based on J2SE 1.4 (i.e. no support for annotations).

That said, I believe JUnit 4 is backwards compatible with JUnit 3. This 
means you can write your JUnit 4 specific test, make sure it's compiled 
at/to level 1.5, and then run it (standalone or together with other 
existing Derby tests). With a little extra code in the Derby JUnit 
framework, you could make the test run only if JUnit 4 is on the 
classpath and ignore it otherwise.

I haven't actually tried this, so I don't know what kind of challenges 
you'll run into :)

Testing Derby's support for OSGi would be a very welcome effort, as I 
believe the current tests in that area are lacking. We've also seen some 
JIRA issues filed related to OSGi.


Regards,
-- 
Kristian

>
> Thanks,
> Nufail.
>
> [1] http://team.ops4j.org/wiki/display/paxexam/Pax+Exam
>
> -- 
>
> Mohamed Nufail
> Undergraduate,
> Department of Computer Science & Engineering,
> University of Moratuwa.
> Blog: http://www.nufailm.blogspot.com/
>