This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.testing.osgi-mock-1.1.0 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-osgi-mock.git
commit 8d208171a3f361725c1f4070f4caa5a93653f278 Author: Stefan Seifert <[email protected]> AuthorDate: Mon Oct 13 14:32:45 2014 +0000 SLING-4042 move all mock projects to mocks/ subdirectory git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/osgi-mock@1631416 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 2 +- src/site/markdown/index.md | 35 --------------------------- src/site/markdown/usage.md | 59 ---------------------------------------------- 3 files changed, 1 insertion(+), 95 deletions(-) diff --git a/pom.xml b/pom.xml index 708d885..b4060c4 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ <groupId>org.apache.sling</groupId> <artifactId>sling</artifactId> <version>22</version> - <relativePath>../../parent/pom.xml</relativePath> + <relativePath>../../../parent/pom.xml</relativePath> </parent> <artifactId>org.apache.sling.testing.osgi-mock</artifactId> diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md deleted file mode 100644 index acf7d98..0000000 --- a/src/site/markdown/index.md +++ /dev/null @@ -1,35 +0,0 @@ -## About OSGi Mocks - -Mock implementation of selected OSGi APIs. - -### Maven Dependency - -```xml -<dependency> - <groupId>org.apache.sling</groupId> - <artifactId>org.apache.sling.testing.osgi-mock</artifactId> - <version>1.0.0-SNAPHOT</version> -</dependency> -``` - -### Documentation - -* [Usage](usage.html) -* [API Documentation](apidocs/) -* [Changelog](changes-report.html) - -### Implemented mock features - -The mock implementation supports: - -* Instantiating OSGi `Bundle`, `BundleContext` and `ComponentContext` objects and navigate between them. -* Read and write properties on them. -* Register OSGi services and get references to service instances -* Service and bundle listener implementation -* When adding services to BundleContext OSGi metadata from `/OSGI-INF/<pid>.xml` is read (e.g. for service ranking property) -* Mock implementation of `LogService` which logs to SLF4J in JUnit context - -The following features are *not supported*: - -* Activation and deactivation methods of services are not called automatically (but helper methods exist) -* Dependency injection does not take place automatically (but helper methods exist) diff --git a/src/site/markdown/usage.md b/src/site/markdown/usage.md deleted file mode 100644 index c7e8bb8..0000000 --- a/src/site/markdown/usage.md +++ /dev/null @@ -1,59 +0,0 @@ -## Usage - -### Getting OSGi mock objects - -The factory class `MockOsgi` allows to instantiate the different mock implementations. - -Example: - -```java -// get bundle context -BundleContext bundleContext = MockOsgi.newBundleContext(); - -// get component context -Dictionary<String,Object> properties = new Hashtable<>(); -properties.put("prop1", "value1"); -BundleContext bundleContext = MockOsgi.newComponentContext(properties); -``` - -It is possible to simulate registering of OSGi services (backed by a simple hash map internally): - -```java -// register service -bundleContext.registerService(MyClass.class, myService, properties); - -// get service instance -ServiceReference ref = bundleContext.getServiceReference(MyClass.class.getName()); -MyClass service = bundleContext.getService(ref); -``` - -### Activation and Dependency Injection - -It is possible to simulate OSGi service activation, deactivation and dependency injection and the mock implementation -tries to to its best to execute all as expected for an OSGi environment. - -Example: - -```java -// get bundle context -BundleContext bundleContext = MockOsgi.newBundleContext(); - -// create service instance manually -MyService service = new MyService(); - -// inject dependencies -MockOsgi.injectServices(service, bundleContext); - -// activate service -MockOsgi.activate(service, props); - -// operate with service... - -// deactivate service -MockOsgi.deactivate(service); -``` - -Please note: The injectServices, activate and deactivate Methods can only work properly when the SCR XML metadata files -are preset in the classpath at `/OSGI-INF`. They are generated automatically by the Maven SCR plugin, but might be -missing if your clean and build the project within your IDE (e.g. Eclipse). In this case you have to compile the -project again with maven and can run the tests - or use a Maven IDE Integration like m2eclipse. -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
