Class JUnitFramework

java.lang.Object
aQute.bnd.junit.JUnitFramework
All Implemented Interfaces:
AutoCloseable

@Deprecated public class JUnitFramework extends Object implements AutoCloseable
Deprecated.
This class provides an OSGi framework that is configured with the current bnd workspace. A project directory is used to find the workspace. This makes all repositories in the workspace available to the framework. To be able to test JUnit code against/in this framework it is necessary that all packages on the buildpath and testpath are actually exported in the framework. This class will ensure that. Once the framework is up and running it will be possible to add bundles to it. There are a number of ways that this can be achieved:
  • Build a bundle – A bnd Builder is provided to create a bundle and install it. This makes it possible to add classes from the src or test directories or resources. See bundle().
  • Add a bundle using a bnd spec – Using the bnd specs (e.g. 'org.apache.felix.configadmin;version=3'). See addBundle(String) et. al.
  • Add a bndrun file – A file bndrun file can be added. All properties in this file that can be applied after a framework is started will be applied. See addBundles(File) et. al.
Convenience methods are added to get services, see getService(Class) et. al. Notice that this framework starts in the same process as that the JUnit code runs. This is normally a separately started VM.
  • Field Details

    • executor

      final ExecutorService executor
      Deprecated.
    • promiseFactory

      final org.osgi.util.promise.PromiseFactory promiseFactory
      Deprecated.
    • trackers

      public final List<org.osgi.util.tracker.ServiceTracker<?,?>> trackers
      Deprecated.
    • bin_test

      public final Jar bin_test
      Deprecated.
    • framework

      public final org.osgi.framework.launch.Framework framework
      Deprecated.
    • context

      public final org.osgi.framework.BundleContext context
      Deprecated.
    • projectDir

      public final File projectDir
      Deprecated.
    • workspace

      public Workspace workspace
      Deprecated.
    • project

      public Project project
      Deprecated.
    • n

      static AtomicInteger n
      Deprecated.
  • Constructor Details

    • JUnitFramework

      public JUnitFramework()
      Deprecated.
      Start a framework assuming the current working directory is the project directory.
    • JUnitFramework

      public JUnitFramework(File projectDir)
      Deprecated.
      Start a framework while providing a project directory.
      Parameters:
      projectDir -
  • Method Details

    • getExtra

      private String getExtra() throws Exception
      Deprecated.
      Throws:
      Exception
    • close

      public void close() throws Exception
      Deprecated.
      Close this framework
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception
    • getBundleContext

      public org.osgi.framework.BundleContext getBundleContext()
      Deprecated.
    • getServices

      public <T> List<T> getServices(Class<T> class1) throws org.osgi.framework.InvalidSyntaxException
      Deprecated.
      Throws:
      org.osgi.framework.InvalidSyntaxException
    • getService

      public <T> T getService(Class<T> class1) throws Exception
      Deprecated.
      Throws:
      Exception
    • waitForService

      public <T> org.osgi.util.promise.Promise<T> waitForService(Class<T> class1, long timeoutInMs) throws Exception
      Deprecated.
      Throws:
      Exception
    • bundle

      public JUnitFramework.BundleBuilder bundle() throws IOException
      Deprecated.
      Throws:
      IOException
    • addBundles

      public void addBundles(String bndrun) throws Exception
      Deprecated.
      Throws:
      Exception
    • addBundles

      public void addBundles(File bndrun) throws Exception
      Deprecated.
      Throws:
      Exception
    • getWorkspace

      public Workspace getWorkspace() throws Exception
      Deprecated.
      Throws:
      Exception
    • getProject

      public Project getProject() throws Exception
      Deprecated.
      Throws:
      Exception
    • startAll

      public void startAll(List<org.osgi.framework.Bundle> bundles) throws org.osgi.framework.BundleException
      Deprecated.
      Throws:
      org.osgi.framework.BundleException
    • addBundle

      public List<org.osgi.framework.Bundle> addBundle(String spec) throws Exception
      Deprecated.
      Throws:
      Exception
    • getFactory

      private org.osgi.framework.launch.FrameworkFactory getFactory() throws Exception
      Deprecated.
      Throws:
      Exception