[ 
https://issues.apache.org/jira/browse/SLING-4724?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14553870#comment-14553870
 ] 

Stefan Seifert commented on SLING-4724:
---------------------------------------

see the very last sentence on 
http://sling.apache.org/documentation/development/osgi-mock.html
{quote}
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.
{quote}

when you compile OSGi services with SCR metdata within you IDE you have to make 
sure the plugins defined in the POM are executed as well esp. the SCR plugin. 
this works in eclipse with m2e plugin.

i've no experience with intellij - if you find a solution i can add them to the 
documentation.

> 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
>              Labels: mocks
>
> 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