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

# Class MockComponentContext

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

All Implemented Interfaces:
  `org.osgi.service.component.ComponentContext`

public class MockComponentContext extends Object implements org.osgi.service.component.ComponentContext

## Constructor Summary

Constructors
Constructor
Description
`MockComponentContext(MockBundle bundle)`
`MockComponentContext(MockBundleContext mockBundleContext)`
`MockComponentContext(MockBundleContext mockBundleContext, javax.servlet.Servlet servlet)`
`MockComponentContext(MockBundle bundle, javax.servlet.Servlet servlet)`

## Method Summary

Modifier and Type
Method
Description
`void`
`addService(org.osgi.framework.ServiceReference reference, Object service)`
`void`
`disableComponent(String name)`
`void`
`enableComponent(String name)`
`org.osgi.framework.BundleContext`
`getBundleContext()`
`org.osgi.service.component.ComponentInstance`
`getComponentInstance()`
`Dictionary<String,Object>`
`getProperties()`
`org.osgi.framework.ServiceReference`
`getServiceReference()`
`org.osgi.framework.Bundle`
`getUsingBundle()`
`Object`
`locateService(String name)`
`Object`
`locateService(String name, org.osgi.framework.ServiceReference reference)`
`Object[]`
`locateServices(String name)`
`void`
`setProperty(Object key, Object value)`

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

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

## Constructor Details

### MockComponentContext

public MockComponentContext(MockBundle bundle)

### MockComponentContext

public MockComponentContext(MockBundleContext mockBundleContext)

### MockComponentContext

public MockComponentContext(MockBundle bundle, javax.servlet.Servlet servlet)

### MockComponentContext

public MockComponentContext(MockBundleContext mockBundleContext, javax.servlet.Servlet servlet)

## Method Details

### addService

public void addService(org.osgi.framework.ServiceReference reference, Object service)

### setProperty

public void setProperty(Object key, Object value)

### getProperties

public Dictionary<String,Object> getProperties()

Specified by:
  `getProperties` in interface `org.osgi.service.component.ComponentContext`

### locateService

public Object locateService(String name, org.osgi.framework.ServiceReference reference)

Specified by:
  `locateService` in interface `org.osgi.service.component.ComponentContext`

### getBundleContext

public org.osgi.framework.BundleContext getBundleContext()

Specified by:
  `getBundleContext` in interface `org.osgi.service.component.ComponentContext`

### disableComponent

public void disableComponent(String name)

Specified by:
  `disableComponent` in interface `org.osgi.service.component.ComponentContext`

### enableComponent

public void enableComponent(String name)

Specified by:
  `enableComponent` in interface `org.osgi.service.component.ComponentContext`

### getComponentInstance

public org.osgi.service.component.ComponentInstance getComponentInstance()

Specified by:
  `getComponentInstance` in interface `org.osgi.service.component.ComponentContext`

### getServiceReference

public org.osgi.framework.ServiceReference getServiceReference()

Specified by:
  `getServiceReference` in interface `org.osgi.service.component.ComponentContext`

### getUsingBundle

public org.osgi.framework.Bundle getUsingBundle()

Specified by:
  `getUsingBundle` in interface `org.osgi.service.component.ComponentContext`

### locateService

public Object locateService(String name)

Specified by:
  `locateService` in interface `org.osgi.service.component.ComponentContext`

### locateServices

public Object[] locateServices(String name)

Specified by:
  `locateServices` in interface `org.osgi.service.component.ComponentContext`