Class JUnitFramework

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    @Deprecated
    public class JUnitFramework
    extends java.lang.Object
    implements java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      Jar bin_test
      Deprecated.
       
      org.osgi.framework.BundleContext context
      Deprecated.
       
      (package private) java.util.concurrent.ExecutorService executor
      Deprecated.
       
      org.osgi.framework.launch.Framework framework
      Deprecated.
       
      (package private) static java.util.concurrent.atomic.AtomicInteger n
      Deprecated.
       
      Project project
      Deprecated.
       
      java.io.File projectDir
      Deprecated.
       
      (package private) org.osgi.util.promise.PromiseFactory promiseFactory
      Deprecated.
       
      java.util.List<org.osgi.util.tracker.ServiceTracker<?,​?>> trackers
      Deprecated.
       
      Workspace workspace
      Deprecated.
       
    • Constructor Summary

      Constructors 
      Constructor Description
      JUnitFramework()
      Deprecated.
      Start a framework assuming the current working directory is the project directory.
      JUnitFramework​(java.io.File projectDir)
      Deprecated.
      Start a framework while providing a project directory.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      java.util.List<org.osgi.framework.Bundle> addBundle​(java.lang.String spec)
      Deprecated.
       
      void addBundles​(java.io.File bndrun)
      Deprecated.
       
      void addBundles​(java.lang.String bndrun)
      Deprecated.
       
      JUnitFramework.BundleBuilder bundle()
      Deprecated.
       
      void close()
      Deprecated.
      Close this framework
      org.osgi.framework.BundleContext getBundleContext()
      Deprecated.
       
      private java.lang.String getExtra()
      Deprecated.
       
      private org.osgi.framework.launch.FrameworkFactory getFactory()
      Deprecated.
       
      Project getProject()
      Deprecated.
       
      <T> T getService​(java.lang.Class<T> class1)
      Deprecated.
       
      <T> java.util.List<T> getServices​(java.lang.Class<T> class1)
      Deprecated.
       
      Workspace getWorkspace()
      Deprecated.
       
      void startAll​(java.util.List<org.osgi.framework.Bundle> bundles)
      Deprecated.
       
      <T> org.osgi.util.promise.Promise<T> waitForService​(java.lang.Class<T> class1, long timeoutInMs)
      Deprecated.
       
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • executor

        final java.util.concurrent.ExecutorService executor
        Deprecated.
      • promiseFactory

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

        public final java.util.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 java.io.File projectDir
        Deprecated.
      • workspace

        public Workspace workspace
        Deprecated.
      • project

        public Project project
        Deprecated.
      • n

        static java.util.concurrent.atomic.AtomicInteger n
        Deprecated.
    • Constructor Detail

      • JUnitFramework

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

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

      • getExtra

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

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

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

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

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

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

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

        public void addBundles​(java.io.File bndrun)
                        throws java.lang.Exception
        Deprecated.
        Throws:
        java.lang.Exception
      • getWorkspace

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

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

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

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

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