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> A
int
compareTo
(org.osgi.framework.Bundle o) findEntries
(String path, String filePattern, boolean recurse) org.osgi.framework.BundleContext
long
getDataFile
(String filename) getEntryPaths
(String path) getHeaders
(String locale) long
org.osgi.framework.ServiceReference<?>[]
getResource
(String name) getResources
(String name) org.osgi.framework.ServiceReference<?>[]
getSignerCertificates
(int signersType) int
getState()
org.osgi.framework.Version
boolean
hasPermission
(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.void
setHeaders
(Map<String, String> value) Set headers for mock bundlevoid
setLastModified
(long lastModified) Set the last modified value for the mock bundlevoid
setSymbolicName
(String value) Set symbolic name for mock bundlevoid
setVersion
(org.osgi.framework.Version version) Sets a new version for this bundlevoid
start()
void
start
(int options) void
stop()
void
stop
(int options) void
void
update()
void
update
(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:
getBundleId
in interfaceorg.osgi.framework.Bundle
-
getBundleContext
public org.osgi.framework.BundleContext getBundleContext()- Specified by:
getBundleContext
in interfaceorg.osgi.framework.Bundle
-
getEntry
- Specified by:
getEntry
in interfaceorg.osgi.framework.Bundle
-
getState
public int getState()- Specified by:
getState
in interfaceorg.osgi.framework.Bundle
-
getHeaders
- Specified by:
getHeaders
in interfaceorg.osgi.framework.Bundle
-
getHeaders
- Specified by:
getHeaders
in interfaceorg.osgi.framework.Bundle
-
setHeaders
Set headers for mock bundle- Parameters:
value
- Header map
-
getSymbolicName
- Specified by:
getSymbolicName
in interfaceorg.osgi.framework.Bundle
-
setSymbolicName
Set symbolic name for mock bundle- Parameters:
value
- Symbolic name
-
getLastModified
public long getLastModified()- Specified by:
getLastModified
in 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:
getEntryPaths
in interfaceorg.osgi.framework.Bundle
-
getLocation
- Specified by:
getLocation
in interfaceorg.osgi.framework.Bundle
-
getVersion
public org.osgi.framework.Version getVersion()- Specified by:
getVersion
in 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:
loadClass
in 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:
findEntries
in interfaceorg.osgi.framework.Bundle
-
getRegisteredServices
public org.osgi.framework.ServiceReference<?>[] getRegisteredServices()- Specified by:
getRegisteredServices
in interfaceorg.osgi.framework.Bundle
-
getResource
- Specified by:
getResource
in interfaceorg.osgi.framework.Bundle
-
getResources
- Specified by:
getResources
in interfaceorg.osgi.framework.Bundle
-
getServicesInUse
public org.osgi.framework.ServiceReference<?>[] getServicesInUse()- Specified by:
getServicesInUse
in interfaceorg.osgi.framework.Bundle
-
hasPermission
- Specified by:
hasPermission
in interfaceorg.osgi.framework.Bundle
-
start
public void start()- Specified by:
start
in interfaceorg.osgi.framework.Bundle
-
stop
public void stop()- Specified by:
stop
in interfaceorg.osgi.framework.Bundle
-
uninstall
public void uninstall()- Specified by:
uninstall
in interfaceorg.osgi.framework.Bundle
-
update
public void update()- Specified by:
update
in interfaceorg.osgi.framework.Bundle
-
update
- Specified by:
update
in interfaceorg.osgi.framework.Bundle
-
start
public void start(int options) - Specified by:
start
in interfaceorg.osgi.framework.Bundle
-
stop
public void stop(int options) - Specified by:
stop
in interfaceorg.osgi.framework.Bundle
-
getSignerCertificates
- Specified by:
getSignerCertificates
in interfaceorg.osgi.framework.Bundle
-
compareTo
public int compareTo(org.osgi.framework.Bundle o) - Specified by:
compareTo
in interfaceComparable<org.osgi.framework.Bundle>
-
adapt
- Specified by:
adapt
in interfaceorg.osgi.framework.Bundle
-
getDataFile
- Specified by:
getDataFile
in interfaceorg.osgi.framework.Bundle
-