You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Jose Guerra <jg...@gmail.com> on 2009/05/08 01:25:08 UTC

Can't execute a unit test bundle with JUnit4OSGi

Hi,

First of all i like to say *hat off* to Apache for Felix and all
technologies applied to OSGi, and particulary iPOJO which i find
extremely powerful and useful framework.
So, my case, I am just messing around with iPOJOs and i am trying to
set up a basic test case using JUnit4OSGi on Felix. So, I created a
bundle with an OSGi test case within and i deployed the bundle on
Felix (Bundle ID# 15). I also got deployed the JUnit4OSGi example
(Bundle ID# 16) shipped with the framework.

ps
START LEVEL 1
   ID   State         Level  Name
[   0] [Active     ] [    0] System Bundle (1.6.1)
[   1] [Active     ] [    1] Apache Felix Shell Service (1.2.0)
[   2] [Active     ] [    1] Apache Felix Shell TUI (1.2.0)
[   3] [Active     ] [    1] Apache Felix Bundle Repository (1.4.0)
[   4] [Active     ] [    1] Apache Felix Log Service (1.0.0)
[   5] [Active     ] [    1] Apache Felix Configuration Admin Service (1.0.10)
[   6] [Active     ] [    1] Logback_osgi Plug-in (1.0.0)
[   7] [Active     ] [    1] Apache Felix iPOJO (1.3.0.SNAPSHOT)
[   8] [Active     ] [    1] Apache Felix iPOJO URL Handler (1.3.0.SNAPSHOT)
[   9] [Active     ] [    1] Apache Felix iPOJO Arch Command (1.3.0.SNAPSHOT)
[  10] [Active     ] [    1] Apache Felix iPOJO OSGi Junit Runner
(1.1.0.SNAPSHOT)
[  11] [Active     ] [    1] Apache Felix iPOJO Extender Pattern
Handler (1.3.0.SNAPSHOT)
[  12] [Active     ] [    1] Apache Felix iPOJO OSGi Junit Runner -
Felix Command (1.1.0.SNAPSHOT)
[  15] [Active     ] [    1] Test2 Plug-in (1.0.0)
[  16] [Active     ] [    1] Junit-OSGi-Example (0)
->

Ok, so far so good. Now when i try to execute the test case in my
bundle, Felix comes out with the output:

-> junit 15
-> No tests to execute

however, if i execute the example ...

-> junit 16
Executing [Hello Service Test Suite]
....
Time: 0

OK (4 tests)

->
it works!!.

As you will see below, the bundle contains a test case, but it seems
to me that for some reason it doesn't execute the test case. So, ps,
can anyone here try to explain me what i am doing wrong?

package osgitest;

import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;

public class BarTest extends OSGiTestCase {

	public void testBar() {
		assertTrue(true);
	}
}

The bundle is deployed and started correctly

-> install file:bundle/mess/test_1.0.0.jar
Bundle ID: 15
-> 23:39:56.937 [Thread-0] INFO  test - BundleEvent INSTALLED

-> start 15
23:40:02.843 [Thread-0] INFO test - BundleEvent RESOLVED
23:40:02.843 [Thread-0] DEBUG org.apache.felix.ipojo - [DEBUG]
IPOJO-Extender : Creator thread is going to analyze the bundle 15 List
: [test [15]]
-> 23:40:02.843 [Thread-0] DEBUG org.apache.felix.ipojo - [DEBUG]
IPOJO-Extender : Creator thread is waiting - Nothing to do
23:40:02.843 [Thread-0] DEBUG org.apache.felix.ipojo - [DEBUG]
IPOJO-Extender : Creator thread is processing 15
23:40:02.843 [Thread-0] INFO  test - BundleEvent STARTED

I'd be glad if anyone here help me out on this!

Cheers

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Can't execute a unit test bundle with JUnit4OSGi

Posted by Jose Guerra <jg...@gmail.com>.
Hi Clement,

Ok, fair enough!. I didn't understand very well how this feature works.

Thanks for your help



On Fri, May 8, 2009 at 9:14 AM, Clement Escoffier
<cl...@gmail.com> wrote:
> Hi,
>
>
> On 08.05.2009, at 01:25, Jose Guerra wrote:
>
>> Hi,
>>
>> First of all i like to say *hat off* to Apache for Felix and all
>> technologies applied to OSGi, and particulary iPOJO which i find
>> extremely powerful and useful framework.
>> So, my case, I am just messing around with iPOJOs and i am trying to
>> set up a basic test case using JUnit4OSGi on Felix. So, I created a
>> bundle with an OSGi test case within and i deployed the bundle on
>> Felix (Bundle ID# 15). I also got deployed the JUnit4OSGi example
>> (Bundle ID# 16) shipped with the framework.
>>
>> ps
>> START LEVEL 1
>>  ID   State         Level  Name
>> [   0] [Active     ] [    0] System Bundle (1.6.1)
>> [   1] [Active     ] [    1] Apache Felix Shell Service (1.2.0)
>> [   2] [Active     ] [    1] Apache Felix Shell TUI (1.2.0)
>> [   3] [Active     ] [    1] Apache Felix Bundle Repository (1.4.0)
>> [   4] [Active     ] [    1] Apache Felix Log Service (1.0.0)
>> [   5] [Active     ] [    1] Apache Felix Configuration Admin Service
>> (1.0.10)
>> [   6] [Active     ] [    1] Logback_osgi Plug-in (1.0.0)
>> [   7] [Active     ] [    1] Apache Felix iPOJO (1.3.0.SNAPSHOT)
>> [   8] [Active     ] [    1] Apache Felix iPOJO URL Handler
>> (1.3.0.SNAPSHOT)
>> [   9] [Active     ] [    1] Apache Felix iPOJO Arch Command
>> (1.3.0.SNAPSHOT)
>> [  10] [Active     ] [    1] Apache Felix iPOJO OSGi Junit Runner
>> (1.1.0.SNAPSHOT)
>> [  11] [Active     ] [    1] Apache Felix iPOJO Extender Pattern
>> Handler (1.3.0.SNAPSHOT)
>> [  12] [Active     ] [    1] Apache Felix iPOJO OSGi Junit Runner -
>> Felix Command (1.1.0.SNAPSHOT)
>> [  15] [Active     ] [    1] Test2 Plug-in (1.0.0)
>> [  16] [Active     ] [    1] Junit-OSGi-Example (0)
>> ->
>>
>> Ok, so far so good. Now when i try to execute the test case in my
>> bundle, Felix comes out with the output:
>>
>> -> junit 15
>> -> No tests to execute
>>
>> however, if i execute the example ...
>>
>> -> junit 16
>> Executing [Hello Service Test Suite]
>> ....
>> Time: 0
>>
>> OK (4 tests)
>>
>> ->
>> it works!!.
>>
>> As you will see below, the bundle contains a test case, but it seems
>> to me that for some reason it doesn't execute the test case. So, ps,
>> can anyone here try to explain me what i am doing wrong?
>>
>> package osgitest;
>>
>> import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
>>
>> public class BarTest extends OSGiTestCase {
>>
>>        public void testBar() {
>>                assertTrue(true);
>>        }
>> }
>>
>> The bundle is deployed and started correctly
>>
>> -> install file:bundle/mess/test_1.0.0.jar
>> Bundle ID: 15
>> -> 23:39:56.937 [Thread-0] INFO  test - BundleEvent INSTALLED
>>
>> -> start 15
>> 23:40:02.843 [Thread-0] INFO test - BundleEvent RESOLVED
>> 23:40:02.843 [Thread-0] DEBUG org.apache.felix.ipojo - [DEBUG]
>> IPOJO-Extender : Creator thread is going to analyze the bundle 15 List
>> : [test [15]]
>> -> 23:40:02.843 [Thread-0] DEBUG org.apache.felix.ipojo - [DEBUG]
>> IPOJO-Extender : Creator thread is waiting - Nothing to do
>> 23:40:02.843 [Thread-0] DEBUG org.apache.felix.ipojo - [DEBUG]
>> IPOJO-Extender : Creator thread is processing 15
>> 23:40:02.843 [Thread-0] INFO  test - BundleEvent STARTED
>>
>> I'd be glad if anyone here help me out on this!
>
> As said by Filippo, you have to add a test suite or the test case in your
> manifest (bundle 15):
> Test-Suite: osgitest.BarTest
>
> junit4osgi detects tests by using an extender pattern. So, it looks in all
> the bundles if they contain the Test-Suite header.
>
> Regards,
>
> Clement
>
>
>
>
>>
>>
>> Cheers
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Can't execute a unit test bundle with JUnit4OSGi

Posted by Clement Escoffier <cl...@gmail.com>.
Hi,


On 08.05.2009, at 01:25, Jose Guerra wrote:

> Hi,
>
> First of all i like to say *hat off* to Apache for Felix and all
> technologies applied to OSGi, and particulary iPOJO which i find
> extremely powerful and useful framework.
> So, my case, I am just messing around with iPOJOs and i am trying to
> set up a basic test case using JUnit4OSGi on Felix. So, I created a
> bundle with an OSGi test case within and i deployed the bundle on
> Felix (Bundle ID# 15). I also got deployed the JUnit4OSGi example
> (Bundle ID# 16) shipped with the framework.
>
> ps
> START LEVEL 1
>   ID   State         Level  Name
> [   0] [Active     ] [    0] System Bundle (1.6.1)
> [   1] [Active     ] [    1] Apache Felix Shell Service (1.2.0)
> [   2] [Active     ] [    1] Apache Felix Shell TUI (1.2.0)
> [   3] [Active     ] [    1] Apache Felix Bundle Repository (1.4.0)
> [   4] [Active     ] [    1] Apache Felix Log Service (1.0.0)
> [   5] [Active     ] [    1] Apache Felix Configuration Admin  
> Service (1.0.10)
> [   6] [Active     ] [    1] Logback_osgi Plug-in (1.0.0)
> [   7] [Active     ] [    1] Apache Felix iPOJO (1.3.0.SNAPSHOT)
> [   8] [Active     ] [    1] Apache Felix iPOJO URL Handler  
> (1.3.0.SNAPSHOT)
> [   9] [Active     ] [    1] Apache Felix iPOJO Arch Command  
> (1.3.0.SNAPSHOT)
> [  10] [Active     ] [    1] Apache Felix iPOJO OSGi Junit Runner
> (1.1.0.SNAPSHOT)
> [  11] [Active     ] [    1] Apache Felix iPOJO Extender Pattern
> Handler (1.3.0.SNAPSHOT)
> [  12] [Active     ] [    1] Apache Felix iPOJO OSGi Junit Runner -
> Felix Command (1.1.0.SNAPSHOT)
> [  15] [Active     ] [    1] Test2 Plug-in (1.0.0)
> [  16] [Active     ] [    1] Junit-OSGi-Example (0)
> ->
>
> Ok, so far so good. Now when i try to execute the test case in my
> bundle, Felix comes out with the output:
>
> -> junit 15
> -> No tests to execute
>
> however, if i execute the example ...
>
> -> junit 16
> Executing [Hello Service Test Suite]
> ....
> Time: 0
>
> OK (4 tests)
>
> ->
> it works!!.
>
> As you will see below, the bundle contains a test case, but it seems
> to me that for some reason it doesn't execute the test case. So, ps,
> can anyone here try to explain me what i am doing wrong?
>
> package osgitest;
>
> import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
>
> public class BarTest extends OSGiTestCase {
>
> 	public void testBar() {
> 		assertTrue(true);
> 	}
> }
>
> The bundle is deployed and started correctly
>
> -> install file:bundle/mess/test_1.0.0.jar
> Bundle ID: 15
> -> 23:39:56.937 [Thread-0] INFO  test - BundleEvent INSTALLED
>
> -> start 15
> 23:40:02.843 [Thread-0] INFO test - BundleEvent RESOLVED
> 23:40:02.843 [Thread-0] DEBUG org.apache.felix.ipojo - [DEBUG]
> IPOJO-Extender : Creator thread is going to analyze the bundle 15 List
> : [test [15]]
> -> 23:40:02.843 [Thread-0] DEBUG org.apache.felix.ipojo - [DEBUG]
> IPOJO-Extender : Creator thread is waiting - Nothing to do
> 23:40:02.843 [Thread-0] DEBUG org.apache.felix.ipojo - [DEBUG]
> IPOJO-Extender : Creator thread is processing 15
> 23:40:02.843 [Thread-0] INFO  test - BundleEvent STARTED
>
> I'd be glad if anyone here help me out on this!

As said by Filippo, you have to add a test suite or the test case in  
your manifest (bundle 15):
Test-Suite: osgitest.BarTest

junit4osgi detects tests by using an extender pattern. So, it looks in  
all the bundles if they contain the Test-Suite header.

Regards,

Clement




>
>
> Cheers
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Can't execute a unit test bundle with JUnit4OSGi

Posted by Jose Guerra <jg...@gmail.com>.
Hi Filippo,

ehhh. nope!. just only the test case. Do we need to create the test
suite?. Sorry if we do, thought it was just like a regular unit test
class on JUnit. I misunderstood that point from the link you pointed
it out.

Thanks for your response
Cheers
Jose


On Fri, May 8, 2009 at 7:09 AM, Filippo Diotalevi
<fi...@gmail.com> wrote:
> On Fri, May 8, 2009 at 1:25 AM, Jose Guerra <jg...@gmail.com> wrote:
>> Hi,
>> As you will see below, the bundle contains a test case, but it seems
>> to me that for some reason it doesn't execute the test case. So, ps,
>> can anyone here try to explain me what i am doing wrong?
>
> Hi,
>  have you created the TestSuite and added the Test-Suite header as
> explained at
> http://felix.apache.org/site/apache-felix-ipojo-junit4osgi-tutorial.html
> ?
>
> --
> Filippo Diotalevi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Can't execute a unit test bundle with JUnit4OSGi

Posted by Filippo Diotalevi <fi...@gmail.com>.
On Fri, May 8, 2009 at 1:25 AM, Jose Guerra <jg...@gmail.com> wrote:
> Hi,
> As you will see below, the bundle contains a test case, but it seems
> to me that for some reason it doesn't execute the test case. So, ps,
> can anyone here try to explain me what i am doing wrong?

Hi,
  have you created the TestSuite and added the Test-Suite header as
explained at
http://felix.apache.org/site/apache-felix-ipojo-junit4osgi-tutorial.html
?

-- 
Filippo Diotalevi

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org