Roy Teeuwen created SLING-4724:
----------------------------------

             Summary: Mock OSGI service does not work without bind and unbind 
methods.
                 Key: SLING-4724
                 URL: https://issues.apache.org/jira/browse/SLING-4724
             Project: Sling
          Issue Type: Bug
          Components: Testing
            Reporter: Roy Teeuwen
            Priority: Minor


When making a junit test using the org.apache.sling.testing.osgi-mock library, 
the osgi context will not start up (MockOsgi.injectServices(service, 
bundleContext);) when a service which is @Reference'ed does not have a bind and 
unbind method. The following error is thrown:

java.lang.RuntimeException: Bind method with name bindSecondService not found 
for reference 'secondService' for class {}some.packagename.FirstService
at 
org.apache.sling.testing.mock.osgi.ReflectionServiceUtil.injectServiceReference(ReflectionServiceUtil.java:351)
        at 
org.apache.sling.testing.mock.osgi.ReflectionServiceUtil.injectServices(ReflectionServiceUtil.java:278)
        at 
org.apache.sling.testing.mock.osgi.MockOsgi.injectServices(MockOsgi.java:114)
        at some.packagename.FirstServiceTest.before(FirstServiceTest.java:42)

Seeing as sling works without the bind methods, this looks to me like an error 
which should not happen and a default bind method should be used?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to