There are actually two converter implementations available now! The reference implementation converter from OSGi (org.osgi:org.osgi.util.converter:1.0.0) went final last week, and the Felix Converter was released yesterday.
Tim Sent from my iPhone > On 27 Apr 2018, at 13:45, Christian Schneider <ch...@die-schneider.net> wrote: > > Thanks. That works fine. Especially as the converter is now available as a > release. > > Christian > > 2018-04-27 13:11 GMT+02:00 Tim Ward <tim.w...@paremus.com>: >> Have you tried using the OSGi converter? >> >> You can fill a map with properties and then just: >> >> Converters.standardConverter().convert(map).to(MessagingEndpoint.class) >> >> This will honour the defaults from the annotation - see 707.4.4.4.5 of the >> compendium. The closest link I can give is >> https://osgi.org/specification/osgi.cmpn/7.0.0/util.converter.html#util.converter-maps >> >> >> Tim >> >>> On 27 Apr 2018, at 12:06, Christian Schneider via osgi-dev >>> <osgi-osgi-...@mail.osgi.org...@mail.osgi.org> wrote: >>> >>> I am using DS components with type safe configs like below. >>> My innermost tests should run outside of OSGi. So I am using Mockito >>> to inject dependencies into my component. >>> >>> For configs I use >>> >>> @Mock >>> MessagingEndpoint; >>> >>> In the test I then define behaviour like: >>> when(config.endpoint()).thenReturn("http://localhost:8082"); >>> >>> >>> This works but you do not get the default values. So you have to set all >>> config attributes. >>> >>> Is there a better way to simulate such configs? >>> >>> Christian >>> >>> ----- >>> @ObjectClassDefinition(name = "My config") >>> public @interface MessagingEndpoint { >>> >>> @AttributeDefinition >>> String endpoint() default "http://localhost:8176"; >>> >>> @AttributeDefinition >>> int connectTimeout() default 5000; >>> } >>> >>> -- >>> -- >>> Christian Schneider >>> http://www.liquid-reality.de >>> >>> Computer Scientist >>> http://www.adobe.com >>> >>> _______________________________________________ >>> OSGi Developer Mail List >>> osgi-dev@mail.osgi.org >>> https://mail.osgi.org/mailman/listinfo/osgi-dev > > > > -- > -- > Christian Schneider > http://www.liquid-reality.de > > Computer Scientist > http://www.adobe.com >
_______________________________________________ OSGi Developer Mail List osgi-dev@mail.osgi.org https://mail.osgi.org/mailman/listinfo/osgi-dev