From 833e2d152a8198bfa467cb2616dea657cdd6dbfa Mon Sep 17 00:00:00 2001 From: Emil Ivov Date: Wed, 16 Aug 2006 14:52:41 +0000 Subject: [PATCH] optimized imports --- .../slick/protocol/sip/SipSlickFixture.java | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/test/net/java/sip/communicator/slick/protocol/sip/SipSlickFixture.java b/test/net/java/sip/communicator/slick/protocol/sip/SipSlickFixture.java index 884238b97..b87bb97b8 100644 --- a/test/net/java/sip/communicator/slick/protocol/sip/SipSlickFixture.java +++ b/test/net/java/sip/communicator/slick/protocol/sip/SipSlickFixture.java @@ -6,8 +6,8 @@ */ package net.java.sip.communicator.slick.protocol.sip; -import junit.framework.*; import org.osgi.framework.*; +import junit.framework.*; import net.java.sip.communicator.service.protocol.*; /** @@ -155,4 +155,40 @@ public void tearDown() bc.ungetService(provider2ServiceRef); } + /** + * Returns the bundle that has registered the protocol provider service + * implementation that we're currently testing. The method would go through + * all bundles currently installed in the framework and return the first + * one that exports the same protocol provider instance as the one we test + * in this slick. + * @param provider the provider whose bundle we're looking for. + * @return the Bundle that has registered the protocol provider service + * we're testing in the slick. + */ + public static Bundle findProtocolProviderBundle( + ProtocolProviderService provider) + { + Bundle[] bundles = bc.getBundles(); + + for (int i = 0; i < bundles.length; i++) + { + ServiceReference[] registeredServices + = bundles[i].getRegisteredServices(); + + if (registeredServices == null) + continue; + + for (int j = 0; j < registeredServices.length; j++) + { + Object service + = bc.getService(registeredServices[j]); + if (service == provider) + return bundles[i]; + } + } + + return null; + } + + }