if you are using osgi-mock 2.x you can just pass in a map or a list of 
key/values and they are mapped automatically to an annotation instance and 
injected within the unit test.

stefan

[1] https://sling.apache.org/documentation/development/osgi-mock.html


>-----Original Message-----
>From: Konrad Windszus [mailto:[email protected]]
>Sent: Monday, January 30, 2017 1:37 PM
>To: [email protected]
>Subject: Best practice how to generate instances of Component Property
>types in unit tests
>
>When you use the Component Property Types being introduced with OSGi DS
>1.4, you need to define those as annotation classes.
>
>For unit tests it is very common, that you need to dynamically generate
>several instances of those annotations (when you want to test calling the
>activate() method with different configurations).
>Are there any good code examples or recommended libraries which ease to do
>that?
>
>I found several responses in
>http://stackoverflow.com/questions/16299717/how-to-create-an-instance-of-
>an-annotation but none of them seem like the perfect match.
>If you could share how you did that in other projects that would be great,
>Konrad
>


Reply via email to