Hi,
You might be interested by
http://svn.apache.org/repos/asf/felix/trunk/ipojo/tests/core/logger/src/test/java/org/apache/felix/ipojo/tests/core/OSGiHelper.java
It provides an helper class to access services from pax:exam. For
example it provides a waitForService method.
Regards,
Clement
On 09.11.2009, at 18:06, Toni Menzel wrote:
Hi,
not very sure, your issue sounds not really related to pax exam.
Some thoughts:
Are you waiting long enough ? Sure that the service has been exposed
already ? You are starting the bundle yourself ? That should not
really necessary. If the bundle is not in start state, could be that
your other bundles have too much logic in start() activator method
or deadlock ?
At best you provide some more complete data like how you expose the
required service, and how your test method really looks like (not
just chunks).
Really would like to help with more concrete things but.. ;)
cheers,
Toni
On Mon, Nov 9, 2009 at 1:26 PM, Ben Liang <[email protected]>
wrote:
Hi all,
I really feel confused about how a bundle get a service in the
pax_exam??
I have two bundles, one publish a service or registry a service into
Service Registration and the other bundle want to get the service
using the following code:
MbeanInfoManager tracker = new ServiceTracker(context,
MbeanInfoManager.class.getName(), null);
tracker.open();
// grab the service
manager = (MbeanInfoManager) tracker.getService();
where MbeanInfoManager is the service.I put the two bundles into the
OSGi ,and the service can be tracked.
Now I want to make some integration test using pax_exam, so my
integration test code will be like this:
import static org.ops4j.pax.exam.CoreOptions.bundle;
import static org.ops4j.pax.exam.CoreOptions.equinox;
import static org.ops4j.pax.exam.CoreOptions.frameworks;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.options;
import static org.ops4j.pax.exam.CoreOptions.provision;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Inject;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.Configuration;
import org.ops4j.pax.exam.junit.JUnit4TestRunner;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@RunWith( JUnit4TestRunner.class )
public class TestSth {
@Inject
private BundleContext bundleContext;
@Configuration
public static Option[] configuration()
{
return options(
frameworks(
equinox()
),
provision(
bundle( "file:E:/tmp/plugins/
MbeanInfoManagerNew_1.0.0.200911061110.jar" ),
bundle( "file:E:/tmp/plugins/
MbeanInfoManagerTest.jar" )
)
);
}
@Test
public void test()throws Exception{
Bundle testBundle=getInstalledBundle("MbeanInfoManagerTest");
if(testBundle!=null){
System.out.println("Starting....");
testBundle.start();
}
}
public Bundle getInstalledBundle(String name){
Bundle[] bundles=bundleContext.getBundles();
for(Bundle bundle:bundles){
if(bundle.getSymbolicName().equals(name)){
return bundle;
}
}
return null;
}
}
now i can not get the service which has been registry int the
service registration.
why?
pls help me figure it out
Thank you very much
--
Best Regards
Ben Liang
_______________________________________________
general mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/general
--
Toni Menzel
Independent Software Developer
Professional Profile: http://okidokiteam.com
[email protected]
http://www.ops4j.org - New Energy for OSS Communities - Open
Participation Software.
_______________________________________________
general mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/general
_______________________________________________
general mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/general