Class MockBundle
java.lang.Object
org.apache.sling.testing.mock.osgi.MockBundle
- All Implemented Interfaces:
Comparable<org.osgi.framework.Bundle>,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 -
Method Summary
Modifier and TypeMethodDescription<A> AintcompareTo(org.osgi.framework.Bundle o) findEntries(String path, String filePattern, boolean recurse) org.osgi.framework.BundleContextlonggetDataFile(String filename) getEntryPaths(String path) getHeaders(String locale) longorg.osgi.framework.ServiceReference<?>[]getResource(String name) getResources(String name) org.osgi.framework.ServiceReference<?>[]getSignerCertificates(int signersType) intgetState()org.osgi.framework.VersionbooleanhasPermission(Object permission) Class<?>This is primarily used within the context of unit testing byAnnotations.toObject(Class, Map, Bundle, boolean)for injection ofClass-typed OSGi config attributes for default values and String properties representing FQDNs.voidsetHeaders(Map<String, String> value) Set headers for mock bundlevoidsetLastModified(long lastModified) Set the last modified value for the mock bundlevoidsetSymbolicName(String value) Set symbolic name for mock bundlevoidsetVersion(org.osgi.framework.Version version) Sets a new version for this bundlevoidstart()voidstart(int options) voidstop()voidstop(int options) voidvoidupdate()voidupdate(InputStream inputStream)
-
Constructor Details
-
MockBundle
public MockBundle(org.osgi.framework.BundleContext bundleContext) Constructor- Parameters:
bundleContext- Bundle context
-
-
Method Details
-
getBundleId
public long getBundleId()- Specified by:
getBundleIdin interfaceorg.osgi.framework.Bundle
-
getBundleContext
public org.osgi.framework.BundleContext getBundleContext()- Specified by:
getBundleContextin interfaceorg.osgi.framework.Bundle
-
getEntry
- Specified by:
getEntryin interfaceorg.osgi.framework.Bundle
-
getState
public int getState()- Specified by:
getStatein interfaceorg.osgi.framework.Bundle
-
getHeaders
- Specified by:
getHeadersin interfaceorg.osgi.framework.Bundle
-
getHeaders
- Specified by:
getHeadersin interfaceorg.osgi.framework.Bundle
-
setHeaders
Set headers for mock bundle- Parameters:
value- Header map
-
getSymbolicName
- Specified by:
getSymbolicNamein interfaceorg.osgi.framework.Bundle
-
setSymbolicName
Set symbolic name for mock bundle- Parameters:
value- Symbolic name
-
getLastModified
public long getLastModified()- Specified by:
getLastModifiedin interfaceorg.osgi.framework.Bundle
-
setLastModified
public void setLastModified(long lastModified) Set the last modified value for the mock bundle- Parameters:
lastModified- last modified
-
getEntryPaths
- Specified by:
getEntryPathsin interfaceorg.osgi.framework.Bundle
-
getLocation
- Specified by:
getLocationin interfaceorg.osgi.framework.Bundle
-
getVersion
public org.osgi.framework.Version getVersion()- Specified by:
getVersionin interfaceorg.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
This is primarily used within the context of unit testing byAnnotations.toObject(Class, Map, Bundle, boolean)for injection ofClass-typed OSGi config attributes for default values and String properties representing FQDNs.- Specified by:
loadClassin interfaceorg.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
- Specified by:
findEntriesin interfaceorg.osgi.framework.Bundle
-
getRegisteredServices
public org.osgi.framework.ServiceReference<?>[] getRegisteredServices()- Specified by:
getRegisteredServicesin interfaceorg.osgi.framework.Bundle
-
getResource
- Specified by:
getResourcein interfaceorg.osgi.framework.Bundle
-
getResources
- Specified by:
getResourcesin interfaceorg.osgi.framework.Bundle
-
getServicesInUse
public org.osgi.framework.ServiceReference<?>[] getServicesInUse()- Specified by:
getServicesInUsein interfaceorg.osgi.framework.Bundle
-
hasPermission
- Specified by:
hasPermissionin interfaceorg.osgi.framework.Bundle
-
start
public void start()- Specified by:
startin interfaceorg.osgi.framework.Bundle
-
stop
public void stop()- Specified by:
stopin interfaceorg.osgi.framework.Bundle
-
uninstall
public void uninstall()- Specified by:
uninstallin interfaceorg.osgi.framework.Bundle
-
update
public void update()- Specified by:
updatein interfaceorg.osgi.framework.Bundle
-
update
- Specified by:
updatein interfaceorg.osgi.framework.Bundle
-
start
public void start(int options) - Specified by:
startin interfaceorg.osgi.framework.Bundle
-
stop
public void stop(int options) - Specified by:
stopin interfaceorg.osgi.framework.Bundle
-
getSignerCertificates
- Specified by:
getSignerCertificatesin interfaceorg.osgi.framework.Bundle
-
compareTo
public int compareTo(org.osgi.framework.Bundle o) - Specified by:
compareToin interfaceComparable<org.osgi.framework.Bundle>
-
adapt
- Specified by:
adaptin interfaceorg.osgi.framework.Bundle
-
getDataFile
- Specified by:
getDataFilein interfaceorg.osgi.framework.Bundle
-