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 <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-dev@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 > <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 > <http://localhost:8176/>"; > > @AttributeDefinition > int connectTimeout() default 5000; > } > > -- > -- > Christian Schneider > http://www.liquid-reality.de <http://www.liquid-reality.de/> > > Computer Scientist > http://www.adobe.com <http://www.adobe.com/> > > _______________________________________________ > OSGi Developer Mail List > osgi-dev@mail.osgi.org > https://mail.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________ OSGi Developer Mail List osgi-dev@mail.osgi.org https://mail.osgi.org/mailman/listinfo/osgi-dev