How to use assertServiceEvent with stopBundleAsync ?

10 views
Skip to first unread message

Cristiano Gavião

unread,
Feb 11, 2013, 9:38:40 AM2/11/13
to knowhowlab-...@googlegroups.com
Hi, I'm trying to assertServiceEvent and stopBundleAsync in my test.

What I want to do is certify that services provided by a bundle was released after I stop it:

I created this test, but I couldn't make it work.

Could someone give a tip what Am I missing here ?


    @Test
    public void ensureServicesAreRemovedAfterStopBundle()
            throws InvalidSyntaxException, MalformedURLException {

        ensureOneI18nServiceWasRegisteredForEachLocateFound();

        stopBundleAsync(bc, "org.lunifera.runtime.component.i18n", 0);

        // service registered within 5 sec
        assertServiceEvent(
                ServiceEvent.UNREGISTERING,
                and(create(Ii18nService.class),
                        eq(Ii18nService.LUNIFERA_I18N_SERVICE_TARGET_LOCALE,
                                "pt")), 5, TimeUnit.SECONDS);

    }

thanks.

Cristiano

Dmytro Pishchukhin

unread,
Feb 11, 2013, 9:45:53 AM2/11/13
to knowhowlab-...@googlegroups.com
Hi Cristiano,

in your case an event could not be caught because you stop bundle without any delay (= immediately). Try to use 1 or 2 seconds delay. You can use assertServiceAvailable() to check the service status.

Best regards,
Dmytro

Cristiano Gavião

unread,
Feb 11, 2013, 10:06:42 AM2/11/13
to Dmytro Pishchukhin, knowhowlab-...@googlegroups.com
Hi Dmytro,

I've already tried with a delay but no luck when using the assertServiceEvent.
But I could do this:

        stopBundleAsync(bc, "org.lunifera.runtime.component.i18n", 2,
                TimeUnit.SECONDS);

        assertBundleEvent(BundleEvent.STOPPING | BundleEvent.STOPPED
                | BundleEvent.RESOLVED, "org.lunifera.runtime.component.i18n",
                3, TimeUnit.SECONDS);

I don't think I understand the delay right. Should I put a delay and the command execution (Install, Uninstall, Stop, Start) and add a delay in the event assertion too ?


I take a look assertServiceAvailable(), but don't got your suggestion. how could I use it to check that a Service is not available instead?

thanks,

Cristiano

2013/2/11 Dmytro Pishchukhin <dmytro.pi...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "KnowHowLab OSGi testing" group.
To unsubscribe from this group and stop receiving emails from it, send an email to knowhowlab-osgi-t...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
"Tudo vale a pena se a alma não é pequena..."

Dmytro Pishchukhin

unread,
Feb 11, 2013, 10:17:19 AM2/11/13
to knowhowlab-...@googlegroups.com, Dmytro Pishchukhin
Hi Cristiano,

you can try this way:

        assertServiceAvailable(and(create(Ii18nService.class), eq(Ii18nService.LUNIFERA_I18N_SERVICE_TARGET_LOCALE, "pt")));

        stopBundleAsync(bc, "org.lunifera.runtime.component.i18n", 0);

        assertServiceUnavailable(and(create(Ii18nService.class), eq(Ii18nService.LUNIFERA_I18N_SERVICE_TARGET_LOCALE, "pt")), 5, TimeUnit.SECONDS);

--
Best regards,
Dmytro
2013/2/11 Dmytro Pishchukhin <dmytro.pi...@gmail.com>
To unsubscribe from this group and stop receiving emails from it, send an email to knowhowlab-osgi-testing+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply all
Reply to author
Forward
0 new messages