Package org.apache.sling.testing.mock.osgi

# Class MockBundle

java.lang.Object
org.apache.sling.testing.mock.osgi.MockBundle

All Implemented Interfaces:
  `Comparable<org.osgi.framework.Bundle>`, `org.osgi.framework.Bundle`

public final class MockBundle extends Object implements org.osgi.framework.Bundle
Mock `Bundle` implementation.

## Field Summary

### Fields inherited from interface org.osgi.framework.Bundle

`ACTIVE, INSTALLED, RESOLVED, SIGNERS_ALL, SIGNERS_TRUSTED, START_ACTIVATION_POLICY, START_TRANSIENT, STARTING, STOP_TRANSIENT, STOPPING, UNINSTALLED`

## Constructor Summary

Constructors
Constructor
Description
`MockBundle(org.osgi.framework.BundleContext bundleContext)`
Constructor

## Method Summary

Modifier and Type
Method
Description
`<A> A`
`adapt(Class<A> type)`
`int`
`compareTo(org.osgi.framework.Bundle o)`
`Enumeration<URL>`
`findEntries(String path, String filePattern, boolean recurse)`
`org.osgi.framework.BundleContext`
`getBundleContext()`
`long`
`getBundleId()`
`File`
`getDataFile(String filename)`
`URL`
`getEntry(String name)`
`Enumeration<String>`
`getEntryPaths(String path)`
`Dictionary<String,String>`
`getHeaders()`
`Dictionary<String,String>`
`getHeaders(String locale)`
`long`
`getLastModified()`
`String`
`getLocation()`
`org.osgi.framework.ServiceReference<?>[]`
`getRegisteredServices()`
`URL`
`getResource(String name)`
`Enumeration<URL>`
`getResources(String name)`
`org.osgi.framework.ServiceReference<?>[]`
`getServicesInUse()`
`Map<X509Certificate,List<X509Certificate>>`
`getSignerCertificates(int signersType)`
`int`
`getState()`
`String`
`getSymbolicName()`
`org.osgi.framework.Version`
`getVersion()`
`boolean`
`hasPermission(Object permission)`
`Class<?>`
`loadClass(String name)`
This is primarily used within the context of unit testing by `Annotations.toObject(Class, Map, Bundle, boolean)` for injection of `Class`-typed OSGi config attributes for default values and String properties representing FQDNs.
`void`
`setHeaders(Map<String,String> value)`
Set headers for mock bundle
`void`
`setLastModified(long lastModified)`
Set the last modified value for the mock bundle
`void`
`setSymbolicName(String value)`
Set symbolic name for mock bundle
`void`
`setVersion(org.osgi.framework.Version version)`
Sets a new version for this bundle
`void`
`start()`
`void`
`start(int options)`
`void`
`stop()`
`void`
`stop(int options)`
`void`
`uninstall()`
`void`
`update()`
`void`
`update(InputStream inputStream)`

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

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

## Constructor Details

### MockBundle

public MockBundle(org.osgi.framework.BundleContext bundleContext)
Constructor

Parameters:
  `bundleContext` - Bundle context

## Method Details

### getBundleId

public long getBundleId()

Specified by:
  `getBundleId` in interface `org.osgi.framework.Bundle`

### getBundleContext

public org.osgi.framework.BundleContext getBundleContext()

Specified by:
  `getBundleContext` in interface `org.osgi.framework.Bundle`

### getEntry

public URL getEntry(String name)

Specified by:
  `getEntry` in interface `org.osgi.framework.Bundle`

### getState

public int getState()

Specified by:
  `getState` in interface `org.osgi.framework.Bundle`

### getHeaders

public Dictionary<String,String> getHeaders()

Specified by:
  `getHeaders` in interface `org.osgi.framework.Bundle`

### getHeaders

public Dictionary<String,String> getHeaders(String locale)

Specified by:
  `getHeaders` in interface `org.osgi.framework.Bundle`

### setHeaders

