<dependency>
<groupId>org.osgi.enroute</groupId>
<artifactId>enroute.osgi.junit.wrapper</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
import org.junit.Test;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.InvalidSyntaxException;
import aQute.lib.junit.JUnitFramework;
import aQute.lib.osgi.AnnotatedClassLoader;
import aQute.lib.osgi.AnnotatedClassLoader.AnnotatedResource;
import aQute.libg.junit.util.JunitUtil;
public class MyLibraryTest {
@Test
public void testMyLibrary() throws BundleException, InvalidSyntaxException {
BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
JUnitFramework jUnitFramework = new JUnitFramework(bundleContext);
AnnotatedClassLoader classLoader = jUnitFramework.classloader(MyLibrary.class);
MyLibrary myLibrary = classLoader.newInstance(MyLibrary.class);
assertEquals("Hello World", myLibrary.sayHello());
}
}