Package org.apache.sling.commons.testing.osgi

# Class MockBundleContext

java.lang.Object
org.apache.sling.commons.testing.osgi.MockBundleContext

All Implemented Interfaces:
  `org.osgi.framework.BundleContext`, `org.osgi.framework.BundleReference`

public class MockBundleContext extends Object implements org.osgi.framework.BundleContext

## Constructor Summary

Constructors
Constructor
Description
`MockBundleContext(MockBundle bundle)`

## Method Summary

Modifier and Type
Method
Description
`void`
`addBundleListener(org.osgi.framework.BundleListener bundleListener)`
`void`
`addFrameworkListener(org.osgi.framework.FrameworkListener frameworkListener)`
`void`
`addServiceListener(org.osgi.framework.ServiceListener serviceListener)`
`void`
`addServiceListener(org.osgi.framework.ServiceListener serviceListener, String s)`
`org.osgi.framework.Filter`
`createFilter(String s)`
`org.osgi.framework.ServiceReference[]`
`getAllServiceReferences(String s, String s1)`
`org.osgi.framework.Bundle`
`getBundle()`
`org.osgi.framework.Bundle`
`getBundle(long l)`
`org.osgi.framework.Bundle`
`getBundle(String location)`
`org.osgi.framework.Bundle[]`
`getBundles()`
`File`
`getDataFile(String s)`
`String`
`getProperty(String s)`
`Object`
`getService(org.osgi.framework.ServiceReference serviceReference)`
`<S> org.osgi.framework.ServiceObjects<S>`
`getServiceObjects(org.osgi.framework.ServiceReference<S> reference)`
`<S> org.osgi.framework.ServiceReference<S>`
`getServiceReference(Class<S> clazz)`
`org.osgi.framework.ServiceReference`
`getServiceReference(String s)`
`<S> Collection<org.osgi.framework.ServiceReference<S>>`
`getServiceReferences(Class<S> clazz, String filter)`
`org.osgi.framework.ServiceReference[]`
`getServiceReferences(String s, String s1)`
`org.osgi.framework.Bundle`
`installBundle(String s)`
`org.osgi.framework.Bundle`
`installBundle(String s, InputStream inputStream)`
`<S> org.osgi.framework.ServiceRegistration<S>`
`registerService(Class<S> clazz, org.osgi.framework.ServiceFactory<S> factory, Dictionary<String,?> properties)`
`<S> org.osgi.framework.ServiceRegistration<S>`
`registerService(Class<S> clazz, S service, Dictionary<String,?> properties)`
`org.osgi.framework.ServiceRegistration`
`registerService(String[] strings, Object o, Dictionary dictionary)`
`org.osgi.framework.ServiceRegistration`
`registerService(String s, Object o, Dictionary dictionary)`
`void`
`removeBundleListener(org.osgi.framework.BundleListener bundleListener)`
`void`
`removeFrameworkListener(org.osgi.framework.FrameworkListener frameworkListener)`
`void`
`removeServiceListener(org.osgi.framework.ServiceListener serviceListener)`
`boolean`
`ungetService(org.osgi.framework.ServiceReference serviceReference)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### MockBundleContext

public MockBundleContext(MockBundle bundle)

## Method Details

### getProperty

public String getProperty(String s)

Specified by:
  `getProperty` in interface `org.osgi.framework.BundleContext`

### getBundle

public org.osgi.framework.Bundle getBundle()

Specified by:
  `getBundle` in interface `org.osgi.framework.BundleContext`
Specified by:
  `getBundle` in interface `org.osgi.framework.BundleReference`

### installBundle

public org.osgi.framework.Bundle installBundle(String s) throws org.osgi.framework.BundleException

Specified by:
  `installBundle` in interface `org.osgi.framework.BundleContext`
Throws:
  `org.osgi.framework.BundleException`

### installBundle

public org.osgi.framework.Bundle installBundle(String s, InputStream inputStream) throws org.osgi.framework.BundleException

Specified by:
  `installBundle` in interface `org.osgi.framework.BundleContext`
Throws:
  `org.osgi.framework.BundleException`

### getBundle

public org.osgi.framework.Bundle getBundle(long l)

Specified by:
  `getBundle` in interface `org.osgi.framework.BundleContext`

### getBundles

public org.osgi.framework.Bundle[] getBundles()

Specified by:
  `getBundles` in interface `org.osgi.framework.BundleContext`

### addServiceListener

public void addServiceListener(org.osgi.framework.ServiceListener serviceListener, String s) throws org.osgi.framework.InvalidSyntaxException

Specified by:
  `addServiceListener` in interface `org.osgi.framework.BundleContext`
Throws:
  `org.osgi.framework.InvalidSyntaxException`

### addServiceListener

public void addServiceListener(org.osgi.framework.ServiceListener serviceListener)

Specified by:
  `addServiceListener` in interface `org.osgi.framework.BundleContext`

### removeServiceListener

public void removeServiceListener(org.osgi.framework.ServiceListener serviceListener)

Specified by:
  `removeServiceListener` in interface `org.osgi.framework.BundleContext`

### addBundleListener

public void addBundleListener(org.osgi.framework.BundleListener bundleListener)

Specified by:
  `addBundleListener` in interface `org.osgi.framework.BundleContext`

### removeBundleListener

public void removeBundleListener(org.osgi.framework.BundleListener bundleListener)

Specified by:
  `removeBundleListener` in interface `org.osgi.framework.BundleContext`

### addFrameworkListener

public void addFrameworkListener(org.osgi.framework.FrameworkListener frameworkListener)

Specified by:
  `addFrameworkListener` in interface `org.osgi.framework.BundleContext`

### removeFrameworkListener

public void removeFrameworkListener(org.osgi.framework.FrameworkListener frameworkListener)

Specified by:
  `removeFrameworkListener` in interface `org.osgi.framework.BundleContext`

### registerService

public org.osgi.framework.ServiceRegistration registerService(String[] strings, Object o, Dictionary dictionary)

Specified by:
  `registerService` in interface `org.osgi.framework.BundleContext`

### registerService

public org.osgi.framework.ServiceRegistration registerService(String s, Object o, Dictionary dictionary)

Specified by:
  `registerService` in interface `org.osgi.framework.BundleContext`

### getServiceReferences

public org.osgi.framework.ServiceReference[] getServiceReferences(String s, String s1) throws org.osgi.framework.InvalidSyntaxException

Specified by:
  `getServiceReferences` in interface `org.osgi.framework.BundleContext`
Throws:
  `org.osgi.framework.InvalidSyntaxException`

### getAllServiceReferences

public org.osgi.framework.ServiceReference[] getAllServiceReferences(String s, String s1) throws org.osgi.framework.InvalidSyntaxException

Specified by:
  `getAllServiceReferences` in interface `org.osgi.framework.BundleContext`
Throws:
  `org.osgi.framework.InvalidSyntaxException`

### getServiceReference

public org.osgi.framework.ServiceReference getServiceReference(String s)

Specified by:
  `getServiceReference` in interface `org.osgi.framework.BundleContext`

### getService

public Object getService(org.osgi.framework.ServiceReference serviceReference)

Specified by:
  `getService` in interface `org.osgi.framework.BundleContext`

### ungetService

public boolean ungetService(org.osgi.framework.ServiceReference serviceReference)

Specified by:
  `ungetService` in interface `org.osgi.framework.BundleContext`

### getDataFile

public File getDataFile(String s)

Specified by:
  `getDataFile` in interface `org.osgi.framework.BundleContext`

### createFilter

public org.osgi.framework.Filter createFilter(String s) throws org.osgi.framework.InvalidSyntaxException

Specified by:
  `createFilter` in interface `org.osgi.framework.BundleContext`
Throws:
  `org.osgi.framework.InvalidSyntaxException`

### registerService

public <S> org.osgi.framework.ServiceRegistration<S> registerService(Class<S> clazz, S service, Dictionary<String,?> properties)

Specified by:
  `registerService` in interface `org.osgi.framework.BundleContext`

### registerService

public <S> org.osgi.framework.ServiceRegistration<S> registerService(Class<S> clazz, org.osgi.framework.ServiceFactory<S> factory, Dictionary<String,?> properties)

Specified by:
  `registerService` in interface `org.osgi.framework.BundleContext`

### getServiceReference

public <S> org.osgi.framework.ServiceReference<S> getServiceReference(Class<S> clazz)

Specified by:
  `getServiceReference` in interface `org.osgi.framework.BundleContext`

### getServiceReferences

public <S> Collection<org.osgi.framework.ServiceReference<S>> getServiceReferences(Class<S> clazz, String filter) throws org.osgi.framework.InvalidSyntaxException

Specified by:
  `getServiceReferences` in interface `org.osgi.framework.BundleContext`
Throws:
  `org.osgi.framework.InvalidSyntaxException`

### getServiceObjects

public <S> org.osgi.framework.ServiceObjects<S> getServiceObjects(org.osgi.framework.ServiceReference<S> reference)

Specified by:
  `getServiceObjects` in interface `org.osgi.framework.BundleContext`

### getBundle

public org.osgi.framework.Bundle getBundle(String location)

Specified by:
  `getBundle` in interface `org.osgi.framework.BundleContext`