public void setHeaders(Map<String,String> value)
Set headers for mock bundle

Parameters:
  `value` - Header map

### getSymbolicName

public String getSymbolicName()

Specified by:
  `getSymbolicName` in interface `org.osgi.framework.Bundle`

### setSymbolicName

public void setSymbolicName(String value)
Set symbolic name for mock bundle

Parameters:
  `value` - Symbolic name

### getLastModified

public long getLastModified()

Specified by:
  `getLastModified` in interface `org.osgi.framework.Bundle`

### setLastModified

public void setLastModified(long lastModified)
Set the last modified value for the mock bundle

Parameters:
  `lastModified` - last modified

### getEntryPaths

public Enumeration<String> getEntryPaths(String path)

Specified by:
  `getEntryPaths` in interface `org.osgi.framework.Bundle`

### getLocation

public String getLocation()

Specified by:
  `getLocation` in interface `org.osgi.framework.Bundle`

### getVersion

public org.osgi.framework.Version getVersion()

Specified by:
  `getVersion` in interface `org.osgi.framework.Bundle`

### setVersion

public void setVersion(org.osgi.framework.Version version)
Sets a new version for this bundle

Parameters:
  `version` - the new version

### loadClass

public Class<?> loadClass(String name) throws ClassNotFoundException
This is primarily used within the context of unit testing by `Annotations.toObject(Class, Map, Bundle, boolean)` for injection of `Class`-typed OSGi config attributes for default values and String properties representing FQDNs.

Specified by:
  `loadClass` in interface `org.osgi.framework.Bundle`
Parameters:
  `name` - The name of the class to load.
Returns:
  the class
Throws:
  `ClassNotFoundException` - for more obvious reasons than if this was running in actual OSGi framework

### findEntries

public Enumeration<URL> findEntries(String path, String filePattern, boolean recurse)

Specified by:
  `findEntries` in interface `org.osgi.framework.Bundle`

### getRegisteredServices

public org.osgi.framework.ServiceReference<?>[] getRegisteredServices()

Specified by:
  `getRegisteredServices` in interface `org.osgi.framework.Bundle`

### getResource

public URL getResource(String name)

Specified by:
  `getResource` in interface `org.osgi.framework.Bundle`

### getResources

public Enumeration<URL> getResources(String name)

Specified by:
  `getResources` in interface `org.osgi.framework.Bundle`

### getServicesInUse

public org.osgi.framework.ServiceReference<?>[] getServicesInUse()

Specified by:
  `getServicesInUse` in interface `org.osgi.framework.Bundle`

### hasPermission

public boolean hasPermission(Object permission)

Specified by:
  `hasPermission` in interface `org.osgi.framework.Bundle`

### start

public void start()

Specified by:
  `start` in interface `org.osgi.framework.Bundle`

### stop

public void stop()

Specified by:
  `stop` in interface `org.osgi.framework.Bundle`

### uninstall

public void uninstall()

Specified by:
  `uninstall` in interface `org.osgi.framework.Bundle`

### update

public void update()

Specified by:
  `update` in interface `org.osgi.framework.Bundle`

### update

public void update(InputStream inputStream)

Specified by:
  `update` in interface `org.osgi.framework.Bundle`

### start

public void start(int options)

Specified by:
  `start` in interface `org.osgi.framework.Bundle`

### stop

public void stop(int options)

Specified by:
  `stop` in interface `org.osgi.framework.Bundle`

### getSignerCertificates

public Map<X509Certificate,List<X509Certificate>> getSignerCertificates(int signersType)

Specified by:
  `getSignerCertificates` in interface `org.osgi.framework.Bundle`

### compareTo

public int compareTo(org.osgi.framework.Bundle o)

Specified by:
  `compareTo` in interface `Comparable<org.osgi.framework.Bundle>`

### adapt

public <A> A adapt(Class<A> type)

Specified by:
  `adapt` in interface `org.osgi.framework.Bundle`

### getDataFile

public File getDataFile(String filename)

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