Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [tycho-user] tycho-demo pom first: the bundle except test bundle not started

Igor,

Add <bundleStartlevel> to pom.xml of tycho.demo.itp02.bundle.tests as the following solve the issue, that is, Activators are launched and the services are registered successfully. Now the test passed.

But I wonder why I have to add them explicitly. I have other similar projects including a test project that are all developed as Eclipse Plugin projects, but I don't need to add <bundleStartLevel> to the test project's pom and the test run successfully.

         <bundleStartLevel>
              <bundle>
                 <id>tycho.demo.itp02.pomfirst-thirdparty</id>
                 <level>4</level>
                 <autoStart>true</autoStart>
              </bundle>
              <bundle>
                 <id>tycho.demo.itp02.pomfirst-bundle</id>
                 <level>4</level>
                 <autoStart>true</autoStart>
              </bundle>
              <bundle>
                 <id>tycho.demo.itp02.bundle</id>
                 <level>4</level>
                 <autoStart>true</autoStart>
              </bundle>
           </bundleStartLevel>		   

Thanks for your help.

Guofeng


-----Original Message-----
From: tycho-user-bounces@xxxxxxxxxxx [mailto:tycho-user-bounces@xxxxxxxxxxx] On Behalf Of Igor Fedorenko
Sent: Tuesday, July 17, 2012 6:02 PM
To: tycho-user@xxxxxxxxxxx
Subject: Re: [tycho-user] tycho-demo pom first: the bundle except test bundle not started

Did you add Bundle-Activator and Bundle-ActivationPolicy to relevant bundle manifests? For pom-first projects this should be done through pom.xml configuration, check maven-bundle-plugin documentation for more details.

If you really need to force start bundles during test execution, you can do this with <bundleStartLevel> tycho-surefire-plugin configuration parameter, something like

   ...
   <bundleStartLevel>
     <plugin>
       <id>...</id>
       <level>4</level>
       <autoStart>true</autoStart>
     </plugin>
   </bundleStartLevel>
   ...


--
Regards,
Igor

On 12-07-17 12:05 AM, Guofeng Zhang wrote:
> Hi,
>
> I clone the tycho demo application and tried itp02 for pom first dependency.
>
> The demo works well following the instruction on 
> http://wiki.eclipse.org/Tycho/How_Tos/Dependency_on_pom-first_artifacts.
>
> Now I make some modification to the demo. I let PomFirst and ITP02 to 
> be a registered service by its Activator. The IT02Test changed as the
> following:
>
> public class ITP02Test {
>
>      @Test
>
>      public void basic() {
>
>          ITP02 testee = getITP02();
>
>          Assert.assertEquals("maven-bundle-plugin", 
> testee.getMessage());
>
>      }
>
>              private ITP02 getITP02() {
>
>                              ServiceReference<ITP02> ref = 
> Activator.getContext().getServiceReference(ITP02.class ) ;
>
>                              return 
> Activator.getContext().getService(ref );
>
>              }
>
> }
>
> When run the test by Maven, I got the following error:
>
> Tests in error:
>
>    basic(tycho.demo.itp02.bundle.tests.ITP02Test): A null service 
> reference is not allowed.
>
> I think this is because pomfirst-bundle and tycho.demo.itp02.bundle 
> are not started (not console output from their activators), so the 
> required services are not registered.
>
> I cannot figure out why the two bundles are not started, by analyzing 
> config.ini, the two bundles are listed in osgi.bundles, but without 
> @4:start.
>
> How to solve this issue?
>
> Thanks for your help.
>
> Guofeng
>
>
>
> _______________________________________________
> tycho-user mailing list
> tycho-user@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/tycho-user
>

_______________________________________________
tycho-user mailing list
tycho-user@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/tycho-user


Back to the top